Low Power Seminar - NXP Semiconductors



Introduction

In this Low Power Seminar, we will take a look at the low power features of Freescale’s microcontrollers, whilst developing an increasingly sophisticated digital multimeter (DMM). Starting from a simple ‘familiarization’ with the embedded tools, we gradually add levels of complexity, to end up with a programmable DMM, with data logging, and TFT graphic support, all developed with low-cost tools.

This handout is a self-paced guide to the seminar, and provides instructions on how to complete each lab. You will be given adequate time to complete each section, and if you find that you are falling behind, please ask for help from the class facilitator.

Remember that each delegate will have different levels of skills with low power design, C-programming, Freescale microcontrollers and the embedded tools. Some will be new to these technologies, and others may be more skilled that the class facilitator. Do not be discouraged, and feel comfortable to ask for assistance when it is necessary. The objective of the day is for you to learn some new techniques, and the format of this seminar will help you to learn quickly. You are free to take this handout away with you, and use it as a reference at home and in the office.

The hands-on labs are divided into these parts:

Pre-Lab: Low Power Mode Demo (S08QE128)

Lab 0: LCD DMM with low power (S08LL16)

Lab 1: TFT DMM with low power (S08QE8)

Lab 2: Add keypad and configuration (S08QE32)

Lab 3: Scatter plots and datalogging (S08QE128)

Lab 4: Oscilloscope & graphing (MCF51QE128)

These labs are for you to work on at your own speed. There will be very little use of PowerPoint slides during the labs. It is recommended that you work through the labs in the order presented. Please feel free to take breaks when you want to.

Resources

The following equipment is provided:

PC, running CodeWarrior for MCU Version 6.2

Service packs installed:

CW08_V6_2_HCS08_LL16_SP

CW08_V6_2_HCS08_QB8_SP

CW08_V6_2_PE_V3_04_SP

CW08_MCUs_V6_2_1_patch

Hardware:

DEMOQE Baseboard

MCU daughter cards:

MC9S08QE8 (green)

MC9S08QE32 (green)

MC9S08QE128 (green)

MCF51QE128 (red)

DEMO9S08LL16

TFT Module

Proximity Demo Board

DMM Base Board

USB Cable

Miscellaneous cables

Digital Multimeter

You are not permitted to remove any of these items from the seminar room.

1 PC Orientation

The lab PC has all of the required software pre-installed, including the Integrated Development Environment (CodeWarrior for MCU Version 6.2) and all of the lab material. Throughout the seminar, the various projects can be found in the following directory structure on the C: drive of the PC.

[pic]

A project within CodeWarrior is encapsulated in a project file, known as a Metrowerks CodeWarrior Project, with file extension *.mcp. Here is the project file for the Pre-Lab, Low Power Lab.mcp

You can see it in path

c:\Low Power Seminar\QE128 Low Power

[pic]

There is a shortcut icon on the desktop to launch CodeWarrior for MCU Version 6.2. Please ensure that you always use this shortcut to start CodeWarrior. There are multiple installations of CodeWarrior installed on the PC, and it is important for success in the labs to run the correct version.

[pic]

Starting the PC:

UserName: batwings

Password: CodeWarrior1

Run CodeWarrior for MCU Version 6.2 from the desktop icon, and close any splash screens.

From inside CodeWarrior, use menu Help | About Freescale CodeWarrior to identify the version of CodeWarrior that you are using. At the About Freescale CodeWarrior IDE dialog, click the [Installed Products] button. Write down the version of CodeWarrior that is displayed in the Installed Products window:

CodeWarrior Version: ____________

You are now ready to start the labs.

2. Pre-Lab:

Low Power Mode Demo with S08QE128

1. In this lab, we will program the MC9S08QE128 microcontroller with some example code to demonstrate the low power modes, and make some preliminary current measurements.

2. Locate both the DEMOQE base board and MC9S08QE128 daughter board at your workstation. There are 3 almost identical daughter boards, so ensure that you select the correct one, labelled MC9S08QE128 Flexis 8-bit. Connect the daughter card to the base board, observing the correct orientation by aligning the arrow on the daughter board with the arrow on the baseboard.

[pic]

3. Now check the jumper positions against the table below:

[pic]

4. There is one jumper that we have left undocumented, just to the left of the buzzer. On the rear of the PCB you can see that this jumper is labelled J24 MCU_Vdd. The purpose of the jumper is to allow MCU current measurements. Leave the jumper in place for now.

5. Slide the on/off switch to the OFF position.

6. Start the PC, log on and run CodeWarrior from the desktop shortcut icon, if you have not already done so, and close any splash screens and startup dialogs.

7. Open the project file for the Pre-Lab: in CodeWarrior, use menu item File | Open… to open a browse window, and browse to CodeWarrior project file Low Power Lab.mcp in the path

C:\Low Power Seminar\QE128 Low Power

(it is easiest to find the file if you first set the filter on Objects of Project Files (*.mcp)).

[pic]

8. Select the mcp file, and open it with the Open button.

9. Now connect the demo board to the PC with the provided USB cable. Windows may install a USB driver, but as these PCs are used extensively for training, the drivers are likely to be installed already.

10. Turn ON the demo board with the System_Power switch.

11. Now run a debug session with the CodeWarrior IDE; either press [F5] or click the indicated icon on the Project Explorer window. We are doing this to program the project file into the flash memory of the microcontroller. Note that the IDE runs the compiler before flashing the mcu, and ignore any warnings.

[pic]

12. The debugger runs, and we are taken through a series of dialogs to program the MCU. Please see following pages, and contact the class facilitator if you have any difficulties.

13. Flash programming dialogs:

[pic]

[pic]

14. After the MCU has been programmed, close the debugger window with File | Exit or [Alt-F4], turn OFF the demo board and then remove the USB cable from the board.

15. Configure the board so that current measurements can be taken. Remove the jumper on J24 adjacent to the buzzer, and store it safely by attaching it to the free pin [OFF] on jumper J8, near the bottom left of the base board.

16. Then connect the current probes between the digital multimeter and J24. Set the DMM to measure in the 20mA range.

17. Confirm you have 2-off AAA cells installed on the underside of the DEMOQE board, and turn ON.

18. Observe the MCU RUN current, which should be circa 4.5 mA.

19. Cycle the board through the low power modes:

[pic]

20. Record the currents here:

|Step |Button |Mode |Current (mA) |

|1 |PTA2 |RUN | |

|2 |PTA3 |Low Power RUN | |

|3 |PTD2 |STOP3 | |

|4 |PTD3 |STOP2 | |

21. The class facilitator will describe the operating modes of the mcu in a lecture format.

22. The purpose of this lab was to quickly demonstrate the low current consumption of the Freescale S08QE family of microcontrollers. Also, we learned how to program the mcu with CodeWarrior from a pre-existing project.

23. Finish this lab by turning off the demo board, using the System_Power switch.

24. Spend a couple of minutes looking at the code in the CodeWarrior project. Look for the state machine software in function main of main.c, the function PortSense, and look for the setting of variable mode in the keyboard interrupt service routine in KBI.c.

25. Finally, close the CodeWarrior project (keeping CodeWarrior open) by typing repeatedly [Ctrl-W] until all windows are closed.

26. The class facilitator will make some closing remarks on how the software enters the various low power modes.

3. Lab 0:

LCD DMM with low power (S08LL16)

1. In Lab 0 we will create our first low power voltmeter, using the MC9S08LL16. This mcu has 16kbytes of flash memory, and an on-chip LCD controller with up to 32 pins, suitable for driving segment-on-glass displays in up to 8 x 24 configuration.

2. Locate the DEMO9S08LL16 board, and set about configuring the jumpers as per the following diagram and table.

3. Next, locate the DMM Base Board, and configure the jumper as per the following diagram.

4. Lastly, complete the configuration by connecting the LL16 board J1 to the DMM base board J1.

5.

From inside CodeWarrior for MCU Version 6.2, enter [Ctrl-O] to open a project file, and select seminar.mcp in the folder C:\Low Power Seminar\project\s08\ll16

6. It may take a minute or two for the project to open; it uses a graphical source-code generation tool called Processor Expert, and this needs to be loaded.

7. Program the LL16 mcu with CodeWarrior, following the steps that you took in the Pre Lab, steps 2.9 to 2.14. The LL16 demo board has no ON/OFF switch.

8. It is now necessary to configure the board further. Identify the jumper MCU_EN in the centre of the DEMO9S08LL16 board, and remove it. Store it safely on the USER3 header row, pin 1.

9. Connect the DMM to make current measurements on the board across header MCU_EN. Set the DMM to 20mA range.

10. Finally, connect the output of the potentiometer RV1 on header USER1, pin POT to the DMM base board red banana socket V1_IN. This provides a user-adjustable voltage to be input to the DMM base board.

[pic]

11. Power up the board by attaching the USB cable; power is supplied from the PC.

12. The board starts in Sample Mode, and the display is updated every second with the voltage captured on V1_IN. DMM will read standby current of 3uA, and 52 uA in Sample Mode.

13. Pressing SW1 on the MCU board places the application in Sleep Mode; the sample rate is 1 sample every 10 seconds. Sleep Mode current is 3uA.

14. To exit Sleep Mode, press SW2 to return to Sample Mode.

15. The purpose of this lab was to quickly demonstrate the low current consumption of the Freescale S08LL family of LCD microcontrollers. We observed that a LCD module and MCU with real-time clock can be run on as little as 3 uA. All the necessary voltage levels for the LCD front and backplanes come from the MCU.

16. Finish this lab: turn off the demo board by removing the USB cable.

[pic]

17. Spend a couple of minutes looking at the code in the project. Find the state machine software in function main of programctrl.c, where a switch statement checks for a keypress. Depending upon which switch is pressed, the Time of Day Match register is set in function SetTODM. This generates an interrupt in ‘n’ times 0.25 secs, so a 10 sec interrupt has parameter 40 (0x28). The MCU enters STOP3 mode with function power_set_mode_stop3 (line 230), and remains stopped until woken by the interrupt from the Time of Day module.

18. Finally, close the CodeWarrior project (keeping CodeWarrior open) by typing [Ctrl-W] until all windows are closed.

4. Lab 1:

TFT DMM and low power with MC9S08QE8

1. In Lab 1 we start the digital multimeter DMM design with the low-cost, low power 8kbyte flash mcu MC9S08QE8. We will use the smart TFT panel in this design, to create a sophisticated user interface.

2. The objectives of this session are to design a DMM with the following functionality:

• Take readings on 2 voltage inputs (user selectable input range)

• Graphical User Interface

• User input through push buttons on LCD board

• Display readings on the TFT LCD

• Enter low power ‘sleep’ mode after a user configurable timeout interval

• Measurements taken upon “wakeup” from ‘sleep’ mode

• Measure the QE8 Stop IDD current in the STOP3 mode:

with external reference clock enabled

with external reference clock disabled

• Study the QE8 features implemented in the DMM software design

3. The boards require some preparation before we can start. Remove the DEMO9S08LL16 board from the DMM base board, and set the DEMO board aside; we will not require it again.

4. Locate the DEMOQE base board, MC9S08QE8 daughter board and TFT board at your workstation. Connect the daughter card to the DEMOQE base board, observing the correct orientation by aligning the arrow on the daughter board with the arrow on the baseboard.

5. The jumpers on the DEMOQE base board need to be changed, see following page; also insert the jumper on J24 MCU_Vdd whilst the board is programmed.

6. The jumpers on the DMM base board were set into the correct positions from Lab 0.

7. Connect the DEMOQE base board J1 to the DMM base board J1, pins 1 through 40 should align.

8. Connect a cable between pin 2 of the POT_EN header on the DEMOQE baseboard and the DMM base board red banana socket V1_IN. This provides a user-adjustable voltage to be input to the DMM base board.

[pic]

[pic]

9. Lastly, complete the board preparation by installing the TFT board onto the DMM base board at the position indicated by legend “TO TFT Display”.

10. Turning to the PC, close any open windows in CodeWarrior by typing [Ctrl-W] repeatedly until all windows are closed.

11. From inside CodeWarrior for MCU Version 6.2, enter [Ctrl-O] to open a project file, and select seminar.mcp in the folder:

C:\Low Power Seminar\project\s08\qe8

12. It may take a minute or two for the project to open; it uses a graphical source-code generation tool called Processor Expert, and this needs to be loaded.

13. Program the QE8 mcu with CodeWarrior, following the steps that you took in the Pre Lab, steps 2.9 to 2.14, not forgetting to attach the USB cable, and turning ON the DEMOQE board with the System_Power switch.

14. After the MCU has been programmed, close the debugger window with File | Exit or [Alt-F4], turn OFF the demo board and then remove the USB cable from the board.

15. Configure the board so that current measurements can be taken. Remove the jumper on J24 adjacent to the buzzer, and store it safely by attaching it to the free pin [OFF] on jumper J8, near the bottom left of the base board.

16. Then connect the current probes between the digital multimeter and J24. Set the DMM to measure in the 20mA range.

17. Turn the board ON (it runs from batteries). Observe the MCU RUN current, which should be circa 3 mA.

18. The DMM user interface is as follows:

[pic]

19. Buttons on the TFT board have the following functions:

• D4 - enable/disable voltage inputs

• D5 - select voltage range

• D7 - select current range

• D6 - select display timeout

20. The application will automatically enter a low power sleep mode if there is no user activity (button presses) for a user-defined time period User Timeout. Select the User Timeout by pressing button [D6] several times; note that the timeout wraps around from 10 seconds to 0 seconds.

21. Allow the application to enter the low power stop mode STOP3; simply leave the board untouched for User Timeout seconds.

22. Observe the MCU STOP3 current, which should be circa x uA.

23. Record the stop and run currents:

|Step |Mode |Current (mA) |

|1 |RUN | |

| | |_____________ |

|2 |STOP3 | |

| | |_____________ |

24. Now modify the lab configuration to see the real low power current (HINT: remove a board).

25. With that board removed, there is no way to wake up the application from sleep, which proves tiresome. On the DEMOQE baseboard, connect header PTA2 on J12, which will enable the board to wakeup on switch PTA2.

26. Record the new run and sleep currents.

|Step |Mode |Current (mA) |

|1 |RUN | |

|2 |STOP3 | |

| |Oscillator running | |

27. The purpose of this lab was to quickly demonstrate a low-cost, 8kbyte flash MCU driving a sophisticated TFT display. We looked at the additional current consumption for the TFT display.

28. Finish this lab: turn off the demo board with the switch and then removing the USB cable.

29. In CodeWarrior, identify source file seminar.c in the Project Explorer window, Files view, Base group in the tree-view. Open the file for editing by double-clicking the filename. It opens in an edit window.

30. Locate the function main, and scroll down to observe the function call start_program_ctrl .

[pic]

31. Open a window on this function, by placing the insertion point in the name start_program_ctrl, right-clicking with the mouse to open a pop-up menu, and selecting item Go to function definition of start_program_ctrl:

[pic]

32. Continue by using the same pop-up menu technique to open a window on function set_next_program_mode .

33. Lastly, and with the same technique, open function run_program_mode_qe8_dmm .

34. You will have c-source file programctl.c open, at line 328.

35. Spend a couple of minutes looking at the code in the project. Find the state machine software in function run_program_mode_qe8_dmm of programctl.c,

[pic]

36. The application polls the switches, and turns on a 10ms timer for debouncing. After this time has elapsed, if the key(s) are still pressed, they are handled in a series of if statements, for example:

[pic]

37. Each keypress handler updates several data structures, for control, state machine and TFT display.

38. During the loop, the real-time counter RTC is incrementing each second.

39. At the start of run_program_mode_qe8_dmm the RTC was loaded with a compare value of 10, representing the default sleep_timeout value:

[pic]

40. The sleep_timeout value is also updated in the keypress D6 handler:

[pic]

41. If there is a keypress, the RTC is reset back to zero:

[pic]

42. Steps 4.38 – 4.41 ensure that there is a timer event TI1_OnInterrupt after sleep_timeout seconds of inactivity. You can find this interrupt service routine TI1_OnInterrupt in source file Events.c

[pic]

43. Back in run_program_mode_qe8_dmm after the keypresses have been handled, the state machine tests the sleep_timeout flag in data structure ctrl_flags and enters the STOP3 mode as required.

[pic]

44. On any button press, the mcu wakes from STOP3, continues from where it went to sleep, wakes up the display, performs a measurement, and then the state machine loop repeats.

45. End of Lab 1, so now close the CodeWarrior project (keeping CodeWarrior open) by typing [Ctrl-W] until all windows are closed.

4. Lab 3:

Scatter plots and datalogging S08QE128

1. In Lab 3 we will develop further the digital multimeter DMM design, by adding on a more sophisticated user interface. The additional graphics features require more flash memory, and so we use the low-cost, low power 128kbyte flash mcu MC9S08QE128. We again use the smart TFT panel in this design, and this time, add a keypad based on a proximity sensor to create a sophisticated user interface.

2. The objectives of this session are to design a DMM with the following functionality:

► 5 Modes (screens) for: DMM configuration, Display, Scatter plot, Data logger for Accelerometer and DMM inputs

► Scatter plot

• Shows the accelerometer’s output on a two-axis display

• Can select which two axes of the accelerometer are displayed

► Data logger for Accelerometer and DMM inputs

• Can capture data from both inputs

• Scroll through captured data in a display window

• Send captured data out to a serial port (use PE Micro USB scope utility)

3. The boards again require some preparation before we can start. Remove the DEMOQE base board from the DMM base board, and remove the mcu daughter card MC9S08QE8. Set the MC9S08QE8 board aside; we will not require it again.

4. The jumpers on the DEMOQE base board need to be changed, see following page; also insert the jumper on J24 MCU_Vdd whilst the board is programmed.

5. Locate the MC9S08QE128 daughter board and PROXIMITYDBOARD0 at your workstation. Connect the MC9S08QE128 daughter card to the DEMOQE base board, observing the correct orientation by aligning the arrow on the daughter board with the arrow on the baseboard.

6. The jumpers on the DMM base board were set into the correct positions from Lab 0.

7. Connect the DEMOQE base board J1 to the DMM base board J1, pins 1 through 40 should align.

8. Connect a cable between pin 2 of the POT_EN header on the DEMOQE baseboard and the DMM base board red banana socket V1_IN. This provides a user-adjustable voltage to be input to the DMM base board.

[pic]

[pic]

9. Lastly, complete the board preparation by installing the Proximity Keyboard board onto the DMM base board at the position indicated by legend “Proximity Board”. Exercise for student: as you connect the proximity board, look for the proximity sensor IC. [ Hint: we have a 128kbyte, high performance MCU].

10. Turning to the PC, close any open windows in CodeWarrior by typing [Ctrl-W] repeatedly until all windows are closed.

11. From inside CodeWarrior for MCU Version 6.2, enter [Ctrl-O] to open a project file, and select seminar.mcp in the folder:

C:\Low Power Seminar\project\s08\qe128

12. It may take a minute or two for the project to open; it uses a graphical source-code generation tool called Processor Expert, and this needs to be loaded.

13. Program the QE128 mcu with CodeWarrior, following the steps that you took in the Pre Lab, steps 2.9 to 2.14, not forgetting to attach the USB cable, and turning ON the DEMOQE board with the System_Power switch.

14. After the MCU has been programmed, close the debugger window with File | Exit or [Alt-F4], turn OFF the demo board and then remove the USB cable from the board.

15. Configure the board so that current measurements can be taken. Remove the jumper on J24 adjacent to the buzzer, and store it safely by attaching it to the free pin [OFF] on jumper J8, near the bottom left of the base board.

16. Then connect the current probes between the digital multimeter and J24. Set the DMM to measure in the 20mA range.

17. Turn the DEMOQE board ON. Observe the MCU RUN current, which should be circa 7 mA.

18. The DMM user interface receives keypresses from the proximity board. You can use any of the Touch-, Slider- or Rotary- Pads, although it is most convenient to use the Slider pads (they are arranged E5-E8 left to right, like the display.

E5 [] Scroll forward through menu

E8 [->>] Advance to next screen

19. Key E8 [->>] cycles through the screens in the following order [see next page]

[pic]

[pic]

[pic]

[pic]

[pic]

20. In this session, we will just explore the DMM Logged Values Display screen, and store some values into RAM with the Capture feature.

21. Toggle through the screens with key E8 until you reach the DMM Logged Values Display screen.

22. Move the cursor through the menu with E7 until you reach Capture . Select this menu item with the [Enter] key, E6. Observe the list of recorded values get populated on the right hand side of the screen. The samples are taken quickly and you may not have time to vary the input voltage with the blue potentiometer on the DEMOQE basebord.

23. The values are overwritten each time the Capture feature is used, but the most recently recorded values can be uploaded to your PC, using the Serial Tx feature.

24. The DEMOQE board has a virtual COM port on the USB connector, and this will be used to send data to a PC.

25. In principle, any terminal emulator, such as Hyper Terminal or TeraTerm can be used; in this lab we are using a terminal emulator from our Third Party, P&E Microsystems, called Terminal Window.exe. There is a shortcut to this program on your desktop.

[pic]

26. Run TerminalWindow.exe and use it to connect to the DMM application. Make selections as follows:

[pic]

27. Once the serial port is open, use the Serial Tx feature on the DMM Logged Values Display screen to transmit logged data to TerminalWindow.

28. The lab is complete when you have been able to upload logged data to the PC.

29. The purpose of this lab was to show how increasing the flash and RAM available to the application (128kbytes, 8kbytes) can be used to add more levels of sophistication to the user interface. We added scatter plots and a data-logging feature.

30. Finish this lab: turn off the demo board with the switch and then removing the USB cable.

31. In CodeWarrior, identify source file serialio.c in the Project Explorer window, Files view, Base group in the tree-view. Open the file for editing by double-clicking the filename. It opens in an edit window.

32. Note the use of PE bean-generated code in the custom HAL code. The function,

int8 serialio_write_string(uint8_t* str)

provides an example of this (line 64 calls a function generated by Processor Expert – SERIAL_SendChar.

[pic]

33. Open the Processor Expert tab in the Project Explorer window and open the function list for the SERIAL bean to see which of the available functions were used in serialio.c (see next page).

[pic]

34. Bitmap allocation and display:

35. The bitmap representing the scatter plot background image was generated using a bitmap-to-array converter utility provided by the TFT vendor. The generated constant array Scatter_Plot is contained in the Application/bitmap_screens.c source file.

36. When the red cursor representing the accelerometer deflection needs to be updated, the previous cursor is erased, and the bitmap is redrawn in this location only. See the UI_PaintScatterPlot function in ui.c (line 1456).

37. This is the end of Lab 3, so now close the CodeWarrior project (keeping CodeWarrior open) by typing [Ctrl-W] until all windows are closed.

0. Lab 4:

Oscilloscope & graphing with MCF51QE128

1. In this final lab, Lab 4, we will migrate the software used on the 8-bit mcu MC9S08QE128 to a pin-compatible, peripheral compatible, software compatible 32-bit core. The 32-bit core is the popular ColdFire V1 core, a proprietary Freescale core, developed from the 68k.

2. We will use the tools within CodeWarrior to rapidly migrate the code.

3. The objectives of this session are to design a DMM with the following additional functionality:

► Real-time graph

• Plots the input signal from the DMM inputs or accelerometer axes in real-time

• Utilizes the added processing power of the Coldfire to erase and re-draw all points on the screen as fast as data comes in

• Can capture one screen of data at a time at the push of a button

► Oscilloscope

• Implements an oscilloscope function that can operate on DMM inputs or accelerometer axes

• Triggers on the rising edge of a signal throughout the input voltage range, configurable by the user

• User can set the timebase in terms of sampling rate in milliseconds

4. The boards again require a little preparation before we can start. Remove the MC9S08QE128 (green) board from the DEMOQE base board and set the MC9S08QE128 board aside; we will not require it again.

5. Locate the red MCF51QE128 daughter board at your workstation. Connect the MCF51QE128 daughter card to the DEMOQE base board, observing the correct orientation by aligning the arrow on the daughter board with the arrow on the baseboard.

6. Connect a cable between pin 2 of the POT_EN header on the DEMOQE baseboard and the DMM base board red banana socket V1_IN. This provides a user-adjustable voltage to be input to the DMM base board.

7. That is the board preparation done (all the other boards are configured correctly.

8. From inside CodeWarrior for MCU Version 6.2, enter [Ctrl-O] to open a project file, and select seminar.mcp in the folder:

C:\Low Power Seminar\project\s08\qe128

9. It may take a minute or two for the project to open; it uses a graphical source-code generation tool called Processor Expert, and this needs to be loaded.

10. It is now necessary to convert the 8-bit code to 32-bit Coldfire code. Follow these steps:

11. Changes in Processor Expert

1. Click on Change MCU/Connection

[pic]

2. Select MCF51QE128 from the ColdFire V1 list;

3. Ensure that debugging interface P&E Multilink Cyclone Pro is selected;

4. You can leave Backup project before changes box unchecked;

5. Click [Finish] when you are done.

6. CodeWarrior converts the project from S08 to ColdFire V1; ignore any errors about bean settings.

7. In the Project Explorer (left-hand docked window) click to activate the Processor Expert tab.

8. Right click the CPU bean’s icon and select the CPU Inspector menu option.

[pic]

9. Select the Properties tab

10. Near the top of the properties list, set the Internal Oscillator Frequency to 39.0625 (kHz), and set Initialize Trim Value to yes.

11. Near the bottom of the list, set the Internal Bus Clock to 20 (MHz).

[pic]

12. Right-click the KB1:KBI Bean icon and click the Bean Enabled menu item on the pop-up menu to disable it; it is not needed.

13. Right-click the TPM_Prox:Init_TPM Bean icon and click the Bean Enabled menu item to enable it.

14. Right click the TPM2_HighSpeed:Init_TPM bean’s icon and click the Bean Enabled menu item to enable it. Follow next instruction to remove the red warning exclamation mark.

15. The Bean Inspector window is open for bean TPM2_HighSpeed:Init_TPM. Set interrupt priorities for all of the TPM channels to remove the errors. In the Priority property, use the drop-down list to assign a channel priorit.; pick Level 5.

16. Since the Coldfire core supports interrupt priorities, these need to be set for all interrupts in the TPM bean – 3 places.

17. Double-click on the SM1:SPIMaster [SynchroMaster] bean icon to open the Bean Inspector on the Properties tab.

[pic]

18. Click the ellipsis in the Shift Clock rate property, to set a new shift clock rate.

19. In the dialog, set the new shift clock rate Init. Value to be 10 MHz; this is the last option in the dropdown list.

20. Click [OK] when you have selected 10 MHz, to return to the Bean Inspector.

12. Changes to the CodeWarrior Project

1. Click the Files tab in the Project Explorer.

2. Remove both programctl files (*.c, *.h) in the Application group, by right-clicking on each of them and selecting Remove at the pop-up menu.

3. Right click on the Application source group and click Add Files… from the pop-up menu.

[pic]

4. Browse to the source directory:

c:\Low Power Seminar\src\cf\qe128

5. … and select both the programctl files using the [Ctrl] key; click [Open] to add them to the project.

6. Open up the Standard Settings dialog using short-cut key [Alt-F7] or by clicking on the shortcut icon.

[pic]

7. Switch to the Access Paths view in the treelist and select the old s08\qe128 directory in the User Paths list, and press the [Remove] button, then press [OK].

[pic]

8. Lastly, back in the Project Explorer, Files tab, open the Libs source group and remove the ansibim.lib file by right-clicking and selecting Remove from the pop-up menu.

[pic]

12. Changes to Source Code

1. Open seminar.c in the Base group. This file contains the main function and all initialization code.

[pic]

2. Insert the highlighted line into main(): just uncomment the source code. This function call will initialize the signal acquisition module for use with the fixed frequency sampling code.

[pic]

3. That completes the conversion process.

13. Now build the project with the F7 key, and observe that there are no errors (just a few warnings about my loose code).

14. Program the MCF51QE128 mcu with CodeWarrior, following the steps that you took in the Pre Lab, steps 2.9 to 2.14, not forgetting to attach the USB cable, and turning ON the DEMOQE board with the System_Power switch.

15. This time, we need to tell CodeWarrior to trim the MCU internal clock source to achieve maximum operating speed; at the Connection Manager screen, check the box to use a custom trim frequency, and set the trim frequency to 39062.50 Hz.

[pic]

16. After the MCU has been programmed, close the debugger window with File | Exit or [Alt-F4], turn OFF the demo board, remove USB cable, and then reboot the board by turning on the power.

17. Observe the new Oscilloscope and Accelerometer Graph screens.

[pic]

18. On the accelerometer graph, set the input to V1, and observe the behaviour of the screen as the potentiometer on the DEMOQE baseboard is turned.

19. Take a look at the code highlights, below.

20. Fixed Frequency Sampling (Signal Acquisition Module)

21. All sampling functions have the same signature – one function pointer stores the currently active sampling function

Pointer definition:

uint16 (*sample_fn)(void);

22. Sampling function externally set with enumerated input types using the function

int8 assign_sampling_input(sampling_input_t sample_input)

23. Sampling function called from the ISR for TPM2’s Ch. 1 compare ISR generated by the TPM2_HighSpeed bean

24. ISR contained in Events.c, browse to: ISR(TPM2_CompareISR_1)

25. Main processing in ISR done in sample_data_isr()

26. Cannot modify signal acqusition module’s parameters while a transfer is in progress, so a flag sampling_in_progress implements this functionality

27. Graphing UI Widgets (User Interface Module)

28. Operates on buffered ADC data

29. Can draw an arbitrary number of points on-screen

30. Can operate in free-running mode (single point updates) or buffered mode

31. This can be seen in the graph and oscilloscope functions

32. Axis labels and tigger level indicator are also part of this widget; can be set and re-drawn independent of the graph portion of the widget

33. 32-bit Can be lower power than 8-bit

34. It’s not simply about processor speed or instruction size, but execution efficiency of those instructions

35. Compare:

HCS08 core has one 8-bit accumulator and one 16-bit index register

Coldfire V1 core has eight dedicated 32-bit address and data registers

36. Compare the disassembly of highlighted line of code, below:

[pic]

Now let’s compare the assembler code that the Compiler generates for the S08 and ColdFire cores.

[pic]

[pic]

37. 32-bit can be lower power than 8-bit in the real application! See explanation on opposite column.

38. This is now the end of lab 4 and the end of the hands-on session. Please ask the class facilitator if you have any questions.

39. Please pack away the development boards neatly into the box, placing each board in an antistatic bag.

[pic]

-----------------------

J3

J4

J5

J8

J6

J7

J15

J14

J13

J12

J18

J17

J16

J11

J19

J20

J21

J9

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download