Microcontroller Labs Lab 1 – The LED Test Mode Dr. Gregg Chapman

Slides:



Advertisements
Similar presentations
UBI >> Contents Chapter 7 Timers Laboratories MSP430 Teaching Materials Texas Instruments Incorporated University of Beira Interior (PT) Pedro Dinis Gaspar,
Advertisements

Lab7: Introduction to Arduino
Microcontroller Programming II MP6-1
Chung-Ta King National Tsing Hua University
Chung-Ta King National Tsing Hua University
MICROCONTROLLERS MODULE 2 Programming, Controlling and Monitoring.
Introduction of Holtek HT-46 series MCU
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Electronic Instrumentation 1 Experiment 7 Digital Logic Devices and the 555 Timer Part A: Basic Logic Gates Part B: Flip Flops Part C: Counters Part D:
Pulse Width Modulation (PWM) LED Dimmer Circuit
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Dr. Hoganson CSIS HC11 Demo Program This is our first lab using the 68HC11 microcontroller. We will “talk” to the microcontroller from a PC, run.
Introduction to Arduino Prepared by R. Lamond.  “Arduino is an open-source electronics prototyping platform based on flexible, easy- to-use hardware.
Timers and Interrupts Shivendu Bhushan Sonu Agarwal.
ARDUINO PROGRAMMING Working with the Arduino microcontroller.
LAB 7: WDT+ and Low-Power Optimization
Dr. Hoganson CSIS Segment Display and Count by 16 This is our third lab using the 68HC11 microcontroller. We will write a program that counts by.
T IMERS - 2. O UTPUT U NIT Each capture/compare block contains an output unit. The output unit is used to generate output signals such as PWM signals.
16-Bit Timer/Counter 1 and 3 Counter/Timer 1,3 (TCNT1, TCNT3) are identical in function. Three separate comparison registers exist. Thus, three separate.
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
ARM Timers.
EE 446 Project Assignment Top Design Sensor Components Pin Assignment and Configuration Completed Physical Setup Project Tasks.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Page 1 D&C EBV Seminar June 2003 Motor Demo C868 Chevillot/Jansen June 2003 N e v e r s t o p t h i n k i n g. Infineon C868 Hands On Training CAPCOM6.
ECE 353 Introduction to Microprocessor Systems Discussion 11.
Khaled A. Al-Utaibi  The Push Button  Interfacing Push Buttons to Arduino  Programming Digital Inputs  Working with “Bouncy”
1 Lab 5: Controls and feedback. 2 Lab 5: Control and Feedback This embedded system uses the Photo sensor to detect the light intensity of the environment.
Lecture 11: TI MSP430 Timers Compare Modes
LAB 8: Program Design Pattern and Software Architecture
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
PPI-8255.
Chapter 5 - Interrupts.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
Mindstorm NXT-G Introduction Towson University Robotics.
Pulse-Width Modulation: Simulating variable DC output
Introduction to Projects using Microcontroller Md. Khalilur Rhaman Credit: Interface Lab.
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
Revision questions CENG2400 v.14b 1 CENG2400 Revision, Question 1 A system has an ARM processor with a 32-bit General Purpose Input Output (GPIO) module.
Application Case Study Christmas Lights Controller
80C51 Block Diagram ECE Overview.
The first change to your project files that is needed is to change the device to the correct FPGA. This is done by going to the Assignments tab on the.
CS4101 Introduction to Embedded Systems Lab 6: Low-Power Optimization
Microcontroller basics
Timer and Interrupts.
Repetition Structures Chapter 9
Chapter 6 General Purpose Input/Output
Lesson Outline Peripherals Memory-Mapped IO Ports GPIO Multiplexing
Prof. Chung-Ta King Department of Computer Science
AVR Addressing Modes Subject: Microcontoller & Interfacing
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or the.
Blinking an LED Using MSP430ware to Control GPIO
Lesson 9: "if-else-if" and Conditional Logic
EMT 348: Microcontroller Timer/counter
CENG2400 Revision Q1a A system has an ARM processor with a 32-bit General Purpose Input Output (GPIO) module. Two on/off switches are connected to bit-3.
MicroEconomix 1500 RSLogix 500 LAB#2
ECE 3567 Microcontrollers Dr. Gregg J Chapman
ECE 3567 Microcontroller Lab
8051 Micro Controller.
ECE 3430 – Intro to Microcomputer Systems
CS4101 Introduction to Embedded Systems Lab 2: Basic IO and Timer
Prof. Chung-Ta King Department of Computer Science
EET 2259 Unit 7 Case Structures; Sequence Structures
ECE 3567 Microcontroller Lab
ECE 3567 Microcontrollers Lab
ECE 3567 Microcontrollers Lab
ECE 3567 Microcontroller Lab
Presentation transcript:

Microcontroller Labs Lab 1 – The LED Test Mode Dr. Gregg Chapman ECE 3567 Microcontroller Labs Lab 1 – The LED Test Mode Dr. Gregg Chapman

Lab 1 – LED Test Mode Goals Set up Timer TB0 for Pulse Width Modulation on three outputs Make additions to the parse_Command( ) function to take action for all commands associated with the LED test Mode Modify the main.c loop to check for an active LED Test Mode Use the Timer 1 ISR routine to implement the “flashing” modes for the LH and LC commands.

Pulse Width Modulation Set-up Write and initialization routine for Pulse Width Modulation, called Init_PWM() Configure three outputs: P3.6, P3.7, and P2.2 Set the Clock Period of the Timer for Pulse Width Modulation for TB0 Setup 3 Compare Registers to control the Duty Cycle of the Pulse Width Modulation Initialize the PWMs Add the Init_PWM() initialization Routine to main.c

Pulse Width Modulation Set-up

Pulse Width Modulation Set-up

Configure the Three Outputs Set the data direction of the port pins using the PxDIR registers Select the Secondary Function for each of the outputs to be configuring the same bits in the PxSEL0 and PxSEL1 registers as you selected in the PxDIR register. Set the bits for PxSEL1 and clear the bits for PxSEL0

TB0 Timer In the Users Manual, read the section for Timer B (pp. 664-685), paying particular attention to the COMPARE MODE and OUTPUT MODE sections. TB0CTL is the Timer B Control Register TB0CCTLx are the Comparator Control Registers TB0R is the Timer B0 Count register TB0CCRn are the Compare Registers

TB0 Timer Registers Registers that you will need to program or initialize are indicated in RED.

TB0CTL page 678 of the Users Manual The register default is 0x0000 Verify 16 bit operation Select the ACLK as a timer source Place the timer in Up Mode

Compare Registers TB0CCR0 is the PERIOD count for the PWM repetition rate. The timer is set-up to run off of the ACLK = 32.768 KHz The desired repetition rate for PWM is 10 milliSeconds (100Hz) Therefore value for this PERIOD is a count of 328, or 0x0148. This has been #defined for you as PERIOD. TB0.2 is connected to the P3.6 which is wired to the BLUE element in the RGB LED TB0CCR2 is written with values to change the DUTY CYCLE of the BLUE PWM TB0.3 is connected to the P3.7 which is wired to the GREEN element in the RGB LED TB0CCR3 is written with values to change the DUTY CYCLE of the GREEN PWM TB0.4 is connected to the P2.2 which is wired to the RED element in the RGB LED TB0CCR4 is written with values to change the DUTY CYCLE of the RED PWM Use the variables duty_cycle_blue, duty_cycle_green, and duty_cycle_red to update these 3 comparators Initialize the 3 pulse widths to 0x00FF NOTE: Never write values greater than the PERIOD (0x0148)

TB0CCTL2, TB0CCTL3 , TB0CCTL4 page 681 of the Users Manual Using the Users Manual, figure out the CONTROL register values for each of the three duty cycle compares. All three are configured with the same value. The register default is 0x0000 Set the CLLD so that the TB0CLx (re)loads whenever the TBOR contains a count of 0. Select the OUTMOD so that the output is RESET when the timer counts to the TBxCLn value, and SET when the timer counts to the TBxCL0 value. CHECKPOINT 1: Show your Init_PWM() register values to a Lab Monitor to verify that they are correct before continuing.

Init_PWM() Should look similar to this:

Edit parse_Command () The function parse_Command() reads the two character command from the serial port and stores it in the volatile unsigned char Command. after the comet that says “Act on the Command”, add a switch (Command) statement that includes a case for every command. For the case: LT //LED Test Mode add the following code: LCD_Control = FALSE; // Boolean to turn off LCD LED_Control = TRUE; // Boolean to enable LED manual Control LED_Test = TRUE; // Boolean that LED Mode is enabled RC_Control = FALSE; // RC Voltage Mode is disabled T_Control = FALSE; // Temperature Control is disabled T_Measure = FALSE; // Temperature Mode is disabled clearLCD(); // Clear the LCD display toggle = 0; // Used for flashing the RGB LED Flash = FALSE; // Used for flashing the RGB LED LED_Color = No_Color; // Variable containing the current LED color break;

Edit parse_Command () For the cases: LT LH, LR, LO, LY, LG, LB, LP and LC Set LED_Color = (the name of the color as defined in 3567.h) Set Flash – Flash = FLASE; except for LH and LC. For those commands set Flash = TRUE;

Add update_RGB() to RGB.c The function update_RGB() controls the PWM values to set the RGB LED to the appropriate color. Red - duty_cycle_red = 0x070; Blue - duty_cycle_red = 0x000; duty_cycle_green = 0x000; duty_cycle_green = 0x000; duty_cycle_blue = 0x000; duty_cycle_blue = 0x07A; Orange - duty_cycle_red = 0x0E4; Purple - duty_cycle_red = 0x00C; duty_cycle_green = 0x014; duty_cycle_green = 0x000; duty_cycle_blue = 0x000; duty_cycle_blue = 0x030; Yellow - duty_cycle_red = 0x0E4; duty_cycle_green = 0x08B; duty_cycle_blue = 0x000; Green - duty_cycle_red = 0x000; duty_cycle_green = 0x04A; duty_cycle_blue = 0x000

Add update_RGB() to RGB.c Write nested IF-ELSE statements that tests LED_Color and sets the PWMs accordingly. The code should only execute if LED_Control is TRUE.

Add update_RGB() to RGB.c At the end of update_RGB() write the duty_cycle values to the PWM comparators for each color. e.g. TB0CCR2 = duty_cycle_blue; // CCR2 PWM duty cycle etc. CHECKPOINT 2: Demonstrate the LT, LR, LO, LY,LG,LB, and LP commands to a Lab Monitor. Write a function called PWM_null() that sets all of the duty cycles and the three color comparator values to ZERO. Use this in combination with LED_Control to enable and disable the LED with the LE and LD commands respectively. CHECKPOINT 3: Demonstrate the LD and LE commands to a Lab Monitor

Changes to main.c Add (or uncomment) Init_PWM() In the main loop, inside the (ISR_Flag == 1) if statement, add an if statement that runs update_RGB only if both LED_Test and LED_Control are both TRUE. Write code inside the Timer_A ISR makes the RGB LED Flash if LED_Control is TRUE and Flash is TRUE. You can use Toggle to track whether the LED is off or on. BIG HINT: The easiest way to turn each of the three RGB LED elements off and on is to set the PWM output pins to INPUTS and then back to OUTPUTS. This way, you don’t have to mess with the control registers or storing and restoring the PWM values. NOTE: The LED must Flash at EXACTLY 4 Hz to be given credit CHECKPOINT 4: Demonstrate the LC and LH commands to a Lab Monitor

Checkpoints for Today Show your Init_PWM() register values to a Lab Monitor to verify that they are correct before continuing. Demonstrate the LT, LR, LO, LY,LG,LB, and LP commands to a Lab Monitor. Demonstrate the LD and LE commands to a Lab Monitor Demonstrate the LC and LH commands to a Lab Monitor Replace all items in the bins or cabinet and clean off the Lab bench.