S12 / MagniV Microcontrollers Knowledge Base

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S12 / MagniV Microcontrollers Knowledge Base

Labels

Discussions

Sort by:
This example: 1. write unprotected P-Flash area 2. protect target P-Flash area 3. tries to write protected P-Flash area 4. call Protection Override command for temporary modify P-Flash protection 5. write into temporary unprotected P-Flash area 6. restore original P-Flash protection scheme The part of P-Flash memory used in this example for writing tests (0xFF8000..0xFF8FFFUL) is excluded from linker using. Please look at prm linker file for more details.   The flash_array constant with Protection Override Comparison Key is not directly referenced in the code, therefore we must enter the constant name into ENTRIES section in prm linker file for avoiding stripping it out as unused. Please look at P-Flash Protection Register (FPROT) chapter in the reference manual for more details about P-Flash protection. The key for Protection Override should be rather received from external source and used as PFLASH_Protection_Override() parameter. The correct Protection Override key is here hard-coded (err = PFLASH_Protection_Override(0xCAFE, 0xF...) for example code simplifying.   I hope it helps you. Radek
View full article
This example shows a few possible configurations of the S12PWM8B8CV2 PWM module. Five PWM channels are configured with different clock source, polarity, alignment, period and duty-cycle.   Four clock sources (A, B, SA, SB) are derived from bus clock using dividers.   Selected polarity of PWM channel determines the duty-cycle whereas the alignment determines the period of the PWM signal.   Four 8-bit channels (4-5, 6-7) are concatenated into two 16-bit channels. Channels 4 and 6 become high-order channels while channels 5 and 7 become low-order channels. These low-order channels (5 and 7) are the output channels routed to a port  and they configure the clock, polarity, alignment and enablement of the PWM signal.  Period and duty-cycle of the signal are configured with both the low-order and high-order channels.   The period registers (PWMPERx) and the duty-cycle registers (PWMDTYx) are double buffered. When they are rewritten while the channel is enabled, the change will not take effect until one of the following occurs: 1. The effective period ends 2. Counter resets 3. The channel is disabled
View full article
Tested on: DEVKIT-S12ZVC MCU: S12ZVC192 Development tool: CodeWarrior 10.7 This example shows ACMP - analog comparator,  which compares voltage from potentiometer and voltage from DAC. DAC is set at 2.5V and uses the positive input of the comparator. Potentiometer uses the negative input in the range of 0V - 5V. When the potentiometer is moved, the output from ACMP will be changed.  If the voltage at the non-inverting (positive) input > the voltage at the inverting (negative) input, the output result is in the logic level 1 and the red LED is on.
View full article
You can find here two example codes for API timer. G240-API-CW51.ZIP contains example code for trimming API timer to 10kHz (API isn't factory trimmed). G240-API+STOP-CW51.ZIP contains example code for enter to stop mode and periodical wakeup by API interrupt
View full article
S12 FAMILY DEVICES COP RECOGNITION CONSIDERATIONS SHOULD HELP YOU TO SET HW OF THE RESET PIN TO BE COP CORRECTLY RECOGNIZED The calculator can be found at S12 FAMILY DEVICES COP RECOGNITION CONSIDERATIONS - calculator.xlsx
View full article
A project presents control of the HD44780 driven display where it is assumed that RW pin of the LCD is permanently connected to “Write” level (GND). The SW contains mirror(s) of the LCD display as array of characters stored within RAM. Both read and write function can be used because writing is performed to the display and also to the array. Read functions are directed to the character array stored within RAM.
View full article
The calculator was created for the MagniV devices such as S12ZVL, S12ZVC, S12ZVMB, S12ZVM, S12ZVH, and S12VR qualified under junction temperature Tj <= 150°C. It shows the settings of PLL registers as SYNR, REVDIV, and POSTDIV. The description of these registers can be found in the reference manual of each device.  The Oscillator and Bus clock frequency can be selected from the list or can be written manually. The values will be calculated by "Enter" or "Calculate" button. The MagniVPLLCalc.exe is attached.
View full article
Introduction S12ZVM is a mixed signal MCU for automotive motor control applications. PWM signal for external MOSFETs is managed by integrated gate drive unit, providing gate signals of dedicated profile and strength. In motor control application, current feedback is typically needed and is usually measured in synchronization with PWM signal. In order to schedule sampling commands correctly, delays between PWM signal and actual MOSFET state have to be known. Following text aims to show how to measure delays between PWM and GDU on S12ZVM device. Based on the S12ZVM Reference Manual, the delay is dependent on the slew-rate settings, thus it is important to measure this delay for user configuration. How to Measure Delays in S12ZVM Application? S12ZVM provides PWM probe signals for debugging purposes. In this special mode, PWM signals can be enabled on general purpose pins. User has to make sure the pins are available and not used by another functionality. Pins availability has to be checked for specific product in the Reference Manual. As an example, S12ZVM PMSM/BLDC development kit can be used. S912ZVML12F1MKH or S912ZVML12F3MKH is populated, which introduces PMF_V3 and GDU_V4 in 64-pin LQFP package. On this device, PMF output signals (PWM1_0 to PWM1_5) are routed to pins PP0, PP1, PP2 and PT0, PT1, PT2 and probing can be enabled by PWMPRR1-0 bits in MODRR1 register (see Paragraph 2.3.2.2 Module Routing Register 1 (MODRR1) in the Reference Manual. Note In many motor control applications, probing pins are being used by the application, for example: PP0 - used as EVDD1 external 5V power supply for sensors PP1, PP2 - used for "keyboard wake-up" functionality (e.g. car key signal) PT0, PT1, PT2 - used as Hall-switch sensor inputs (timer input-capture mode signals) or SPI interface or SCI/UART interface. In such cases, it is necessary to have special PCB configured for the test, where the functions above are disabled (e.g. components not populated). System settings Considering S12ZVM PMSM/BLDC development kit as an example, jumper settings should be changed to have the PWM signals clear (with no external load or source, e.g. pull-ups). Jumper Default settings Configuration for the test Notes J9 Enabled Disabled User On/Off switch on PT1 J14 2-3 Removed EVDD / Fault input on PP0 J15 2-3 Removed HALL_A / Res_A on PT1 J16 2-3 Removed HALL_B / Res_B on PT2 J19 Enabled Disabled "Up" button on PP1 J20 Enabled Disabled "Down" button on PP2       Testing Points Oscilloscope of sufficient parameters should be used (at least 500Ms/s) with standard low-capacitance probes or better, with isolated differential probes. Channel connection for the test should be as follows: Channel 1: PWM1_n signal to GND (for PWM1_0, PP0 on J21:1 can be used) Channel 2: GDU HGm or LGm signal to GND (for HG0, TP31 is used) or HGm to PHASE_m if differential probe is used (for HG0, TP31 and PHASE_A / TP35) Channel 3: Phase voltage on PHASE_m to GND (e.g. PHASE_A)   Software Demo software provided on the S12ZVM PMSM/BLDC development kit page can be used for the test with minor changes: In "main.c", buttons and switch handling should be disabled (commented out) INTERRUPT void ADC1done_ISR(void) { static tBool getFcnStatus; EnableInterrupts; //PTT_PTT0 = 1; // Set debug pin to record execution time // Read the user control interface //cntrState.usrControl.btSpeedUp = PTP_PTP1; //cntrState.usrControl.btSpeedDown = PTP_PTP2; // User switch should be checked only if not in init state (see state machine table) //if(cntrState.state != init) // cntrState.usrControl.btFlipFlop = PTT_PTT1; // User accessible switch for stopping the application. if (cntrState.usrControl.btFlipFlop ^ cntrState.usrControl.btFlipFlopTemp) { cntrState.usrControl.btFlipFlopTemp = cntrState.usrControl.btFlipFlop; cntrState.usrControl.switchAppOnOff = (cntrState.usrControl.btFlipFlop) ? false: true; } ... In "src\S12ZVM_system\peripherals\pim.c", pin configuration should be changed as follows: void pim_init(void) { MODRR0_SCI1RR = 1; // SCI - FreeMASTER //DDRS_DDRS4 = 1; // Debugg Signal //DDRS_DDRS5 = 1; // Debugg Signal //DDRT_DDRT0 = 1; // Debugg Signal MODRR1_PWMPRR = 0x01; //PWM to pins enabled //DDRT_DDRT1 = 0; // Input switch signal }  Finally, GDU slew rate should be set to the values assumed by the application: GDUSRC_GSRCHS = 7; // High-side slew rate GDUSRC_GSRCLS = 7; // Low-side slew rate Results Resulting waveforms can be seen on the following figures for normal (room) conditions and using following setup: Item Details Oscilloscope Lecroy WaveRunner 44Xi-A Probes PP008 / 500MHz, 10MΩ, 9.5pF Evaluated PWM signal PWM1_0 / HG0 EVB S12ZVMLEVBLIN Rev.D   Two corner cases have been used to match the specifications in the Reference Manual. However, user-specific slew rate settings may be used to measure the delay in the application. Slowest Slew Rate Settings (GDUsrc=0) Switch-on delay: Switch-off delay: Fastest Slew Rate Settings (GDUsrc=0x77) Switch-on delay:   Switch-off delay:   Summary Measured values are compared with the Reference Manual specifications. Switch-on and switch-off delays are presented. As seen below, the results are within the specified range. Slew rate Edge Minimum Maximum Measured Fastest slew T_delay_ON 0.47 μs 0.89 μs 0.55 μs T_delay_OFF 0.25 μs 0.49 μs 0.32 μs Slowest slew T_delay_ON 0.77 μs 1.43 μs 1.08 μs T_delay_OFF 0.25 μs 0.49 μs 0.33 μs   For higher confidence, high temperature and low temperature tests are recommended. Conclusion This short article shows how to measure propagation delay between PWM signals and GDU outputs on S12ZVM using S12ZVM PMSM/BLDC development kit. The PWM to GDU propagation delay is important information for proper timing of ADC triggering if synchronized with PWM. In simple or simplified use cases, maximum ratings of the delay can be used for consideration. However, unnecessarily higher time span between the PWM edge and ADC trigger may raise a need for lower duty-cycle limit, thus limiting the overall performance e.g. at high speed. Therefore, the importance of proper ADC triggering based on known propagation delay of PWM to GDU signal is obvious. In addition, MOSFET turn-on and turn-off times have to be considered in the overall ADC triggering schedule, based on application-specific settings.
View full article
This document is intended to show the new SM912F634xxxxx part and the differences between this new part and the MM912F634xxxxx part.
View full article
Work with pushbuttons and 7 segment display. Write assembly (ASM) and C programs for the HCS12, as well as to work with the pushbuttons and 7-segment display on the Dragon12-JR board.  The programs find the largest and smallest numbers from an arbitrary list of eight 8-bit unsigned numbers and displays them on the 7-segment display as outlined in the following.   1. Write a program to do the following, in both ASM and C. Do not use MINA, MINM, MAXA, and MAXM instructions.            a. Load an array of eight 8-bit unsigned numbers into RAM.            b. Find the largest of these numbers and store it.            c. Find the smallest of these numbers and store it.            d. Wait for the pushbuttons (S1 or S2) to be pressed.            e. The first time S1 is pressed, display the high nibble of the largest number; the second time S1 is pressed, display the low nibble of the largest number.                For example, if the largest number is 0x3F, the 7-segment display should show “3” the first time S1 is pressed and “F” the second time it is pressed.            f. Do the same for S2, except use the smallest number.  2. Explain why debouncing is used with switches. Optional: Implement software debouncing for switch used above.   Hints: These are unsigned numbers that your program will be searching through.  Make sure you are using the unsigned branch instructions in your ASM code. Your TA will be changing the numbers in your array to make sure it works for arbitrary 8-bit values. Please make sure the array is somewhere near the top of your program file. For interfacing to LEDs, 7 segment Displays, and pushbuttons see the schematic and manual of your development board. The type of the 7-segment LED on the Dragon12-JR board is common anode. All cathodes are driven individually by an output port and all anodes are internally connected together. The Dragon12-JR board uses port H to drive 7-segment cathodes. Skeleton files are provided to help you complete the asseignment. The 7-segment display communicates with the board via Port H whose address is $0260 (PTH).  Its data direction (input or output) is controlled by writing to Data Direction H register whose address is $0262 (DDRH). In order for PTH to be output (i.e. displaying something), you must set DDRH to $FF first (all bits high, all bits output).  The skeleton code does this for you this time. Almost every I/O port on the board works similarly to PTH; that is, you must set the direction of data on a corresponding data direction register before writing to or reading from it. The two pushbuttons (S1 and S2) are connected to PM6 and PM7. S1à PM6, S2à PM7 A subroutine that displays the low nibble of register A is included with the skeleton ASM code. Just store a value in register A and issue jsr seg7_out to display the low nibble of A. You are required to understand how it works and to write a similar routine for the C version of your code.   This document was generated from the following discussion: Professional Way to solve this HCS12 Dragon12-JR,Work with pushbottons and 7 segment display
View full article
TIC example code, v.1.1 * The SW: * demonstrates FLASH programming as a part of application * uses adjusted routines from AN2720 * writes a few words into FLASH locations Pages FE and E0~EF may be used for data storage.   Other pages are used for program storage (see PRM file)      * tested on: HCS12X STARTER KIT * OSCCLK = 16MHz, BUSCLK = 8MHz * Reference to documentation: MC9S12XDP512V2 Rev.2.17 Original Attachment has been moved to: XDP512-FLASH-E_W-CW47.ZIP
View full article
The package contains of AN5327_SW ported to S12ZVML-MINIBRD hardware. Just minor changes are introduced, such as removing a button control, moving the LED light to another pin and using internal oscillator. This is just a working version, it is NOT an official release!!! AN5327_SW_CW11_MINIBRD.ZIP CodeWarrior 11.0 and AMMCLib 1.1.13 or higher is required to run this example. If you are not sure about the AMMCLib version, please download the general AN5327_SW from the www.nxp.com/automcdevkits first, install it and then unzip and use the example above.
View full article
Here is a SW example demonstrating measurement of the bandgap voltage featured on a microcontroller. The bandgap voltage is routed to an internal ATD channel. ATD converter measures the input voltage and stores it to a variable located in Flash memory. The SW example project is made in CodeWarrior v5.1 for MC9S12XEP100 device.
View full article
Based on S12G128,  Firstly, placed some const at PAGE_0B,  Secondly, place the same data at NON_BANKED  Finally, you can check whether reading result of paged const is right. Of course, they are the same.  Cheers !
View full article
Hello Community user, This post is intended to show how to recovery from Bus-Off state using the MSCAN and CANPHY modules in the MagniV devices. This example is focused on S12ZVC due to the internal CANPHY so it makes easier to create a quick example. What is Bus-Off condition? The bus-off condition is a catastrophic condition where the node in this state does not transmit anything on the bus. How to enter in Bus-Off state? A node enters in this state if any of the two error counters, Transmit Error Counter (TEC) and Receive Error Counter (REC) raises above 255. How to recovery from Bus-Off? A note is permitted to become error-active (no longer bus-off) when its error counters both set to 0 after 128 occurrences of 11 consecutive recessive bits have been monitored on the bus. The MSCAN module implements two ways to recover from the fault, the automatic and the manual. The automatic bus-off recovery method puts the node into the error-active state after monitoring 128 occurrences of 11 consecutive bits on the bus. It's important to note that the CANPHY also reports errors on the bus so, the proper error flags must be clear to assure the correct functionality of the node if CANPHY is being used. The manual bus-off recovery method (which is used in this example) puts the note into the error-active state after both independent events have become true in any order: 128 occurrences of 11 consecutive recessive bits on the CAN bus have been monitored. (Cannot be consecutive). CANMISC[BOHOLD] bit has been cleared by the user. Implementation The project contains a header file called  "common.h" which contains three defines that are used to set the CAN nodes. Just one define must be active per node. NODE0_TX and NODE1_TX are transmitting messages on the CAN bus and the NODE_RX is receiving the messages. #define NODE0_TX #define NODE1_TX #define NODE_RX‍‍‍‍‍‍ All nodes are blinking the green led indicating the communication is stable and no errors have occurred. At this point, you should generate the bus-off condition. A way to generate a bus-off condition is grounding one of the two CAN lines (CAN_High or CAN_Low) which will cause a bus-off condition to the transmitters nodes. When the node is in the bus-off state, the yellow led is toggled. At this point, you should not be any message being transmitted on the bus due to the transmitter node is in bus-off. The bus-off condition is detected by the application in the bus-off interrupt (refers Events.c file) which triggers the yellow led toggling. void CAN0_OnBusOff(void) { /* Get CAN bus status */ CAN0_GetError(&gCANErrpr); /* If bus error is set, inform to the application*/ if(gCANErrpr.errName.BusOff){ gBusOffState = PENDING; } CAN0RFLG_CSCIF = 1; // Clear flag }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍ In the main.c file when the node transmitters are selected, there is a routine asking for a push-button event. This event triggers the bus-off recovery request by setting the CANMISC[BOHOLD]. At that point, the 128 occurrences of 11 consecutive recessive bits on the CAN bus should have passed and the green led will toggle again indicating the communication is stable again and no errors have occurred. At this point, you should see the messages on the CAN bus again. /* Read button to recovery from bus off condition*/ if(PushButton3_GetVal()){ CAN0_BusOffRecoveryRequest(); // Request get out of bus off gBusOffState = NONPENDING; /* Clear bus off LED indicator */ LED_YEL_OFF; }‍‍‍‍‍‍‍‍‍‍‍‍‍‍ ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍ Note: The VLG-MC9S12ZVC was used for this example and the push button that must be pressed is SW12. Best Regards, Atzel Collazo
View full article
Theory described in S12 FAMILY DEVICES COP RECOGNITION CONSIDERATIONS_v2.0.pdf
View full article
Hello everyone, In this post you are going to find the example codes that where mentioned during the "Learning to Easily Develop LIN-based Actuator Applications with Mixed-signal MCUs" webinar. In the "S12ZVMA_Webinar_ExampleCodes" package you are going to find the code for the S12ZVMA slave node, the code for the S12ZVL master node and the LIN configuration files (LDF and NPF's files).   SETUP CONFIGURATION: In the images below you can find the information you need to know to create the setup and get running your LIN network and the DC motor.   Note: Remember that in this code we are using the active configuration where the High Side Driver and the Low Side Driver are being used to control de motor.   Steps: Place jumper J21 in the position [3-2]. With this step, we are connecting the PHASE_A_HS with the PHASE_A_LS to get the active configuration. Connect one line of your DC motor to J30 (connect it in pin 2 or 3, do not use pin 1) and the other line to any GND point of your S12ZVMAEVB. Connect the master and the slave nodes using J6 jumper.     Best Regards, Atzel Collazo
View full article
Program Once Field is a part of Flash IFR which can be used to store non-volatile data. This field consists from 8 phrases (64 bytes), where each phrase has an index (0-7).   phrase index 0      0x1F_C0C0 - 0x1F_C0C7   phrase index 1      0x1F_C0C8 - 0x1F_C0CF   phrase index 2      0x1F_C0D0 - 0x1F_C0D7   phrase index 3      0x1F_C0D8 - 0x1F_C0DF   phrase index 4      0x1F_C0E0 - 0x1F_C0E7   phrase index 5      0x1F_C0E8 - 0x1F_C0EF   phrase index 6      0x1F_C0F0 - 0x1F_C0F7   phrase index 7      0x1F_C0F8 - 0x1F_C0FF The attached example code presents Flash commands to access the IFR Program Once Field. Program Once command takes a single phrase (8 bytes) of data and one phrase index. Each phrase can be programmed independently but only once since the non-volatile information register in P-Flash cannot be erased. On attempt to overwrite a phrase that has been once written, ACCERR flag is set in FSTAT register and the command is terminated.   Similarly, Read Once command takes one phrase index and returns a phrase of data. After this command is executed data are available in FCCOBx registers and can be read by software. The Program Once and Read Once commands must not be executed from the Flash block containing the IFR Program Once reserved field to avoid conflicts. Therefore, a function that launches Flash commands is placed into RAM.
View full article
This simple SW example is a CodeWarrior project which demonstrates the usage of Security feature on a microcontroller. Find detailed description in the main.c file. It is also shown how to use backdoor access key to put MCU in unsecured state. The CW project is made for MC9S12ZVL device and the source code can be used on any other derivative with MagniV device family.
View full article