S12 / MagniVマイクロコントローラ ナレッジベース

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S12 / MagniV Microcontrollers Knowledge Base

ラベル

ディスカッション

ソート順:
 *******************************************************************************  * File              main.c  * Owner             LaMa-TIC-RPR  * Version           1.1  * Date              Jun/17/2016  * Classification    General Business Information  * Brief             S12Z Frequency Measurement at PT0 (IOC0_0) by TIM module  *                   in input capture mode  *******************************************************************************  * Detailed Description:  * The code measures frequency at PT0  * It demonstrates  * - It measures frequency at PT0 by means of TIM module IOC0_0.  * - The measurement is sensitive on rising edges so duty cycle has no affect  *   to the measurement  * - Constants:  *           BUSCLOCK  *           MAX_OVERFLOWS  *           TIMER_PRESCALLER  *      must be defined  * - MAX_OVERFLOWS determines minimum measurable frequency.  *   It is max. allowed number of overflows. When overflows counter reaches  *   this value it the flag FREQUENCY_TOO_LOW is set. The message  *   PERIOD BETWEEN TWO EDGES IS TO WIDE is then written to a variable "str"  *   This value gives time interval:  *     T = TIMER_PRESCALER * MAX_OVERFLOWS * 65536 / BUSCLOCK      *     For example:  *      - TIMER_PRESCALER = 1  *      - MAX_OVERFLOWS   = 1000  *      - BUSCLOCK        = 16,000,000Hz  *      T = 1 * 1000 * 65536 / 16,000,000 = 4,096s  => f=0,244140625Hz  * - TIMER_PRESCALER = { 1,2,4,8,16,32,64,128} - smaller values give more  *   precise values but it generates timer overflow more frequently  * - the physical representation of the measured frequency is stored in the  *   string "str"  *  * - The measurement precision is df which can be expressed as:  *  *    df = BUSCLK / ((n^2 + n) * PRESCALER); n = measured number of TCNT periods  *               *   For example: BUSCLK = 16MHz, n = 399, PRESCALER = 1  *     *     *             df = 16,000,000 / ((399^2 + 399) * 1) = 100.25Hz  *               *             so, count 399 means f=BUSCL/399=16,000,000/399 = 40,100.25Hz  *             so, count 400 means f=BUSCL/400=16,000,000/399 = 40,000.00Hz  *                   * So this method is not suitable for large frequencies as can be seen in  * following table (percentual error we can get is df/f):  * n   f[Hz]      df[Hz]                        n   f[Hz] df[Hz]  * 1   8000000   5333333,3           101 1553,0 30,1  * 2   2666666,6 1333333,3           102 1522,9 29,2  * 3   1333333,3  533333,3           103 1493,6 28,4  * 4    800000    266666,6             104 1465,2 27,6  * 5    533333,3  152380,9            105 1437,5 26,8  * 6    380952,3   95238,0             106 1410,6 26,1  * 7    285714,2   63492,0             107 1384,5 25,4  * 8    222222,2   44444,4             108 1359,1 24,7  * 9    177777,7   32323,2             109 1334,4 24,0  * 10   145454,5   24242,4            110 1310,4 23,4  * 11   121212,1   18648,0            111 1287,0 22,7  * 12   102564,1   14652,0            112 1264,2 22,1  * 13    87912,0   11721,6             113 1242,0 21,6  * 14    76190,4    9523,8             114 1220,4 21,0  * 15    66666,6    7843,1             115 1199,40,502  * 16    58823,5    6535,9             116 1178,8 19,9  * 17    52287,5    5503,9             117 1158,9 19,4  * 18    46783,6    4678,3             118 1139,4 18,9  * 19    42105,2    4010,0             119 1120,4 18,5  * 20    38095,2    3463,2             120 1101,9 18,0  * 21    34632,0    3011,4             121 1083,8 17,6  * 22    31620,5    2635,0             122 1066,2 17,1  * 23    28985,5    2318,8             123 1049,0 16,7  * 24    26666,6    2051,2             124 1032,2 16,3  * 25    24615,3    1823,3             125 1015,8 15,9  *  * - PCB setup:  *   - J35 is disconnected because measurement is done on PT0  *   - pulse generator is connected to the J35 pin 1. (PT0)  *    * - Reference to documentation: MC9S12ZVLMR1.pdf Rev. 1.02  * - Tested on TRK-S12ZVL  * - MCU MC9S12ZVL32 0N22G  * - OSCCLK = 4MHz  * - BUSCLK = 16MHz (set by PLL)  *  * The info about frequency and count is transmitted over the SCI0 Tx which is  * routed (MODRR) to PS1 pin  *  *******************************************************************************  Revision History:  Version Date          Author            Description of Changes  1.0     Jun/17/2016   LaMa-TIC-RPR      Initial version  ******************************************************************************/
記事全体を表示
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
記事全体を表示
This example simulates ECC issue by cumulative write into the same Flash area without an erasing.   The Flash erase operation set all bits into log1. The Flash program operation may keep bit cells in log1 state or change it into log0 state, but not in opposite way.   The S12Z MCU Flash is protected by 39-Bit ECC Scheme. Every aligned 32bits is protected by additional 7 bits with ECC checksum. The ECC values are not accessible for users. Every Flash reading triggers also ECC check by internal logic. The single bit error in user data may be corrected by ECC checksum. The double bit error cannot be corrected.   The ECC protection is implemented also at flash controller commands and results are signaling by MGSTAT bits.     The first case simulates Single-bit ECC error during reading. The MGSTAT bits after the second write are 0b10 due to fact that just 1 bit is different during write verification (correctable error)   The second case simulates Single-bit ECC error during reading. The MGSTAT bits after the second write are 0b11 due to fact that more than 1 bits are different during write verification (non-correctable error)   The third case simulates Double bit ECC error during reading. The MGSTAT bits after the second write are 0b11 due to fact that more than 1 bits are different during write verification (non-correctable error)     The flash patterns are selected for highlighted described behavior and they don't have any real meaning.   The cumulative write is not allowed for normal operation!!! The code from this example should be used only for design testing - not in production!!!   Please, see the prm file. Address range 0xFF0000-0xFF01FF is excluded from default ROM and is used as user flash memory The size of sectors is 512 bytes = 64 phrases.   Note: The PFLASH_Program() function was updated - erase verification is skipped     I hope it helps you. Radek
記事全体を表示
Here are the two utilities which can be used to calculate the following:   - PLL filter component values on HCS12 devices such as MC9S12DP256   - PLL register values on S12(X) devices such as S12XE, S12XF, S12XS, S12P and S12HY.   Both utilities come with appropriate user manuals in PDF.
記事全体を表示
Have you ever wondered what is the difference between the electric motors included in those two Development Kit with S12 MagniV?     MTRCKTSBNZVM128: 3-phase Sensorless BLDC Development Kit with S12 MagniV S12ZVM MTRCKTSPNZVM128: 3-phase Sensorless PMSM Development Kit with S12 MagniV MC9S12ZVML128 MCU   Well frankly writing none. They include the same motor model 45ZWN24-90       . So the motors are same from physics perspective, only the flux distribution in an air gap is different. It is sinusoidal for PMSM whereas it is trapezoidal for BLDC motor. The powerstage is same for both but what is different however is the control strategy. The Linix motor equipped with the DevKits is in fact somewhere between PMSM and BLDC, The flux is not sinusoidal nor trapezoidal.   Further information and motor parameters can be found at manufacturer product pages:                          http://www.linixmotor.com/3-3-Tool-Motor.html
記事全体を表示
CAN setup calculator for S12(X) and MagniV devices.   I would like to share my CAN setup calculator I've been using for a few years. I’ll be glad if anyone who sees any discrepancy in calculation or values would contact me with comment or idea for improvement. Even I think the sheet is intuitive I’ll provide a few notes. 1) Entering input values a) fosc – defines frequency of input clocks for CAN peripheral. It can be either oscillator clock or bus clock in dependence what is used in application. Note: Because of CAN clock requirements I suggest to use oscillator clock as a source clock for CAN peripheral to meet oscillator precision parameter. The recommendation is based on the fact of that the PLL is usually used for bus clock generation and the PLL unlock parameter is usually out of clock specification. Especially un-lock parameter which can be observed and processed by PLL lock interrupt. Only for example, S12ZVC defines:   b) Physical Interface Tx+ Rx propagation delay – The parameter can be calculated from the data presented in the data sheet for given CAN transceiver. A few values are presented in the top of the sheet.   c) Required sample point - A good general rule is to set the sample point above 80%. Based on the experiences of the automotive industry, the selected sample point should be near the 80% value.   2) Output values   The results field show calculations for all combinations. The simplification, I use, is the max SJW is always used.   Lines containing correct values for bitrate setup are highlighted with orange color. The only thing which is not checked is sample point. You should check calculated “Sample point calculated” whether it corresponds to your requirements. There are two correct values of CANBTR0 and CANBTR1 for required bitrate but the bottom orange line meets exactly our requirement for sample point.
記事全体を表示
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.
記事全体を表示
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
記事全体を表示
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
記事全体を表示
Here is the example code demonstrating usage of BATS module integrated in MagniV devices such as S12ZVM, S12ZVC, S12ZVL etc. Find detailed description in the projects main.c file. The example project was created in CodeWarrior IDE v10.6.4 and tested on TRK-S12ZVL board.
記事全体を表示
For debug purposes, it is possible to read and write the user data and the ECC value directly from/to the SRAM memory. For these debug accesses a register interface is available.   By the debug access and writing incorrect data + ECC values into the system memory,  the single and double bit ECC errors may be simulated for checking the software error handling.   The debug registers may be modified only in a special mode.   The tested address 0x3000 is excluded from linker use - see prm linker file.   I hope it helps you. Radek
記事全体を表示
Interrupt catcher you can use for debugging or directly in your software. Few notes: 1. You should replace lines for expected interrupt by your interrupts routines as in example of SCI0 interrupt routine. 2. All interrupt vectors are only 16bit addresses, therefore all your interrupt routines must be placed in non banked memory (for example by #pragma commands) 3. Interrupt number 0 presents POR reset vector, 1 is CM reset, 2 is COP reset, … , 119 is Spurious Interrupt. Interrupt number = (0xFE-Vector Address)/2. See Table Interrupt Vector Locations at RM. For Example: Interrupt number of SCI0 = (0xFE-D6)/2 = 0x14 = 20.
記事全体を表示
Theory described in S12 FAMILY DEVICES COP RECOGNITION CONSIDERATIONS_v2.0.pdf
記事全体を表示
Dear reader,   There is extended information provided in the attached document. it contains detailed description "how-to", example design, detailed memory maps and code examples.   Also tested example projects created under CodeWarrior are attached.   I believe the document as well as SW examples will help you in the design and avoid mistakes we have met under our work in the S12(X) support team.   Yours sincerely,   Ladislav
記事全体を表示
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.
記事全体を表示
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.
記事全体を表示
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
記事全体を表示
Attached zip file contains three Code Warrior project for MagniV devices (S12ZVM, S12ZVL and S12ZVC). Each of them demonstrates usage of High Voltage Input feature. Find detailed description in the header of main.c file of the CW project.
記事全体を表示
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.
記事全体を表示
In the ZIP file you can find two CodeWarrior projects, one for S12ZVM and other for S12ZVL device, demonstrating the trimming of Autonomous Clock (ACLK - trimmable internal RC-Oscillator) which can be selected as clock source for some CPMU features. Also the Autonomous Periodical Interrupt feature using the trimmed ACLK as a clock source is demonstrated too in this SW example.
記事全体を表示