Home

MC9S12P-Family Demonstration Lab Training

image

Contents

1. 5 3 3 Emulated EEPROM Driver 8 S4 LIN Communications o 2 2 lt 250 22304 ocsene ee 14 3 5 MSCAN Module 446 058 eces eeue peeeyaees 14 5 60 PWM Module ic2c ciceacdabet tind sedan bia 16 3 7 S12P Low Power Modes 005 17 3 8 MMC Program Flash Paging Window 19 39 ADC Module esiri a0 a guaderknd dietetik hee 24 310 Mimer MOQUIC 3 icc ccs dia ee ececte a esa a baa a 26 S11 SCiCommunications 2 s24424 184052045 048 28 312 SPiComminications o 6 24 000e0440 20048 pa 29 CONCUSSION s 2 05 25 aksara 28 2h he iani iiae Sek bas 31 Useful Reference Material 32 2 freescale semiconductor Setup 2 Setup 2 1 Tools Setup NOTE Before starting any of the module examples in this document it is important that you complete the Software Setup and Hardware Setup as described in the DEMO9S12PFAME User s Manual which accompanies the demonstration board 2 2 Board Setup The steps listed below provide a basic configuration for each of the module examples in this document Any deviation from this basic configuration or any specific requirements for a module will be outlined in the relevant module chapter 1 Ensure that the RESET and BKGD jumpers are present on the BDM ENA header Ensure that all of the SW ENA jumpers are present Ensure that all of the LED ENA jumpers are present Ensure that all of the CAN ENA jumpers are present Ensure tha
2. 18 Freescale Semiconductor 10 11 12 13 14 15 16 3 7 3 Demonstration Lab Examples Hit RESET The LEDs will flash 20 times indicating Run mode and then the MCU will enter into Wait mode Pressing PPO causes the MCU to exit Wait mode back into Run mode The LEDs will flash 20 times before the MCU returns into Wait mode again Monitor the ECLK signal on the oscilloscope The 32 MHz square wave representing the bus clock will be present in both Run and Wait modes Monitor the EXTAL signal on the oscilloscope In both Run and Wait modes a 4 MHz sine wave should be observed indicating that the external oscillator continues to operate in Wait mode Put the PB1 dip switch into the 0 position Ensure that the PBO PB2 and PB3 dip switches are in the 1 position Hit RESET The LEDs will flash 20 times indicating Run mode and then the MCU will enter into Pseudo Stop mode Pressing PPO causes the MCU to exit Pseudo Stop mode back into Run mode The LEDs will flash 20 times before the MCU returns into Pseudo Stop mode again Monitor the ECLK signal on the oscilloscope The 32 MHz square wave representing the bus clock is only present in Run mode In Pseudo Stop mode the bus clock is stopped to save power Monitor the EXTAL signal on the oscilloscope In both Run and Pseudo Stop modes a 4 MHz sine wave should be observed indicating that the external oscillator continues to operate in Pseudo Stop mode Put the P
3. From the CodeWarrior main menu choose File gt Open and choose the S12P CAN Demo mcp file 7 Click Open The project window will open aS Oe wh MC9S12P Family Demonstration Lab Training Rev 0 14 Freescale Semiconductor Demonstration Lab Examples 8 The C code of this demonstration is contained within the main c file Double click on the file to open it 9 Ensure the Softec HCS12 option is selected as the target 512P_PWM_Demo mep D SofTec HCS12 DYB Full Chip Simulation P amp E Multilink Cyclone Pro Sof Tec HCS12 ET AM datapage c 185 0 x EE Includes 0 0 af AB derivative h 0 0 x RB MC9S12P128 h 0 0 a H Project Settings 52 6 xi amaa aan 10 From the main menu choose Project gt Debug This will compile the source code generate an executable file and download it to the demo board 11 A new debugger environment will open Once the download to the demo board is complete close the debugger environment 3 5 2 Instructions Follow these instructions to run the lab example 1 Ensure that the PBO PB1 PB2 and PB3 dip switches are set to the 0 position 2 Hit RESET The MSCAN demo software will begin the execution 3 Vary the positions of the PBO PB1 PB2 and PB3 dip switches The LEDs should match their configuration 3 5 3 Summary The MSCAN module is a serial data bus communication controller implementing the CAN 2 0A B protocol as defined in the Bosch specification dated Sep
4. Write to FOCOBIX register D identify specific command prameter to kad Write to FOOOB register D bad mquired command pramewr Wrine _PSTAT n r t bunch conmazd Ciar CCIF Oi Bi Polling for Command Completion eck MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 5 Demonstration Lab Examples 3 2 2 Code Example Explanation and Walkthrough The user will note that this program is compiled and run from RAM because sections of flash will be erased in this example The security information byte OxFFOF in the flash configuration field is not erased NOTE If the security information byte is accidentally erased the part will be secured and cannot be re programmed until it is unsecured The file of interest is main c The purpose of this demonstration is to show e Launching a flash command e Demonstrate programming and erasing of flash This example has been written with a series of user software breakpoints so that the only thing that has to be done is to hit the Run button On startup the debugger should begin the program in main 3 2 3 Breakpoint 1 Launch Flash Command Filling P Flash The importance at this breakpoint is the LaunchFlashCommand function This function is responsible for exercising the flash block depending upon the flash command given The flash commands are briefly described in the flash h header file and within the S12P reference ma
5. errr Demonstration Lab Examples The D flash has now been erased and will have to be arranged as active and alternative sectors This software driver requires that at least two alternative sectors are available This is to deal with any brownout or dead sector situations The FSL_InitEeprom function initializes the two sectors at location 0x4400 and 0x4500 to active and the remaining sectors 0x4600 0x4700 and 0x4800 to alternative On completion the active sectors are defined by 0xFACFO0000 and alternative are defined by OxFFFFO000 Z Memory 1 amp O x Memory 2 E 00400 FA CF 00 00 00500 FA CF 00 00 00404 FF FF 4 00408 FF FF FF F E D eS gt lt mons lol 00600 FF FF 00 00 00604 FF FF 00608 FF FF FF E R oee sees 0060C FF FF FF FF 00410 FF FF FF FF 00510 ee 00610 FF FF FF FF 00414 FF FF FF FF 00614 FF FF FF FF 00418 FF FF FF FF 00618 FF FF FF FF 0041C FF FF FF FF 0061C FF FF FF FF 00420 FF FF FF FF 00620 FF FF FF FF 00424 FF FF FF FF 00624 FF FF FF FF E Memory 4 4 00700 FF FF 00 00 00704 FF FF FF FF 00708 FF FF FF FF 0010C FF FF FF FE 0090C FF FF FF FF 00710 FF FF FF FF 810 FF FF FF FF 00714 FF FF FF FF 00814 FF FF FF FF 00718 FF FF FF FF 00818 FF FF FF FF 0071C FF FF FF FF 0081C FF FF FF FF 40720 FF FF FF FF 00820 FF FF FF FF Mi i 00624 FF FF FF FF E Memory 5 00800 FF FF 00 00 00804 FY EF FF FF DD e
6. 00 23 3 FF 0052C 00 34 00 34 4 4 FF 00530 00 34 00 24 4 FF 00534 00 35 00 35 5 5 FF 00538 00 35 00 25 5 FF 0053C 00 36 00 36 6 6 F 00540 00 36 00 26 6 FF 00544 00 37 00 37 7 7 FF 00548 00 37 00 27 7 FF 0054C 00 38 00 38 8 8 FE F F 00550 00 38 00 28 8 EE FE EF FF 00554 00 39 00 39 9 9 FF FF FF FF 00558 00 39 00 29 9 EF fF fF fF 0055C 00 3A 00 3A FF FF FF FF 00560 00 3A 00 2A MC9S12P Family Demonstration Lab Training Rev 0 12 Freescale Semiconductor Demonstration Lab Examples The process described whereby the sectors are being filled copied and erased will continue through an application such as an odometer for example When power to the application is lost the data is stored in the D flash and is easily read 3 3 8 Breakpoint 6 Reading EEE and Erase asm BGND software breakpoint 6 Active sector swapped The code below will read and then re program the This reads the data with Data ID 0x01 The record is read from the cache table if EED CACHETABLE returnCode FSL_ReadEeprom DATA_ID ONE sreadAddr if EED OK returnCode A 8 ErrorTrap A else BH for i Oji lt EED_DATA_VALUE_SIZE i EED MIN PROG SIZE 1A e eeiema ri emama teeter ai aman mera nra ss wma There are read functions after breakpoint 6 which are responsible for reading the EEE This will read the record with a specified data and addres
7. EEE driver user s guide included within the Emulated EEPROM software pack available from www freescale com 3 4 LIN Communications An example of how to manage the SCI module to reconstruct a LIN bus is included on the system software CD from Softec Microsystems labeled DEMO9S12PFAME which is supplied with the DEMO9S12PFAME board The software developed by Softec Microsystems uses the LIN bus to communicate a potentiometer value from master to slave The LIN example software can be found on the CD in DEMO9S12PFAME Docs CW_Examples DEMO9S12PFAME Q LIN 3 5 MSCAN Module This lab example uses the MSCAN module in loopback mode to transmit and receive a byte of data using standard length identifiers and four 16 bit filters The status of Port B is read and transmitted by the MSCAN module When the MSCAN module receives its own transmission the data in the message is read and displayed on the Port A LEDs When the MSCAN module is operated in loopback mode no CAN signals are transmitted externally Both the Tx and Rx pins are held high 3 5 1 Setup The following steps should be followed before running the lab example 1 Ensure that the RS 232 LIN SEL jumper on the DEMO9S12PFAME demonstration board selects the RS 232 position Ensure that the ENA jumper on J503 is present Ensure that the ENA jumper on J505 is present Ensure that the ENA jumper on J506 is present Start CodeWarrior by selecting it in the Windows Start menu
8. FF FF 00540 FF FF FF FF 0061C FF FF FF FE 0072C FF FF FF FE 00444 FF FF FF EF 00544 FF FF FF FF 00620 FF FF FF FF 00730 FF FF FF FF 00448 FF FF FF FF 00548 FF FF FF FF 00624 FF FF FF FF 00734 FF FF FF FF 0044C FF FF FF FF 0054C FF FF FFIF 00628 FF FF FF FF 00738 FF FF EFEF 00450 FF FF FF FF 00550 FF FF FE FF 0062C FF FF FF FF 0072C FF FF FF FF 00454 FF FF FF FF 00554 FF FF FE FF 00630 FF FF FF FF 00740 FF FF FF FF 00458 FF FF FF FF 00558 FF FF FF FF 00634 FF FF FF FF 00744 FF FF FF FF 0045C FF FF FF FF 0055C FF FF FF FF 00638 FF FF FF FF 00748 FF FF FF FF 00460 FF FF FF FF Mooseo FF FF rrrr q looesc FE EE rrrr Mnane FF rr FF FF MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 13 Demonstration Lab Examples 3 3 9 Summary The demonstration software has shown how to initialise the D flash for EEE operation by producing active and alternative sectors via the FSL_InitEeprom function The functions for writing FSL_WriteEeprom and reading FSL_ReadEeprom are required to write read the appropriate data and accompanying ID records and hence emulate EEPROM In an application it will be the two latter functions which will be relied upon Moreover the software is capable of dealing with brownout events as well as dead sectors For developing applications with this code it is advisable to read the
9. Lab Examples 3 10 3 Summary The Timer is a very useful module in that it provides a trigger for events to occur at a specific time or captures when the events have occurred It is very important in the scheduling of repetitive actions and contains a variety of special functions such as pulse accumulation For further information on the Timer module please refer to the following documentation which is available at www freescale com e MC9S12P128 Reference Manual 3 11 SCI Communications This lab example shows how to configure the SCI module to transmit and receive data using different baud rates 3 11 1 Setup The following steps should be taken before running the lab example 1 Ensure that the RS 232 LIN SEL jumper on the DEMO9S12PFAME demonstration board selects the RS 232 position 2 Start CodeWarrior by selecting it in the Windows Start menu 3 From the CodeWarrior main menu choose File gt Open and choose the 12P SCI Tx and Rx mcp file 4 Click Open The project window will open 3 11 2 Instructions Follow these instructions to run the lab example 1 The C code of this demonstration is contained within the main c file Double click on the file to open it 2 Configure the variable Baud_Rate to 9600 and make sure all other options are disabled void main void char RegisterCase unsigned int BaudRatePrescaler x y unsigned long Baud_Rate 9600 r unsigned long Baud_Rate 19200 7 unsigned long Baud
10. is to show how e The D flash is initialized for EEE e The active and alternative sectors are assigned e The active sector is filled and swapped and erased with an alternative sector In an application the D flash would be continually read and written to and sectors would be copied swapped and erased This example has been written with a series of user software breakpoints so that the only thing that has to be done is to hit the Run button gt On startup the debugger should begin the program in main void main void 5 UINT16 returnCode UINT16 readAddr UINT16 erasingCycles UINT16 temp EED_DATA VALUE_SIZE EED MIN PROG SIZE M 0 0 00 UINTS i j 3 3 3 Breakpoint 1 Erase the D Flash ed EEPROM At EED_OK returnCode 8 ErrorTrap A a On selecting the run button the first software breakpoint will be hit Breakpoint 1 stops at the function which is responsible for initializing the D flash This function erases and assigns the physical D flash which shall be used for EEE The user will notice that the selected D flash 0x400 0x500 0x600 0x700 will be in the erased state 3 3 4 Breakpoint 2 Initialise the Active and Alternative Sectors asm BGND if EED_OK returnCode A a ErrorTrap A a Wait until InitEeprom is done while BUSY EE_Status A p StMain MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 9
11. selected as the target 512P_PWM_Demo mcp Full Chip Simulation P amp E Muttilink Cyclone Pro Sof Tec HCS12 0 AB datapage c 0 a Includes 0 0 AB derivative h 0 0 of RB MC9S12P128 h 0 0 a H Project Settings 52 6 a aaa aan From the main menu choose Project gt Debug This will compile the source code generate an executable file and download it to the demo board A new debugger environment will open Once the download to the demo board is complete close the debugger environment MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor Demonstration Lab Examples 3 6 2 Instructions Follow these instructions to run the lab example 1 Hit RESET The code should run on its own The PWM module should output 50 duty cycle signals on Ports PO P4 2 Try probing all four signals simultaneously if possible This allows the difference in settings such as center alignment and polarity to be more apparent 3 6 3 Summary The PWM is a common module on many microcontrollers It often finds use in applications that have a need to vary frequency or intensity such as with lighting For further information on the PWM module please refer to the following documentation which is available at www freescale com e MC9S12P128 Reference Manual 3 7 S12P Low Power Modes In addition to the default Run mode the MC9S12P has three low power modes Wait Pseudo Stop and Stop Wait mode is
12. similar to RUN mode except that CPU execution is halted and it is possible to selectively disable some modules so that only necessary modules are clocked For lower power consumption Pseudo Stop mode halts the bus clock but the external oscillator continues to run Stop Mode disables the external oscillator for the lowest power consumption This lab example shows how to enter each mode and the differences between them The table below summarizes the signals present in each mode Mode Bus Clock External Oscillator Run Y Y Wait Y Y Pseudo Stop N Y Stop N N The changes in the MCU operating mode can be observed via the LEDs and by monitoring the ECLK signal Bus clock and EXTAL signal Crystal on an oscilloscope Care should be taken to probe ECLK and EXTAL separately to avoid adding extra noise to the signals MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 17 Demonstration Lab Examples 3 7 1 Setup The following steps should be taken before running the lab example 1 Start CodeWarrior by selecting it in the Windows Start menu 2 From the CodeWarrior main menu choose File gt Open and choose the S12P Low Power Modes mcp file 3 Click Open The project window will open 4 The C code of this demonstration is contained within the main c file Double click on the file to open it 5 Ensure the Softec HCS12 option is selected as the target 512P_PWi_Demo mc
13. taken before running the lab example 1 Aunt wv x 10 11 12 Ensure that the RS 232 LIN SEL jumper on the DEMO9S12PFAME demonstration board selects the RS 232 position Ensure that the ENA jumper on J503 is present Ensure that the ENA jumper on J505 is present Ensure that the ENA jumper on J506 is present Start CodeWarrior by selecting it in the Windows Start menu From the CodeWarrior main menu choose File gt Open and choose the S12P ADC Demo mcp file Click Open The project window will open The C code of this demonstration is contained within the main c file Double click on the file to open it Ensure the Softec HCS12 option is selected as the target 512P_PWM_Demo mcp Full Chip Simulation P amp E Multilink Cyclone Pro SofTec HCS12 TBDML AB datapage c 185 0e of EE Includes 0 0 af AR derivative h 0 0 AB MC9S12P128 h 0 0 a H Project Settings 52 E e xf j From the main menu choose Project gt Debug This will compile the source code generate an executable file and download it to the demo board A new debugger environment will open Once the download to the demo board is complete close the debugger environment The ADC conversion result is sent to the RS 232 port baud rate 9600 data bits 8 parity N stop bits 1 Flow control Hardware Open a terminal window on the PC with this configuration MC9S12P Family Demonstration Lab
14. the setting of the Program Page Index Register PPAGE True Time Simulator amp Real Time Debugger _D Profiles r28318 My Documents MetroWerks Projects S12P S12P MMC Demo Softec HCSi2ni Ele View Run inDART HCS12 Component Source Window Help able e 2X gt a x 2 4 2 D Profiles 28318 My Documents Metrowerks Projects S12P S12P MMC Demo Sources main c void main void B fi Assembly 4002 SB1S while 1 4004 00 4005 52 09 asm BGND 400A 5815 PPAGE Ox0A 400c 00 asm BGND 400D 52 PPAGE 0x0B asm BGND D Fare o mx coso ivf o IP 4000 pc 4000 pace Oo eo seen ceo evatusur oeooo 70 00 oo oo 00 00 O00 00 oe008 9F 00 00 00 DO 00 00 00 08010 00 00 00 00 00 00 00 00 08018 00 00 39 60 40 00 40 00 Window lt 56 gt const array 56 of const signed char 08020 00 00 00 00 00 00 09 00 Windows lt 56 gt const array 56 of const signed char 08028 00 00 00 GO 00 00 00 00 WindowA lt 56 gt const array 56 of const signed char 08030 00 00 00 00 SF OF 03 7C Windows lt 56 gt const array 56 of const signed char 08038 00 80 00 00 00 00 00 00 LED_Flag 0 unsigned char 08040 00 00 00 00 00 00 00 00 _PPAGE lt 1 gt volatile PPAGESIR main 0x4000 T STARTED RUNNING Breakpoint in gt For Help press F1 Automatic breakpoints watchpoints and trace possible Mc9512P 128 Breakpoint H 3 Start the software by clicking on the Run button 4 When t
15. 0 00 pane A 08064 00 00 00 00 J 62 annara nan an an an Figure 2 The Memory Maps Showing Real Time Erasing and Programming The user will note that 0x8000 the P flash window will show different content depending on the PPAGE When the programming has occurred check PPAGE C F by entering the character in the PPAGE register Register By Altering the PPAGE the user can see the 64 kb windows of programmed information at 0x8000 3 2 5 Breakpoint 3 Launched Program Commands Address Data As breakpoint 2 except the data being written to the P flash is different the data written are the actual addresses of the P flash MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 7 Demonstration Lab Examples 3 2 6 Breakpoint 4 D flash Launched Program Commands The same functions are used but will now perform activity on the D flash The only difference to the flash command function is the memory address issued and flash commands in other words D flash instead of P flash The end of the demonstration is indicated by the LEDs on the EVB being toggled This example does not re program the device to default this will happen on the next re load of a program by allowing NVM erasing 3 2 7 Summary The demonstration software has shown how to initialise the flash command to perform programming erasing and erase verify on both the P flash and D flash It is vital that the flow diagram i
16. 50 AGE OB P SO 41 47 45 20 30 42 20 PAGE OB PPAGE 0B Windows lt 56 gt const array 56 of const signed char E Window lt 56 gt const array 56 of const signed char WindowA lt 56 gt const array 56 of const signed char 80 50 50 41 47 45 20 30 42 B FF FF FF FF FF FF FF FF 8040 FF FF FF FF FF FF FF FF ab eee SE Pe ee EE ee ee E WindowS lt 56 gt const array 56 of const signed char LED_Flag 0 unsigned char E _PFAGE lt 1 gt volatile PPAGESTR For Help press F1 Automatic breakpoints watchpoints and trace possible Mc9512P128 ILLEGAL_BP H 11 Hit the Run button and the software will loop back to return the PPAGE register to 08 The contents of PPAGE 08 can be seen in the Memory window 3 8 3 Summary The MMC module can be used to expand the accessible amount of memory of the MC9S12P128 MCU by paging the expanded global memory into a window in the local memory For further information on the MMC module please refer to the following documentation which is available at www freescale com e MC9S12P128 Reference Manual 3 9 ADC Module This lab example shows how to use the ADC module to perform single conversions continuous conversions and automatic compare The ADC conversion results are output on a terminal window via the RS 232 port MC9S12P Family Demonstration Lab Training Rev 0 24 Freescale Semiconductor 3 9 1 Demonstration Lab Examples Setup The following steps should be
17. 9S12P Family Demonstration Lab Training Rev 0 6 Freescale Semiconductor e Demonstration Lab Examples 3 2 4 Breakpoint 2 Launched Program Commands Known Data On entry of the second breakpoint the memory maps have been set up to show the P flash being erased OxFFFF state then programmed with known parameters OxAAAA All P flash pages have been filled with OxAAAA 0x1400 0x4000 0xC000 and the PPAGE OC OF 0x8000 OxBFFF local entry Note PPAGE 08 0B have not been used D flash P flash P flash P flash P flash E E Sill E Swen a Shem E Omenenl Jo gt 04000 FF FF AA 04004 FF FF AA 04008 FF FF AA 0400C FF FF AA 04010 FF FF AA 0c010 jodi 04014 FF FF AA 0C014 FF FF AA AR 0041 04018 FF FF AA 0C018 FF FF AA AR 0141C F 01420 FF FF FF 01424 0401C FF FF AA ocoic F 04020 FF FF AA 04024 FF FF AA 04028 FF FF AA 0402C FF FF AA 04030 FF FF AA 04034 FF FF AA 04038 FF FF AA 08034 y0043c 00 oo o 0403C FF FF AA ozac foo440 00 oo o 04040 FF FF AA 02040 o 00 00 100444 00 oo oo oo 04044 FF FF AR 08044 00 00 00 00 Jo0448 00 oo 00 oo 04048 FF FF AA 08048 00 00 00 00 0404C FF FF AA aeo4c 00 00 00 00 M o ee tee ter Ih ter fies tet tee fer te ter fee tet te ee tier tee te ter tor 04050 FF FF AA 08050 00 00 00 00 04054 FF FF AR 02054 00 00 00 00 04058 FF FF AA 08058 00 00 00 00 0405C FF FF AA 0805C 00 00 00 00 04060 FF FF Al 08060 00 00 0
18. AGE OA WindowA lt 56 gt const array 56 of const signed char 08030 50 50 41 47 45 20 30 41 PPAGE OA E WindowB lt 56 gt const array 56 of const signed char 08038 FF FF FF FF FF FF FF FF LED_Flag 0 unsigned char _PPAGE lt 1 gt volatile PPAGESIR For Help press F1 Automatic breakpoints watchpoints and trace possible uc9si2P 128 EGAL BP f 9 Hit the Run button and observe the Memory and Register windows at the next breakpoint 10 Now the PPAGE register is set to OB and the P Flash Window shown in the Memory window displays the contents of PPAGE OB MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 23 Demonstration Lab Examples True Time Simulator amp Real Time Debugger _D Profiles r28318 My Documents MetroWerks Projects S12P S12P MMC Demo Soffec_HCS12ini View Run inDART HCS12 Component Source Window Help sia tjej 2X gt a alele 4 2 B Piofles 2831E 8 My Documents MetroWerks Projects S12P S12P MMC Demo Sources main c void main void 8 4005 52 INCB 4006 5B15 STAB 0 while i 4008 00 BEND 8 4009 52 INCB PPAGE 0x08 400A 5815 STAB ND 400c 00 BEND 400D 52 INCB 400E 5815 STAB PPAGE Ox0B asm BGND mp 4011 eo ern rro evernzur E Memory 08000 30 42 20 50 50 41 47 45 OB PPAGE 8008 20 30 42 20 50 50 41 47 OB PPAG 8010 45 20 30 42 20 50 50 41 E OB PPA 47 45 20 30 42 20 50 50 GE OB PP 41 47 45 20 30 42 20
19. BO and PB1 dip switches into the 0 position Ensure that the PB2 and PB3 dip switches are in the 1 position Hit RESET The LEDs will flash 20 times indicating Run mode and then the MCU will enter into Stop mode Pressing PPO causes the MCU to exit Stop mode back into Run mode The LEDs will flash 20 times before the MCU returns into Stop mode again Monitor the ECLK signal on the oscilloscope The 32 MHz square wave representing the bus clock is only present in Run mode In Stop mode the bus clock is stopped to save power Monitor the EXTAL signal on the oscilloscope The 4 MHz sine wave is only present in Run mode In Stop mode the external oscillator is stopped to save power Summary The MC9S12P Family can be configured in a variety of ways to achieve low power consumption The three low power modes offer different solutions for user applications For further information on low power modes please refer to the following documentation which is available at www freescale com 3 8 AN2461 Low Power Management using HCS12 and SBC devices MC9S12P128 Reference Manual MMC Program Flash Paging Window The MC9S12P128 has a global memory of 128 KB This amount of memory cannot be addressed by the 16 Bit MC9S12P128 MCU Instead a paging system which maps 16 KB blocks of memory into the local memory map from address 0x8000 to OxBFFF is used This lab example shows how to use the paging capability of the MMC module to access global memory ad
20. F FF fo0444 00 18 00 18 00544 00 37 00 37 7 7 00620 FF FF FF FF poosse 00 18 00 08 00548 00 37 00 27 7 00624 FF FF FF FF poo44c 00 19 00 19 0054C 00 38 00 38 8 8 00628 FF FF FF FF foo4s0 0019 00 09 tw 00550 00 38 00 28 8 0062C FF FF FF FF fo0454 00 1A 00 1A 00554 00 39 00 39 9 9 00630 FF FF FF FF 00452 00 1A 00 OA 00558 00 39 00 29 9 00634 FF FF FF FF 0045C 00 1B 00 1B 0055C 00 3A 00 3A wt 00638 FF FF FF FF Jooseo 00 1B 00 0B SR00560 00 3A 00 2A QOOG3C FF FF FF FF 3 3 7 Breakpoint 5 Sector Swap Now that the active sectors have been completely filled the next record write will only occur after a new active sector has been created This is a two stage process firstly all the records from the first active sector are copied to the first available alternative sector in this case data and ID records from 0x400 0x499 are copied to 0x600 Secondly the sector at 0x400 is erased and becomes a new alternative sector On the new alternative sector notice it begins with OxFFFFO001 Old active sector now Records copied e Er 00500 FA CF 00 00 FF 00504 00 2F 00 2F Er 00508 00 2F 00 1F FF oosoc 00 30 00 30 0 0 FF 00510 00 30 00 20 0 F 00514 00 31 00 31 1 1 FF 00518 00 31 00 21 1 FF 0051C 00 32 00 32 2 2 FE 00520 00 32 00 22 2 FF 00524 00 33 00 33 3 3 FF 00528 00 33
21. Freescale Semiconductor Application Note Document Number AN3937 Rev 0 09 2009 MC9S12P Family Demonstration Lab Training by Gordon Borland Matt Grant Lela Garofolo Steven McLaughlin MSG Auto R amp D 1 Introduction This publication serves to document the demonstration lab software examples The examples show how to configure and use the modules to users getting started with the MC9S12P Family of MCUs The examples included here illustrate a basic configuration of the modules to allow users to quickly start developing their own applications Complete code is available for all examples This can be downloaded onto an MC9S12P128 target such as the DEMO9S12PFAME demo board upon which this demonstration lab is based Each module of the MC9S12P Family has its own stand alone software and is discussed within its own section of this document A zip file AN3937SW zip containing the complete CodeWarrior projects for the lab examples accompanies this application note The file can be downloaded from www freescale com Freescale Semiconductor Inc 2009 All rights reserved Contents MIPFOQUCUOM seier dee eek hae aida da A on 1 SHUP Goliad EE e ss ehaeratuddeteed deta 2 eA HOGS SOUP Kdceeieias denenranude EAEN 2 22 Board Sep ciecics rae teneeras opeag eer acd 2 Demonstration Lab Examples 0 2 Bot MOP MUNG IGEKS 658 25 c ieee amt Ok eed Boke aoe 2 3 2 Flash Programming Example
22. GE IS INTENTIONALLY BLANK MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 33 How to Reach Us Home Page www freescale com Web Support http www freescale com support USA Europe or Locations Not Listed Freescale Semiconductor Inc Technical Information Center EL516 2100 East Elliot Road Tempe Arizona 85284 1 800 521 6274 or 1 480 768 2130 www freescale com support Europe Middle East and Africa Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen Germany 44 1296 380 456 English 46 8 52200080 English 49 89 92103 559 German 33 1 69 35 48 48 French www freescale com support Japan Freescale Semiconductor Japan Ltd Headquarters ARCO Tower 15F 1 8 1 Shimo Meguro Meguro ku Tokyo 153 0064 Japan 0120 191014 or 81 3 5437 9125 support japan freescale com Asia Pacific Freescale Semiconductor China Ltd Exchange Building 23F No 118 Jianguo Road Chaoyang District Beijing 100022 China 86 10 5879 8000 support asia freescale com For Literature Requests Only Freescale Semiconductor Literature Distribution Center 1 800 441 2447 or 303 675 2140 Fax 303 675 2150 LDCForFreescaleSemiconductor hibbertgroup com Document Number AN3937 Rev 0 09 2009 Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products There are no ex
23. Training Rev 0 Freescale Semiconductor 25 Demonstration Lab Examples 3 9 2 Instructions Follow these instructions to run the lab example 1 Ensure that the PBO PB1 PB2 and PB3 dip switches are in the 1 position 2 Hit RESET The ADC will perform a single 12 bit conversion on PADOO To perform another conversion press PPO 3 Vary the conversion result by turning potentiometer P501 on PADOO and observe the changes in the terminal window 4 Put the PBO dip switch into the 0 position Ensure that the PB1 PB2 and PB3 dip switches are in the 1 position 5 Hit RESET The ADC will perform continuous 8 bit conversions on PADO1 6 Vary the conversion result by shading the light sensor R507 on PADO1 and observe the changes in the terminal window 7 Put the PB1 dip switch into the 0 position Ensure that the PBO PB2 and PB3 dip switches are in the 1 position 8 Hit RESET The ADC will perform continuous 12 bit conversions on PADOO and compare the result to see if it is higher than 0x07FF Whilst the comparison is true the LEDs on the demo board will flash 9 Vary the conversion result by turning potentiometer P501 on PADOO and observe the result in the terminal window Notice how the LEDs only flash when the result is greater than OxO7FF 3 9 3 Summary The ADC module is highly autonomous with an array of flexible conversion sequences and resolution It can be configured to select which analog source to start the conversio
24. _Rate 38400 ef unsigned long Baud_Rate 57600 MC9S12P Family Demonstration Lab Training Rev 0 28 Freescale Semiconductor Demonstration Lab Examples 3 Ensure the Softec HCS12 option is selected as the target 512P_PWM_Demo mcp Full Chip Simulation P amp E Multilink Cyclone Pro SofTec HCS12 TBDML 0e xi AB datapage c 185 0e of a Includes 0 0 sf AB detivative h 0 Oo 6 AB MC9S12P128 h 0 0 a H Project Settings 52 6 x 4 From the main menu choose Project gt Debug This will compile the source code generate an executable file and download it to the demo board 5 A new debugger environment will open 6 The software uses the RS 232 port to interact with the user Open a terminal window baud rate 9600 data bits 8 parity N stop bits 1 Flow control Hardware to see the RS 232 port data 7 Hit F5 The code will begin execution configuring the SCI to the selected baud rate It s status can be confirmed on the terminal window 8 The SCI register configurations can be confirmed by selecting an option displayed on the terminal window Choose some options and observe the SCI register configurations 9 Repeat steps 2 to 9 for baud rates of 19200 38400 and 57600 Alternatively modify the definition of variable Baud_Rate for a user configured baud rate 3 11 3 Summary The SCI module can be used to communicate with peripheral devices or other MCUs For further informa
25. dresses within the local memory map MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 19 Demonstration Lab Examples 3 8 1 Setup The following steps should be taken before running the lab example 1 Start CodeWarrior by selecting it in the Windows Start menu 2 From the CodeWarrior main menu choose File gt Open and choose the S12P MMC Demo mcp file 3 Click Open The project window will open The C code of this demonstration is contained within the main c file Double click on the file to open it 5 Ensure the Softec HCS12 option is selected as the target 12P_PWM_Demo mcp Full Chip Simulation P amp E Multilink Cyclone Pro SofTec HCS12 TBDML ff datapage c Ea Includes 0 0 af of derivative h 0 Oo g f MC9512P128 h 0 0 a H Project Settings 52 6 xi i 6 From the main menu choose Project gt Debug This will compile the source code generate an executable file and download it to the demo board 7 A new debugger environment will open Do not close the debugger environment MC9S12P Family Demonstration Lab Training Rev 0 20 Freescale Semiconductor Demonstration Lab Examples 3 8 2 Instructions Follow these instructions to run the lab example 1 The Memory window in the debugger environment is configured to show the first few locations of the P Flash Window at address 0x8000 2 The Register window in the debugger environment shows
26. et and will produce a bus clock of 8 MHz For further information on the CPMU module please refer to the following documentation which is available at www freescale com e AN3622 Comparison of the 12XS CRG Module with the 12P CPMU Module e MC9S12P128 Reference Manual MC9S12P Family Demonstration Lab Training Rev 0 4 Freescale Semiconductor Demonstration Lab Examples 3 2 Flash Programming Example 3 2 1 Flash Overview The flash technology module FTM a 1 5T split gate transistor flash technology contains program flash P flash and data flash D flash P Flash is intended primarily for non volatile code storage D Flash is used as basic flash memory for non volatile data storage or non volatile storage to support emulated EEPROM or a combination of both The user interfaces with this module via the following steps 1 Set the flash clock divider FCLKDIV 2 Check the status of the Flash status register FSTAT 3 Make sure the command complete interrupt flag is set CCIF 1 4 Launch the appropriate flash commands program erase verify and so on via FCCOBIX and FCCOB registers 5 Check flash status register and that CCIF 1 A flow chart of these steps is shown below Read FCLKDIV register Clock Regiser Wren Geck Note FCLKDIV must be set after each reset FOCOB Awailadi lity Check Access Eror and Write PSTAT regimer Fotection Violation Gear ACCERR FPVIOL 0x30
27. gt lt DD i 00520 FF FF FF FF 00524 FF FF FF FF Active Sectors Alternative Sectors 3 3 5 Breakpoint 3 Write First Data and ID Record a f asm BGND software breakpoint 3 the function below will write the first data record and ID ye turncode FSL WriteEeprom if EED_OK returnCode anes ErrorTrap a Wait until WriteEeprom is done while BUSY EE Status A _ BH Arse Maint The data to be written is defined within a header file 0x10 When executed this function will write the data 0x10 and will assign this with a record ID of 0x01 The ID size is two bytes and the data size has been configured to six bytes The specific EEE users guide explains how to set the data size MC9S12P Family Demonstration Lab Training Rev 0 10 Freescale Semiconductor Demonstration Lab Examples Data Record ID Record 3 3 6 Breakpoint 4 Completely Write the Active Sectors asm BGND software breakpoint 4 the first record has been written and the function below will write tl It will loop here until all the active sectors are filled Sor Oy lt EED_MAX_RECORD_NUMBER i for j Ojj lt EED_DATA_VALUE_SIZE EED_MIN PROG _SIZE j 1A temp j i DATA VALUE returnCode FSL_WriteEeprom i temp if EED OK returnCode w This writes data records such that the active block is completely filled The next write after t
28. he loop will cause a swap The active sectors at 0x400 and 0x500 have been filled since the code executes a for loop until it reaches the end of the second active sector MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 11 Demonstration Lab Examples Active sector Beginning of first completely filled red alternative sector FA CF 00 00 Boosoo Fa cF oo 00 lMoospc oo 4a 00 4a 00 10 00 10 00504 00 2F 00 2F QOSEO 00 4A 00 3A e 00 10 00 01 lS moosoes 00 2F OO 1F B 005E4 00 4B 00 4B 00 11 00 11 0050C 00 30 00 30 0 0 OOSES 00 4B 00 3B 000110001 00510 00 30 00 20 0 QOSEC 00 4C 00 4C 00 12 00 12 00514 00 31 00 31 1 1 OOSFO 00 4C 00 3C 8 00 12 00 02 00518 00 31 00 21 1 OOSF4 00 4D 00 4D yoo 00 13 00 13 0051C 00 32 00 32 2 2 OoSF 00 4D 00 3D foos2 oo 13 0003 00520 00 32 00 22 2 OOSFC FF FF FF FF jjoo424 00 14 00 14 00524 00 33 00 33 3 3 00600 FF FF 00 00 fo0428 00 14 00 04 00528 00 33 00 23 3 00604 FF FF FF FF fo042c 00 15 00 15 0052C 00 34 00 34 4 4 00608 FF FF FF FF foo430 00 15 00 05 00530 00 34 00 24 4 0060C FF FF FF FF fo0434 00 16 00 16 00534 00 35 00 35 5 5 00610 FF FF FF FF foo438 00 16 oo 06 Cw 00538 00 35 00 25 5 00614 FF FF FF FF yoo43c 00 17 00 17 0053C 00 36 00 36 6 6 00618 FF FF FF FF 00440 00 17 00 07 00540 00 36 00 26 66 8 0061C FF FF F
29. he software hits the first breakpoint examine the contents of the Memory and Register windows The PPAGE register is set to 08 and the P Flash Window shown in the Memory window displays the contents of PPAGE 08 MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 21 Demonstration Lab Examples True Time Simulator amp Real Time Debugger _D Profiles r28318 My Documents MetroWerks Projects S12P S12P MMC Demo Soffec_HCSi2ani void main void 8 while 1 a PPAGE 0x08 asm BGND asm BGND PPAGE Ox0A asm BGND tabs 0x4000 PPAGE 0x0B asm BGND Hi Window8 lt 56 gt const array 56 of const signed char Hi Window9 lt 56 gt const array 56 of const signed char WindowA lt 56 gt const array 56 of const signed char E WindowB lt 56 gt const array 56 of const signed char LED Flag 0 unsigned char FF FF FF FF lt 1 gt volatile PPAGESTR FF EF FF FF 5 Hit the Run button and observe the Memory and Register windows at the next breakpoint 6 Now the PPAGE register is set to 09 and the P Flash Window shown in the Memory window displays the contents of PPAGE 09 Source void main void while 1 a PPAGE 0x08 asm BGND PPAGE 0x09 asm_BGND asm BGND zabs 024000 PPAGE 0x0B asm BGND const array 56 of const signed char const array 56 of const signed char const ar
30. imulation P amp E Multilink Cyclone Pro SofTec HCS12 TBDML AB datapage c 4 Includes 0 0 af AB detivative h 0 0 AB MC9S12P128 h 0 0 a H Project Settings 52 6E xi From the main menu choose Project gt Debug This will compile the source code generate an executable file and download it to the demo board A new debugger environment will open Once the download to the demo board is complete close the debugger environment Ensure that the RS 232 LIN SEL jumper on the DEMO9S12PFAME demonstration board selects the RS 232 position The PLL configuration is sent to the RS 232 port baud rate 9600 data bits 8 parity N stop bits 1 Flow control Hardware Open a terminal window on the PC with this configuration The bus clock speed is represented on pin 27 PE4 ECLK The ECLK signal is equivalent to the MCU bus speed and can be monitored by attaching an oscilloscope probe to pin 31 of the J102 header MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor Demonstration Lab Examples 3 1 2 Instructions Follow these instructions to run the lab example 1 Ensure that the PBO PB1 PB2 and PB3 dip switches are in the 1 position 2 Hit RESET The MCU is now running in it s default PEI mode with a bus clock frequency of 8 MHz 3 Monitor the ECLK signal on the oscilloscope ECLK will match the bus clock frequency Observe the LED pulse rate Examine the PLL configuration on the terminal
31. in 0 xi AB datapage c 185 0 xf a Includes 0 0 sf AB detivative h 0 Oo 86 AB MC9S12P128 h 0 0 a H Project Settings 52 6E xi annan i 7 From the main menu choose Project gt Debug This will compile the source code generate an executable file and download it to the demo board 8 A new debugger environment will open Once the download to the demo board is complete close the debugger environment 9 Attach scope probes to PM3 PM4 and PMS 10 Configure the oscilloscope to trigger on the falling edge of PM3 3 12 2 Instructions Follow these instructions to run the lab example 1 Hit RESET The code will begin execution configuring the SPI to transmit an incrementing byte of data at a baud rate of 15 625 kbits s 2 Monitor the SPI transmission on the oscilloscope to see the relationship between Slave Select PM3 data transmitted on MOSI PMS and the Serial Clock PM4 signals MC9S12P Family Demonstration Lab Training Rev 0 30 Freescale Semiconductor Conclusion M Pos 300 0 us M 100s 3 12 3 Summary The SPI module can be used to allow duplex synchronous serial communication between peripheral devices and the MCU For further information on the SPI module please refer to the following documentation which is available at www freescale com e MC9S12P128 Reference Manual 4 Conclusion The 12P family of microcontrollers MCUs offers the enhanced features of 16 Bit performance at the
32. le Semiconductor products for any such unintended or unauthorized application Buyer shall indemnify and hold Freescale Semiconductor and its officers employees subsidiaries affiliates and distributors harmless against all claims costs damages and expenses and reasonable attorney fees arising out of directly or indirectly any claim of personal injury or death associated with such unintended or unauthorized use even if such claim alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part RoHS compliant and or Pb free versions of Freescale products have the functionality and electrical characteristics as their non RoHS compliant and or non Pb free counterparts For further information see http www freescale com or contact your Freescale sales representative For information on Freescale s Environmental Products program go to http www freescale com epp Freescale and the Freescale logo are trademarks of Freescale Semiconductor Inc All other product or service names are the property of their respective owners Freescale Semiconductor Inc 2009 All rights reserved lt p 2 freescale semiconductor
33. n on how many conversions to perform and whether these should be on the same or multiple input channels An automatic compare can be used to liken the conversion result against a programmable value for higher than or less than equal to matching Any conversion sequence can be repeated continuously without additional MCU overhead For further information on the ADC module please refer to the following documentation which is available at www freescale com e AN2428 An Overview of the HCS12 ATD Module e MC9S12P128 Reference Manual 3 10 Timer Module This lab example shows how to use the Timer module to perform output compare and input capture In case an oscilloscope is unavailable the LEDs associated with Port A on the DEMO9S12PFAME board toggle to indicate an output compare match or a successful input capture MC9S12P Family Demonstration Lab Training Rev 0 26 Freescale Semiconductor Demonstration Lab Examples 3 10 1 Setup The following steps should be taken before running the lab example 1 Ensure that the ENA jumper on the J508 is present for LEDs AO Al and A3 2 Connect Port T1 from J101 pin 15 with Port T3 from J102 pin 8 This will allow the output compare function on T1 to provide stimulus to the input capture function on PT3 The connections may be easier to make if header rows are populated on J101 and J102 3 Start CodeWarrior by selecting it in the Windows Start menu 4 From the CodeWarrior main menu ch
34. nual chapter 13 4 Stepping through will take the user to the function below LXE IH III IIS SII IIIS SI III ISIIS ISIS IIIISESSI SII SI ISIS SSS IIISISIS SII IIIS SI SSSI I ISIS IS SSIS Function Name LaunchFlashCommand Engineer Date Arguments Return Notes This function does not check if the Flash is erased This function does not explicitly verify that the data has been sucessfully programmed This function must be located in RAM or a flash block not being programmed HHH HHH KKH HHI KKH AHI IEE IAI IIIA ASIII IIIA IIA IIS III IIIS IAI AI AIH tU08 LaunchFlashCommand char params tU08 command tU08 ccob0 tU16 ccobl tU16 ccob2 tU16 ccob3 tU16 ccob4 tU16 ccobS if FSTAT_CCIF 1 7 Clear any error flags FSTAT FPVIOL_MASK ACCERR_MASK e the command id ccob0 0 command ccobt l params bi Write next data word to CCOB buffer X l params b2 7 Write next data word to CCOB buffer l params 3 Write next data word to CCOB buffer IX l params b4 Write next data word to CCOB buffer X l params b5 Write next data word to CCOB buffer FCCOBIX params 1 7 Clear command buffer empty flag by writing a 1 to it FSTAT CCIF_MASK while FSTAT_CCIF 7 wait for the command to complete Return status return FSTAT command completed return FLASH_BUSY state machine busy Figure 1 Launch Flash Command Function MC
35. oose File gt Open and choose the S12P Timer Demo mcp file 5 Click Open The project window will open 6 The C code of this demonstration is contained within the main c file Double click on the file to open it 7 Ensure the Softec HCS12 option is selected as the target 512P_Timer_Demo mcp ID SofTec Hcs12 Jany Sy Full Chip Simulation P amp E Multilink Cyclone Pro SofTec HCS12 7 denvative 0 E MC9S12P128 h 0 0 x EE Project Settings 52 6 x 8 From the main menu choose Project gt Debug This will compile the source code generate an executable file and download it to the demo board 9 A new debugger environment will open Once the download to the demo board is complete close the debugger environment 3 10 2 Instructions Follow these instructions to run the lab example 1 Hit RESET The code should run and the Timer will perform output compares on channel 0 Port TO and channel 1 Port T1 and input capture on channel 3 Port T3 When a compare match occurs Ports TO and T1 will toggle 2 Use an oscilloscope to view the toggling of Timer channel pins In case an oscilloscope is not available the LEDs associated with Port AO and Port Al toggle in sync with Port TO and Port T1 respectively 3 To ensure the input capture is detecting edge transitions observe Port A3 LED toggles in sync with Port Al MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 27 Demonstration
36. p Full Chip Simulation P amp E Multilink Cyclone Pro SofTec HCS12 TBDML AB datapage c 4 Includes 0 0 af AB detivative h 0 0 AB MC9S12P128 h 0 0 a H Project Settings 52 6 xi 6 From the main menu choose Project gt Debug This will compile the source code generate an executable file and download it to the demo board 7 A new debugger environment will open Once the download to the demo board is complete close the debugger environment 8 The bus clock is represented on pin 27 PE4 ECLK The ECLK signal is equivalent to the MCU bus speed and can be monitored by attaching an oscilloscope probe to pin 31 of the J102 header 9 The oscillator can be monitored by attaching a scope probe to the EXTAL side of the Y101 crystal 3 7 2 Instructions Follow these instructions to run the lab example 1 Ensure that the PBO PB1 PB2 and PB3 dip switches are in the 1 position 2 Hit RESET The MCU is now operating in Run mode The LEDs will flash indefinitely indicating the MCU is in Run mode 3 Monitor the ECLK signal on the oscilloscope ECLK represents the bus clock A 32 MHz square wave should be observed 4 Monitor the EXTAL signal on the oscilloscope EXTAL indicates that the crystal oscillator is running A 4 MHz sine wave should be observed 5 Put the PBO dip switch into the 0 position Ensure that the PB1 PB2 and PB3 dip switches are in the 1 position MC9S12P Family Demonstration Lab Training Rev 0
37. press or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document Freescale Semiconductor reserves the right to make changes without further notice to any products herein Freescale Semiconductor makes no warranty representation or guarantee regarding the suitability of its products for any particular purpose nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit and specifically disclaims any and all liability including without limitation consequential or incidental damages Typical parameters that may be provided in Freescale Semiconductor data sheets and or specifications can and do vary in different applications and actual performance may vary over time All operating parameters including Typicals must be validated for each customer application by customer s technical experts Freescale Semiconductor does not convey any license under its patent rights nor the rights of others Freescale Semiconductor products are not designed intended or authorized for use as components in systems intended for surgical implant into the body or other applications intended to support or sustain life or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur Should Buyer purchase or use Freesca
38. ray 56 of const signed char const array 56 of const signed char unsigned char volatile PPAGE MC9S12P Family Demonstration Lab Training Rev 0 22 Freescale Semiconductor Demonstration Lab Examples 7 Hit the Run button and observe the Memory and Register windows at the next breakpoint 8 Now the PPAGE register is set to OA and the P Flash Window shown in the Memory window displays the contents of PPAGE 0A True Time Simulator amp Real Time Debugger D Profiles r28318 My Documents MetroWerks Projects 512P 512P MMC Demo Sollec HCSiaam Ele View Run inDART HCS12 Component Source Window Help oleja e 2 2 e lae ele a 2 SETA 101 xi PREE D Profiles s28318 My Documents MetioWerks Projects S12P S12P MMC Demo Sources main c mn void main void 8 4005 52 4006 5B15 while 1 4008 00 8 4009 52 PPAGE 0x08 400A 5815 asm BGND PPAGE 0x09 400D 52 asm BGND 400E 5815 PPAGE Ox0A 4010 00 a GND 4011 20ED 7 zaba 0x4000 o B Ix x o p 400D pc 400D __PPAGE eo omn cro evarnror 08000 30 41 20 50 50 41 47 45 OA PPAGE 08008 20 30 41 20 50 50 41 47 OA PPAG 08010 45 20 30 41 20 50 50 41 E OA PPA 08018 47 45 20 30 41 20 50 50 GE OA PP Windows lt 56 gt const array 56 of const signed char 08020 41 47 45 20 30 41 20 50 AGE OA P Window lt 56 gt const array 56 of const signed char 08028 SO 41 47 45 20 30 41 20 P
39. s This demonstration program will complete by erasing the D flash sectors and will end in the while loop 00400 FF FF FF FF Moosoo FF rr rr FF Sloosnc rr rr FF FF 00404 FF FF EF EF 00504 FF FF FFIF OOSEO FF FF FF FF O06FO FF FF FF FF 00408 FF FF FF FF S Moosoe zr FF FF rr Alfloosea Fr rr rrrr EE oori FF rr rr FF 0040C FF FF FF EF 0050C FF FF FF IF OOSES FF FF FF FF O06F2 FF FF FF FF 00410 FF FF EF EF 00510 FF FF FE FF QOSEC FF FF FF FF O06FC FF FF FF FF 00414 FF FF FF FF 00514 FF FF FF FF OOSFO FF FF FF FF 00700 FF FF FF FF 00418 FF FF FF FF 00518 FF FF FF FF OOSF4 FF FF FF FF 00704 FF FF FF FF 0041C FF FF FF EF 0051C FF FF FF EF QOSF2 FF FF FF FF 00708 FF FF FF FE 00420 FF FF FF EF 00520 FF FF FF FF OQOSFC FF FF FF EF 0070C FF FF FF EF 00424 FF FF FF EF 00524 FF FF FF FF 00600 FF FF FF FF 00710 FF FF FF FF 00428 FF FF EFIF 00528 FF FF FF FF 00604 FF FF FF FF 00714 FF FF FF FF 0042C FF FF FF EF 0052C FF FF FF IF 00608 FF FF FF FF 00718 FF FF FF EF 00430 FF FF FF FF 00530 FF FF FE FF 0060C FF FF FF IF 0071C FF FF FF FEF 00434 FF FF EFIF 00534 FF FF FF FF 00610 FF FF FF FF 00720 FF FF FF FF 00438 FF FF FF FF 00538 FF FF FF FF 00614 FF FF FF FF 00724 FF FF FF FF 0043C FF FF FF FF 0053C FF FF FF FF 00618 FF FF FF FF 00728 FF FEF FF FE 00440 FF FF
40. s followed for correct operation Deviation from this could cause errors when working with the P D flash Although this demonstration did not include it it is good practice to verify that the correct data has been programmed to the flash 3 3 Emulated EEPROM Driver 3 3 1 Emulated EEPROM Overview EEPROM electrically erasable programmable read only memory which can be byte or word programmed and erased is often used in automotive electronic control units This flexibility for program and erase operations makes it suitable for data storage of application variables that must be maintained when power is removed and needs to be updated individually during run time For the devices without EEPROM memory the page erasable Flash memory can be used to emulate for EEPROM through EEPROM emulation software The EEPROM emulation driver for S12P implements the fixed length data record scheme emulation on the split gate flash The EEPROM functionalities to be emulated include organizing data records initializing and de initializing EEPROM reporting EEPROM status reading and writing data records Four or more sectors shall be involved in emulation with a round robin scheduling scheme MC9S12P Family Demonstration Lab Training Rev 0 8 Freescale Semiconductor Demonstration Lab Examples 3 3 2 Code Example Explanation and Walkthrough The file of interest is NormalDemo c where the main function resides The purpose of this demonstration
41. t the LIN ENA jumper is present Ensure that the VDD CAN ENA jumper is present Ensure that the VAUX ENA jumper is present Ensure that the RS 232 LIN SEL jumpers select the RS 232 position Ensure that the POWER SEL jumper selects the USB position 10 Connect the demonstration board to the PC via the USB cable 11 The green POWER LED on the board should turn on CON DARWHN 3 Demonstration Lab Examples 3 1 CPMU Clocks This lab example shows how to produce PLL based bus clocks using the different clock modes of the CPMU module The example software initializes the PLL to run in default 8 MHz PEI mode 12 5 MHz PEI mode 32 MHz PEE mode and 2 MHz PBE mode The changes in bus clock can be observed via the LED pulse rate and the frequency can be measured by monitoring the ECLK signal Bus clock on an oscilloscope MC9S12P Family Demonstration Lab Training Rev 0 2 Freescale Semiconductor 3 1 1 Demonstration Lab Examples Setup The following steps should be taken before running the lab example l 2 10 Start CodeWarrior M by selecting it in the Windows Start menu From the CodeWarrior main menu choose File gt Open and choose the S12P System Clocks mcp file Click Open The project window will open The C code of this demonstration is contained within the main c file Double click on the file to open it Ensure the Softec HCS12 option is selected as the target 512P_PWM_Demo mcp Full Chip S
42. tember 1991 It is not limited to automotive applications and is suited to wide variety of uses which require reliable communications For further information on the MSCAN module please refer to the following documentation which is available at www freescale com e AN3034 Using MSCAN on the HCS12 Family e MC9S12P128 Reference Manual MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 15 Demonstration Lab Examples 3 6 PWM Module This lab provides an example of how to setup and use the PWM module to create a 50 duty cycle output with different polarity and alignment settings This behavior is best illustrated if all of the PWM signals can be displayed simultaneously on a four channel oscilloscope 3 6 1 Setup The following steps should be completed before running the lab example 1 Ensure that the ENA jumpers on J504 and J503 are removed This is to prevent the push button associated with Port PO and P1 from interfering with the PWM signal If desired populate J101 with a header row that allows probing of the MCU signals specifically PO P4 Start CodeWarrior by selecting it in the Windows Start menu From the CodeWarrior main menu choose File gt Open and choose the S12P PWM Demo mcp file Click Open The project window will open The C code of this demonstration is contained within the main c file Double click on the file to open it Ensure the Softec HCS12 option is
43. tion on the SCI module please refer to the following documentation which is available at www freescale com e AN2883 Serial Communication Interface as UART on HCS12 MCUs e MC9S12P128 Reference Manual 3 12 SPI Communications This lab example shows how to set up and use the SPI module in Master mode to transmit an incrementing byte of data As there is only one SPI module available on the DEMO9S12PFAME board this example is limited to transmitting data only When an SPI master transmits data to an SPI slave data is usually received simultaneously synchronized by a serial clock MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 29 Demonstration Lab Examples 3 12 1 Setup An oscilloscope and three scope probes are required for this demo The following steps should be followed before running the lab example 1 Ensure that the J101 is populated with a header row that allows probing of the MCU signals specifically PM3 PM5 Start CodeWarrior by selecting it in the Windows Start menu From the CodeWarrior main menu choose File gt Open and choose the S12P SPI Demo mcp file Click Open The project window will open The C code of this demonstration is contained within the main c file Double click on the file to open it 6 Ensure the Softec HCS12 option is selected as the target A ad 512P_PWM_Demo mcp Full Chip Simulation P amp E Multilink Cyclone Pro SofTec HCS12 TBDML sn
44. value of 8 bit MCUs The S12P family bridges the gap between 8 and 16 bit MCUs and serves as an entry point into Freescale s 16 bit family offerings giving customers the flexibility to enhance or cost reduce their applications The 12P family is ideal for a wide range of central body control applications such as window lifts seat controllers sunroofs door modules low end anti lock brake systems ABS electronic power steering EPS and watchdog control A zip file AN3937S W zip containing the complete CodeWarrior projects for the lab examples accompanies this application note The file can be downloaded from www freescale com MC9S12P Family Demonstration Lab Training Rev 0 Freescale Semiconductor 31 Useful Reference Material 5 Useful Reference Material The following material is available at www freescale com Software Development Tools CodeWarrior for HCS12 X Microcontrollers Application Notes AN3622 Comparison of the S12XS CRG Module with S12P CPMU Module AN3034 Using MSCAN on the HCS12 Family AN2612 PWM Generation Using HCS12 Timer Channels AN2428 An Overview of the HCS12 ATD Module AN2883 Serial Communication Interface as UART on HCS12 MCUs AN2461 Low Power Management using HCS12 and SBC devices AN3613 Using the MC9S12XS Family as a Development Platform for the MC9S12P Family MC9S12P Family Demonstration Lab Training Rev 0 32 Freescale Semiconductor THIS PA
45. window 4 Put the PBO dip switch into the 0 position Ensure that the PB1 PB2 and PB3 dip switches are in the 1 position 5 Hit RESET The MCU is now running in PEI mode with a bus clock frequency of 12 5 MHz 6 Monitor the ECLK signal on the oscilloscope ECLK will match the bus clock frequency Observe the LED pulse rate Examine the PLL configuration on the terminal window 7 Put the PB1 dip switch into the 0 position Ensure that the PBO PB2 and PB3 dip switches are in the 1 position 8 Hit RESET The MCU is now running in PEE mode with a bus clock frequency of 32 MHz 9 Monitor the ECLK signal on the oscilloscope ECLK will match the bus clock frequency Observe the LED pulse rate Examine the PLL configuration on the terminal window 10 Put the PBO and PB1 dip switches into the 0 position Ensure that the PB2 and PB3 dip switches are in the 1 position 11 Hit RESET The MCU is now running in PBE mode with a bus clock frequency of 2 MHz 12 Monitor the ECLK signal on the oscilloscope ECLK will match the bus clock frequency Observe the LED pulse rate Examine the PLL configuration on the terminal window 3 1 3 Summary The CPMU PLL has three modes PLL Engaged Internal Mode PEI PLL Engaged External Mode PEE and PLL Bypassed External Mode PBE From reset the bus clock is derived from the CPMU PLL using the 1 MHz internally generated reference clock as it s source PEI mode This is the default clock mode from res

Download Pdf Manuals

image

Related Search

Related Contents

Valueline VLCP60350B10 USB cable  Système de frein  ヘッドレスト付デラックスうしろ子供のせくRBC  1 Resumo dos Sistemas de Repintura para Veículos de Passageiros  AE5400 AE3300 取扱説明書  RCA RC940 User's Manual  108-Port InfiniBand QDR SwitchX® Switch Platform Hardware User  X7721r/X7721r+ User`s Manual Version 1.0  Hype -Manual X7 IT  

Copyright © All rights reserved.
Failed to retrieve file