Getting started with S12ZVL32 S12 MagniV Training Labs Aug.03.2015 TM External Use Agenda. • Low Power Hands-On Exercise • • • • Description Low Power Capabilities Flow Chart Adjust wake-up time • PWM Hands-On Exercise • • • Description Flow Chart Plot of signals • SPI Hands-On Exercise • • • Description Flow Chart Connections/ Results • EVDD Hands-On Exercise • • • Description Flow Chart Connections TM External Use 1 Low Power Hands-on Exercise S12ZVL_ Training TM External Use 2 Low Power Hands-on Exercise Purpose and description: Demonstrate the S12ZVL low power capabilities, In this Project the MCU is in stope mode mode but is woken-up by an autonomous periodical interrupt. In each interrupt led PP5 will toggle. TM External Use 3 S12ZVL low power functionality • Apart from Run mode, the following table summarizes the low power capabilities. Operating mode Current consumption (typ) Active functionality Wake up sources Wait ~26mA *ADC *Timers *PLL *SCI *I2C *Timers *KWI *PIM *SCI Stop ~23uA *ACLK *KWI *API *XIRQ *IRQ Wake up time tlock 23us+tlock *tlock: (150 +256/fREF)us TM External Use 4 Low Power Hands-on Exercise 1. 2. 3. 4. Create a new Project in CodeWarrior Add the Low Power code Download/Debug the code Modify the wake-up frequency TM External Use 5 Low Power Hands-on exercise Create a new project in CodeWarrior 1. 2. 3. 4. 5. 6. File -> New -> Bareboard Project Name the project. Click next Select device: S12Z -> S12ZVL Family -> MC9S12ZVL32 Debug connection: Select “Open Source BDM” Build options are left as default, click next Rapid is not used, click Finish TM External Use 6 Low Power Hands-on exercise TM External Use 7 Low Power Hands-on exercise TM External Use 8 Low Power Hands-on exercise TM External Use 9 Low Power Hands-on exercise TM External Use 10 Low Power Hands-on exercise TM External Use 11 Low Power Hands-on exercise TM External Use 12 Low Power Hands-on exercise Add the Low Power code 1. Open “S12ZVL_Training/Labs/S12VL_Training_LP” 2. Open “Sources/main.c” 3. Copy all the code 4. Go back to CodeWarrior 5. Open “main.c” 6. Replace all the code TM External Use 13 Low Power Hands-on exercise Flow Chart TM External Use 14 Low Power Hands-on exercise Download / debug the code and run it TM External Use 15 Low Power Hands-on exercise Verify Green led is blinking TM External Use 16 Low Power Hands-on exercise How to adjust your wake up time. Modify wake-up frequency changing the value on CPMUAIRH and CPMUAIRH register Desired wake up time CPMUAIRH CPMUAIRL 100ms 0x02 0x7C 500ms 0x0C 0x6D 1s 0x18 0xDA 5s 0x7C 0x45 * Assuming autonomous internal clock of 25.4Khz TM External Use 17 PWM Hands-on Exercise S12ZVL_ Training TM External Use 18 PWM Hands-on Exercise Purpose and Description: • In this project you will setup the PWM module. Configuring time sources, prescalers and duty cycles for the different pins of port P. TM External Use 19 PWM Hands-on Exercise PWM brief description • The PWM module in S12ZVL has 8 independent channels to be configured as PWM. Each channel has independent programmable period and duty cycle. TM External Use 20 PWM Hands-on Exercise 1. 2. 3. 4. 5. Create a new project in CodeWarrior Add the PWM code Download / Debug the code Use an oscilloscope to verify the different duty cycles in the signals Modify the code to see a change in duty cycle. TM External Use 21 PWM Hands-on Exercise Create a new project in CodeWarrior 1. 2. 3. 4. 5. 6. File -> New -> Bareboard Project Name the project. Click next Select device: S12Z -> S12ZVL Family -> MC9S12ZVL32 Debug connection: Select “Open Source BDM” Build options are left as default, click next Rapid is not used, click Finish TM External Use 22 PWM Hands-on Exercise Add the PWM code 1. 2. 3. 4. 5. 6. Open “S12ZVL_Training/Labs/S12VL_Training_PWM” Open “Sources/main.c” Copy all the code Go back to CodeWarrior Open “main.c” Replace all the code TM External Use 23 PWM Hands-on Exercise Flow Chart TM External Use 24 PWM Hands-on Exercise Download / debug the code and run it TM External Use 25 PWM Hands-on Exercise • Connect pins PP1, PP3, PP5 and PP7 to an oscilloscope PP1- Yellow signal (25%) PP3- Green signal (50%) PP5- Blue signal (75%) PP7- Pink signal (100%) TM External Use 26 PWM Hands-on Exercise • Modify the code to see a change in duty cycle: TM External Use 27 SPI Hands-on Exercise S12ZVL_ Training TM External Use 28 SPI Hands-on Exercise Description: • On this project the SPI module will be configured to send the message “ABCD” through MOSI signal. TM External Use 29 SPI Hands-on Exercise 1. 2. 3. 4. 5. Create a new project in CodeWarrior Add the SPI code Download / Debug the code Use an oscilloscope to verify the data sent. Modify the code to change the data sent through MOSI signal. TM External Use 30 SPI Hands-on Exercise Create a new project in CodeWarrior 1. 2. 3. 4. 5. 6. File -> New -> Bareboard Project Name the project. Click next Select device: S12Z -> S12ZVL Family -> MC9S12ZVL32 Debug connection: Select “Open Source BDM” Build options are left as default, click next Rapid is not used, click Finish TM External Use 31 SPI Hands-on Exercise Add the PWM code 1. 2. 3. 4. 5. 6. Open “S12ZVL_Training/Labs/S12VL_Training_SPI” Open “Sources/main.c” Copy all the code Go back to CodeWarrior Open “main.c” Replace all the code TM External Use 32 SPI Hands-on Exercise Flow Chart TM External Use 33 SPI Hands-on Exercise Download / debug the code and run it TM External Use 34 PWM Hands-on Exercise • Connect MISO, MOSI, CLK and SS pins to an oscilloscope. MISO MOSI Sending “ABCD” message through MOSI channel CLK SS TM External Use 35 SPI Hands-on Exercise Modify the code to change the data sent through MOSI signal: TM External Use 36 EVDD Hands-on Exercise S12ZVL_ Training TM External Use 37 EVDD Hands-on Exercise Description: • S12ZVL has a switchable external power supply pin (EVDD) with a increased current capability (20mA). • On this project the over-current monitor will be implemented to protect the EVDD pin from short circuits or excess currents on the output. TM External Use 38 EVDD Hands-on Exercise 1. 2. 3. 4. 5. Create a new project in CodeWarrior Add the EVDD code Download / Debug the code Use a proto board, 1K ohm resistance and a led diode. Test the project TM External Use 39 EVDD Hands-on Exercise Create a new project in CodeWarrior 1. File -> New -> Bareboard Project 2. Name the project. Click next 3. Select device: S12Z -> S12ZVL Family -> MC9S12ZVL32 4. Debug connection: Select “Open Source BDM” 5. Build options are left as default, click next 6. Rapid is not used, click Finish TM External Use 40 EVDD Hands-on Exercise Add the PWM code 1. 2. 3. 4. 5. 6. Open “S12ZVL_Training/Labs/S12VL_Training_EVDD” Open “Sources/main.c” Copy all the code Go back to CodeWarrior Open “main.c” Replace all the code TM External Use 41 EVDD Hands-on Exercise Flow Chart TM External Use 42 EVDD Hands-on Exercise Download / debug the code and run it TM External Use 43 EVDD Hands-on Exercise 1. Connect in series the resistance with the led and connect to pin PP7 and Gnd. The led will turn on 2. If the 1Kohm resistance is removed the output driver is immediately forced low and the over-current interrupt flag OCIF asserts. TM External Use 44 EVDD Hands-on Exercise Verify red led is turned on. TM External Use 45 More S12ZVL resources Product summary page • www.freescale.com/S12ZVL Application notes: • AN5122: LIN Driver with the MagniV Family • AN5082: MagniV in 24 V Applications • AN4842: LIN Enabled RGB LED Lighting Application TM External Use 46 TM www.Freescale.com © 2014 Freescale Semiconductor, Inc. | External Use