NXP Semiconductors Freescale DEMOEM MCF51EM Lab Tutorial

Specifications

Brand: NXP Semiconductors
Category: Microcontrollers
Model: Freescale DEMOEM MCF51EM
File Type: PDF
File Size: —
Pages: 4

Read Online

Read the NXP Semiconductors Freescale DEMOEM MCF51EM Lab Tutorial online using the built-in PDF viewer.

Text of the manual

These labs highlight key features of the MCF51EM

microcontroller and are implemented as a standard CodeWarrior project without an RTOS framework. They are also intended to serve as software examples of peripheral configuration and functional operation. For code examples using the MQX RTOS, please refer to the DEMOEM MQX Lab Tutorials document within the documentation section of the Getting Started DVD. Before You Begin Complete the steps in the Quick Start Guide to install 1. CodeWarrior for Microcontrollers v6.3 Special Edition (30-day evaluation version). Ensure the DEMOEM board jumpers are configured in their 2. factory default positions, as described in the DEMOEM User Manual within the documentation section of the Getting Started DVD. The demonstration code was programmed into the flash memory of the MCF51EM MCU prior to shipment of the DEMOEM kit. It should not be necessary to re-program the device unless you have already completed the MQX labs or have downloaded your own development code to MCU flash. Program the Demo Code to MCU Flash In the event that flash has been over-written since the arrival of your DEMOEM kit, download the project code to the MCU as follows: Select the ‘DEMOEM Project for CodeWarrior 6.3’ link under 1. the Software tab of the Getting Started DVD and save the project to your hard drive. Open CodeWarrior for Microcontrollers. From the Windows 2. Start menu, select “Programs>Freescale CodeWarrior>CW for Microcontrollers V6.3>CodeWarrior IDE.” Open the lab project by selecting the File>Open menu 3. option and navigating to the directory path where the DEMOEM-CW63.mcp file was saved during Step 1. In the project pane, select the “P&E Multilink/Cyclone Pro” 4. build target, as shown below: Compile the project by pressing the F7 key or by 5. clicking the Make icon on the project pane. Connect the DEMOEM board to your computer using the 6. USB cable included with the kit. Then power the board by sliding switch K6 in the upper left corner of the board to the left-most position. The red Power LED, the green USB LED, and the QE8 Signal Generator LEDS should be on. Now start the debugger by clicking the 7. Debug icon. The P&E MCF51xx Connection Manager window will 8. now appear as shown below. Click the Connect button and a dialog box will appear asking if you would like to erase the flash and program it with the project code. Select OK to proceed. After the code has been programmed to flash, begin code 9. execution in one of several ways: a. Press the debugger Run button. b. Press the DEMOEM hardware Reset button. c. Disconnect and reconnect the USB cable from the DEMOEM board. d. Toggle power switch K6 to power-down, then power-up the MCU. Once code is executing, you may close the True-Time 10. Simulator and Real-Time Debugger window. You should now see a welcome message on the DEMOEM LCD: Demo Code Functional Structure The demonstration code operates as a state machine (see back page for program flow diagram). Progression through the states is controlled via the SW1 button. Once the Welcome state is exited, it is impossible to return without a Reset/POR. Familiarize yourself with the DEMOEM hardware and the various user interfaces that will be used over the course of the following lab exercises, many of which have been labeled on the board diagram (see back page). State 1 Measure Typical Power and Energy Parameters of an Emulated Three-Phase System Using the MCF51EM ADC and PDB This lab demonstrates the smart metering capability of the MCF51EM microcontroller. Code configures the ADC and uses the Programmable Delay Block (PDB) to trigger conversions at precisely-timed intervals to account for phase delay between voltage and current measurements. The resulting conversions are stored to a cyclic RAM buffer for calculation of RMS voltage (V) and current (I), current at the fundamental frequency (IF), power factor (PF), energy (E), active power (P), reactive power (RP), apparent power (AP) and total harmonic distortion (TH). The DEMOEM 9S08QE8 signal generator circuit in the lower right corner of the board must be configured for normal mode operation, as indicated by one blink every three seconds of the LED labeled “PTC2.” Use push button SW5 to cycle the signal generator through its operating modes until normal mode is achieved. For more information regarding the signal generator functionality, refer to the QE8 Signal Generator User Manual within the documentation section of the Getting Started DVD. User Interface • SW1 advances to the next state/demo. • SW2 advances through the available measurements/ calculations as follows: RMS voltage (V) -> RMS current (I) -> current at the fundamental frequency (IF) -> power factor (PF) -> energy (E) -> active power (P) -> reactive power (RP) -> apparent power (AP) -> total harmonic distortion (TH) -> RMS voltage (V) -> • SW3 and SW4 scroll backward and forward, respectively, through the individual measurements/calculations: line1<-> line2 <-> line 3 <-> total <-> line1 * Note that some parameters do not have a “total” field. • Potentiometer W1 adjusts the amplitude of the voltage waveforms all together (lines 1, 2, and 3 simultaneously). • Potentiometer W2 adjusts the amplitude of the current waveforms all together (lines 1, 2, and 3 simultaneously). • Potentiometer W3 adjusts the phase delay between the voltage and current waveforms. Step by Step Instructions Press SW1 until you see the “Measurement” state on 1. the display. Press SW2 to enter the metering demo. RMS 2. voltage for line1 will be shown on the LCD. Step the metering demonstration through all 3. the calculated parameters using SW2 and note the change in each parameter as you vary the stimulus waveforms using the signal generator’s potentiometers. State 2 Use the IRTC Tamper Log Feature to Track Hardware Tamper Events The MCF51EM independent real-time clock (IRTC) includes a feature that records the type and timestamp when hardware tampering events, such as a change in state of the Tamper device pin or removal of the IRTC VBAT supply during normal operation, occur. For this demonstration, install a CR2032 battery (not included with the DEMOEM kit) in the appropriate socket underneath the board to avoid continuous tamper detection for missing VBAT source. Then install a jumper at J37 to connect the MCU VBAT pin to the CR2032 battery source. User Interface • SW1 advances to the next state/demo. • Press (SW2 + SW3) or (SW2 + SW4) to clear the tamper log. • SW3 and SW4 scroll backward and forward, respectively, through the Tamper log entries recorded in MCU flash. Step by Step Instructions Press SW1 until you see the “Tamper Log” state on 1. the display. Press SW2, SW3 or SW4 to view the contents of the log in 2. flash, which should be initialized to 00-00-00 on reset. Press and hold the Tamper button (near Reset below the 3. LCD) for a few seconds before releasing it. You should see new events recorded in the tamper log: one timestamp with code “P” to indicate a tamper event due to a change in state of the MCU Tamper pin, and another with timestamp code “A” to indicate when the pin tamper event was cleared. The recorded time of each tamper event is displayed as HH-MM-SSC where HH=hours, MM=minutes, SS=seconds, and C=tamper code. Now remove the CR2032 4. battery and wait a few seconds before you reinstall it. Again, you should notice two new entries in the tamper log. One with a timestamp code “b” to indicate a VBAT supply interruption during normal MCU operation, and another with the “A” timestamp code to again note when the battery tamper event cleared. DEMOEM Lab Tutorial: V1 ColdFire MCU for smart metering

DEMOEM Lab Tutorial: V1 ColdFire MCU for smart metering

Clear the log of all entries by tapping either (SW2 + SW3) 5. or (SW2 + SW4) simultaneously. When the log is cleared, a message will be displayed on the LCD as follows: State 3 Configure the IRTC Time of Day During this lab, you will use the simple user interface to configure the IRTC for the desired time of day. If you have a CR2032 battery installed on the DEMOEM board, and jumper J37 in place per the IRTC Tamper Log exercise above, you will also be able to observe the correct time displayed by the demo even after extended periods with the board power disconnected. User Interface • SW1 advances to the next state/demo. • SW2 increments the hours setting by one. • SW3 increments the minutes setting by one. • SW4 resets the seconds counter to zero. Step by Step Instructions Press SW1 until you see the IRTC Time 1. of Day state on the display, with the following syntax: HHH-MM- SS, where H marks the hours field, HH=hours, MM=minutes, and SS=seconds. Press SW2, SW3, and SW4 to set the time as desired. 2. Now, if you have a CR2032 battery installed on your 3. DEMOEM board, either disconnect the USB cable from the board, or use power switch K6 to disable power to the MCU. Wait a while and then restore power to the board. On power-up, the demo code will display the State 0 welcome message again. However, when you use SW1 to advance back to the IRTC TOD state, you will notice the clock has continued from the setting you programmed prior to powering down the board. In order to reset the IRTC settings back to default, remove 4. the CR2032 battery, then disable power to the MCU using switch K6 or by disconnecting the USB cable. State 4 Configure the IRTC Calendar (Date) Settings As for the previous lab, you will use the simple user interface to configure the IRTC for the desired day, month, and year. If you have a CR2032 battery installed on the DEMOEM board, and jumper J37 in place per the IRTC Tamper Log exercise above, you will also be able to observe the correct time and date displayed by the demo even after extended periods with the board power disconnected. User Interface • SW1 advances to the next state/demo. • SW2 increments the year setting by one. • SW3 increments the month setting by one. • SW4 increments the day setting by one. Step by Step Instructions Press SW1 until you see the IRTC Calendar 1. state on the display, with the following syntax: dDD-MM-YY, where d marks the days field, DD=day, MM=month, and YY=year. Press SW2, SW3, and SW4 to set the year, month, and day 2. settings, respectively. You can repeat the power-down test from the IRTC TOD 3. exercise above, and again will see that time and date settings are retained over extended periods of MCU power- down as long as the VBAT battery source is maintained. Use SW1 to return to the IRTC TOD state and set the time to 4. 23:59:00, for instance. Wait one minute and verify that the date incremented as expected. Note that the IRTC cannot safeguard against invalid date settings (for instance, you may initialize the date to February 30), but will adjust the date appropriately given a valid initial setting. State 5 Use a Pair of DEMOEM Boards to Demonstrate Serial Communications via Infrared Transmission and Reception The lab requires two DEMOEM boards positioned with their infrared communications ports aligned. The MCU’s SCI1 asynchronous serial communications port is connected to an infrared transmitter and receiver positioned near the board edge. The infrared demonstration will allow you to select the data to be transmitted from each DEMOEM board, and likewise monitor the data received from the other board. In addition, the serial port’s drive strength setting will allow you to adjust the range of infrared communications for close or farther-reaching communications. User Interface • SW1 advances to the next state/demo. • SW2 increments the data to be transmitted by one. • SW3 decrements the data to be transmitted by one. • SW4 toggles the Tx port between low and high drive strength. Step by Step Instructions Use SW1 to select the infrared demo state, as shown below: 1. The display indicates the data to transmit (“T”), the data last 2. received (“R”), and the port drive strength setting (“S”). The default setting is to transmit data value 0x35 with normal port drive strength. Use SW2 or SW3 to set the transmit data to different values 3. for each DEMOEM board. Verify the data setting transmitted by one board is the same value received by the other board (Note that data is transmitted once per button press, not continuously). Adjust the distance between the two boards until 4. communication is just lost, then move them slightly together again until communication is restored. Now use SW4 to change the port drive strength setting 5. for each board and repeat step four to note the change in effective communications distance for each drive strength setting. State 6 Use the MCF51EM LCD Driver Programmable Blink Feature to Control Duration of Active/Blank Display The MCF51EM LCD driver has a feature that allows the user to disable all segments at once, resulting in a blank display. This feature is enhanced to further allow the user to automatically alternate between active and blank display to create a blink effect with programmable duration (50% duty cycle between blank and active display). User Interface • SW1 advances to the next state/demo. • SW2 increments blink period (longer duration). • SW3 decrements the blink period (shorter duration). • SW4 has no functionality for this demo. Step by Step Instructions Press SW1 until you see the LCD Blinker state on 1. the display. Press SW2 or SW3 to change the rate of the blinking 2. display. SW2 slows the rate of blinking, while SW3 speeds the rate of blinking. State 7 Use the MCF51EM LCD Driver’s Internal Voltage Regulator Trim Capability as Software Contrast Control The MCF51EM LCD driver has a selectable internal voltage regulator with four-bit trim that serves as a software contrast control for the display, eliminating the need for contrast control circuitry external to the MCU. During this final lab exercise, you will use the simple DEMOEM user interface to change the contrast of the LCD by adjusting the internal voltage regulator’s trim setting. User Interface • SW1 advances to the next state/demo. • SW2 increments voltage regulator output by 1.5%. • SW3 decrements voltage regulator output by 1.5%. • SW4 has no functionality for this demo. Step by Step Instructions Press SW1 until you see the LCD Contrast state on 1. the display. Press SW2 or SW3 to change the output of the internal 2. voltage regulator. SW2 increases the regulator output, increasing the LCD contrast. SW3 decreases the regulator output, decreasing the LCD.

Freescale, the Freescale logo, CodeWarrior and ColdFire are trademarks or registered trademarks of Freescale Semiconductor, Inc. in the U.S.

and other countries. All other product or service names are the property of their respective owners. © 2010 Freescale Semiconductor, Inc. Doc Number: MCF51EM246LB REV 0 Learn More: For more information about Freescale products, please visit www.freescale.com. Get to know the DEMOEM Program Flow Diagram 0 Welcome 1 Metering Demo 2 Tamper Log 3 IRTC TOD 4 IRTC Calendar 5 Infrared Demo 6 LCD Blink 7 LCD Contrast Barrel connector for external power LEDs USB for embedded BDM Optional RS232 serial interface Custom LCD glass Push buttons for demo menu navigation 9S08QE8 signal generator circuit for three-phase emulation Daughter card adapter for 80- or 100-pin MCU package options Power switch IR Comm port