AN4300 STMICROELECTRONICS | Alldatasheet
Document overview
- Manufacturer or author: Provided By ALLDATASHEET.COM(FREE DATASHEET DOWNLOAD SITE)
- PDF pages: 40
Technical content
Datasheet sections
- 1 Lighting application design challenge
- 1.1 General light application aspects
- 1.2 Driver signals characteristics
- 1.3 System proposal
- 1.4 Diagnosis check
- 1.4.1 Digital diagnosis
- 1.4.2 Analog diagnosis
- 1.4.3 Serial diagnosis
- 2 SPC56xBx features to cover lighting needs
- 2.2 CTU (Cross Triggering Unit)
- 2.3 ADC (Analog-to-Digital Converter)
- 3 Lighting application example architecture
- 3.1 Hardware architecture
- 3.1.1 Generalities on M0-6
- 3.2 Software Implementation
- 3.2.1 Synchronous diagnosis
- 3.3 Synchronous Analog Diagnosis
- 3.4 Implementation of the synchronous diagnosis
- 4 MCU initialization
- 4.1 Setting up Mode Entry and clocks
- 4.2 DSPI configuration
- 4.4 DMA module
- 4.5 ADC module
- 4.5.1 Check Voltage Battery function
- 4.6 CTU module
- 4.7 Micro Resources summary
Advanced light control and diagnostics using SPC56xBx and SPC56xCx microcontrollers Introduction The members of the SPC56xBx and SPC56xCx families are high performance microcontrollers developed for car body application needs. These devices are especially useful in automotive light management applications and offer features to assist the car body system developer in writing optimized firmware with a very low CPU load. This document offers an interesting example about the interconnection between the eMIOS, CTU, and ADC modules of the SPC56EC74 (one member of the SPC56xB/Cx family) in a lighting application, including the support of circuitry diagnostics, without placing an additional load on the MCU’s CPU. This example is easily applied to each device of the SPC56xB/Cx family.
1 Lighting application design challenge
1.1 General light application aspects
- Lamp power supply variations
- Lamp lifetime Lamp power supply voltage may differ when compared to its nominal value. Figure 1 displays how lamp lifetime depends on power supply voltage. The impact of 5 % overvoltage (630 mV at 12.6 V) on light bulb performance is significant, as indicated by the vertical line in the figure. The light bulb luminous flux grows up to 120 % and the light bulb lifetime is reduced to less than 60 %, when compared to nominal values. Therefore, the lamp power supply voltage should be regulated to the nominal value to maintain lamp lifetime. The most common control technique is the PWM, which can also be used for lamp light beam intensity control.
Figure 1. Lamp light bulb characteristics account when designing a lighting module.
AN4300 Lighting application design challenge
1.2 Driver signals characteristics
The signals that drive the light loads must satisfy the following requirements:
- Capability to drive up to 60 channels with PWM signals
- Capability to drive different load types using PWM signals with different characteristics: – Bulb lamp PWM frequency: ~100 Hz Duty cycle: 50 to 100 % Duty cycle adjustment precision: usually 5 % –L E D PWM frequency: 150 to 200 Hz Duty cycle: 10 % to 100 % (as much as 2 % to 100 % for high efficiency LED) Duty cycle adjustment precision: usually 1–2 % The variation of the duty cycle is performed to maintain constant power on the lamps when the battery voltage changes. The duty cycle variation is based on the following expression: Equation 1 where V ref is the nominal value of the battery voltage Vbat is the actual battery voltage If Vbat ≤ Vref, the duty cycle is equal to 100 %, else the expression is applied. The adaptation of the duty cycle is performed one time per period. A typical battery voltage value for automotive applications is 13.2 V, so if, for example, the application reads a Vbat equal to 16 V, a duty cycle of 68 % applies. When turning the lamp light bulb on, the bulb current applied to a cold filament can reach up to 10 times the rated current. The total current of several lamps causes a significant power supply voltage drop and an increase in the electromagnetic interference (or EMI) emissions. Therefore, it is essential not to drive all lamps together and it is necessary to introduce a delay between each pair of rising edges of the PWM signals (see Figure 3).
1.3 System proposal
In a typical system solution for a light application, the SPC56xB/Cx microcontroller family can manage several power drivers, depending on how the power is managed and the number of channels to be driven. Some devices are driven by an SPI link. Using this link, the application can configure the signals, that are generated inside the driver device, to drive the loads. bat ref V V =δ If Vbat > Vref bat ref V V =δ If Vbat > Vref
Figure 2. This solution is configured with an STMicroelectronics power driver and the Figure 2. System solution for light application an SPI connection to configure the drivers.
1.4 Diagnosis check
in turn, makes it possible to detect faults and react to them in a specified time. protective action to obtain a safe and robust system.
- Digital
- Analog
- Serial The diagnosis types are explained in the following sections. 63, 63, 9EDW 9EDW 'LDJQRVWLF 3:0LQSXWVLJQDOV 63&(& 9UHJ 914 91'([[[ ("1(3*
AN4300 Lighting application design challenge
1.4.1 Digital diagnosis
To read the digital diagnosis it is necessary to read an I/O pin of the driver for each load driven. To read this type of diagnosis the microcontroller has to read the digital pin in polling mode or by connecting this signal to an external interrupt line.
1.4.2 Analog diagnosis
To read the analog diagnosis a current sense pin is available for each load driven. This pin is used to read a proportional current (voltage using a resistor) that flows in the load. Comparing this current with certain thresholds can determine if problems on the load exist. To read the voltage of the current sense pin, an analog-to-digital conversion must be performed. The analog diagnosis has to be read in synchronous mode to the input (PWM) signal which is available after a delay from the rising edge of the input signals. The analog-to-digital conversion has to be triggered with a delay from the rising edge of the input signals to allow the load current to stabilize.
1.4.3 Serial diagnosis
When the power devices provide serial diagnosis, they usually save the type of fault in internal registers. The microcontroller, using the SPI link, then performs a query on the specified register to examine the fault status. The application can perform the following types of diagnosis inspection:
- During T_ON (time when the PWM input signal is switched on) of the input signal – Open-load – Overtemperature – Undervoltage – Short-circuit to GND – Short-circuit to V CC
- During T_OFF (time when the PWM signal is switched off) of the input signal – Open-load – Short-circuit to V CC The digital and serial diagnosis can usually be read asynchronously with respect to the PWM input signals and the diagnosis action can be performed during a noncritical instant of the system cycle. The CPU load used to collect this information is not an important aspect. The analog diagnosis consists of checking the current that flows in the loads. The input signal status must be known to collect diagnosis information in a specific instant of the loads’ activity. The reading of the diagnosis and the input signal must be synchronized to determine the status of the input signal. The input signal is a PWM signal, making it necessary to select if the diagnosis is occurred in the T_ON or T_OFF phase of the input signal. Furthermore, a delay exists between the rising (falling) edge and the instant when the diagnosis read occurs because the current sense signal is stabilized only after a transitory time (about 300 µs).
Figure 3. Light management features that are used to manage the analog diagnosis.
2 SPC56xBx features to cover lighting needs
- eMIOS (enhanced Modular I/O Subsystem)—provides functionality to generate or measure time events and then to generate PWM signals
- CTU (Cross Trigger Unit)—allows triggering analog-to-digital conversion synchronized to a PWM signal
- ADC—allows converting analog signals synchronized to a PWM signal and allows holding the converted value in different register for each ADC channel The three module descriptions are covered in Section 2.1: eMIOS (enhanced Modular Input/Output Subsystem) Section 2.2: CTU (Cross Triggering Unit) and Section 2.3: ADC (Analog-to-Digital Converter). It is also recommended to read the SPC56xBx and SPC56xCx device reference manual see Section Appendix A: Reference documents. The eMIOS channels are connected to event configuration registers of the CTU, where it links an eMIOS trigger to a specified ADC channel conversion (see Figure 4). Inside each event configuration, that is connected in a fixed way to an eMIOS channel, it is possible to write an ADC channel that is triggered when an event from the eMIOS channel arrives.
Figure 4. eMIOS, ADC and CTU interconnection scheme2.1 eMIOS (enhanced Modular Input/Output Subsystem) trigger—using the CTU—an analog-to-digital conversion at a specified point of the period. This is especially suited for lighting applications.
Mode (MC), the A1 register determines the counting period. Figure 5. eMIOS-OPWMT mode
- Internal counter (only for the channels that have this feature)
- Counter bus A driven by UC[23]
- Counter buses B, C, D, E driven by UC[0], UC[8], UC[16], UC[24] In a channel configured in OPWMT mode, the A1 register value defines the PWM leading- edge and the B1 register value defines the PWM trailing edge (duty cycle). The A2 register is the sampling point for diagnostic purposes (the ADC channel trigger using the CTU), and in B2, the buffered value of the trailing edge, which is, on A1 match, loaded into the B1 register (see the eMIOS chapter of the device reference manual see Section Appendix A: Reference documents). When the B2 value equals the A1 value, the PWM duty cycle is 0 %. When a B2 value is higher than the channel period, the PWM duty cycle reaches 100 %. The PWM output signal polarity is dependent on the user’s choice. When configuring channels UC[0], UC[8], UC[16], UC[23] and UC[24] in Modulus Counter (MC) mode, the A1 register determines the counting period.
2.2 CTU (Cross Triggering Unit)
- The CTU channel 0–15 event can trigger any of the ADC channels 0–15
- The CTU channel 32-47 event can trigger any of the ADC channels 32–47
- The CTU channel 48–95 event can trigger any of ADC channels 48–95 For more details, see the Cross Triggering Unit chapter in the device reference manual (see Section Appendix A: Reference documents).
AN4300 SPC56xBx features to cover lighting needs
2.3 ADC (Analog-to-Digital Converter)
The 2 ADC module convert analog signals into digital form; ADC_0 with a 10-bit resolution and ADC_1 with a 12-bit resolution offering normal, injected and trigger-injected modes. The ADC module can be configured to provide up to 62 single-ended input channels with no additional external logic, exapandable to 90 channels using an external multiplexer, all driven by the ADC module logic. When using the SPC56EC74:
- The ADC channels 0–15 correspond to ANP pins 0–15 with a resolution of 10-bit or 12- bit (depending on the choice of ADC_0 (10-bit resolution) or ADC_1 (12-bit resolution); in both cases the used pins are the same (precision channels)
- The ADC_0 channels 32–60 (28 channels) correspond to ANS pins 0–27 (extended channel, medium occurrence) while the ADC_1 channels 32-44 corresponf to ANS pins 0-12
- The ADC channels 64–95 correspond to ANX pins 0–3 (external multiplexer driven by MA0–2 ADC pins; external channel, medium accuracy) For the family SPC56xB/Cxx, 6 + 3 analog watchdogs (6 on 10-bit ADC, 3 on 12-bit ADC) are present on the ADC peripheral. The analog watchdogs provide the capability to generate an interrupt for continuous hardware monitoring to determine if the converted channel value lies within a given guarded area defined by user-specified threshold values. If the converted value lies outside the guarded area, an interrupt is generated. The analog watchdog interrupts are well suited for light bulb diagnostic purposes. With SPC56xB/Cxx devices, the diagnosis value can be collected in hardware mode, thus reducing the load on the CPU for this task. Moreover, one time within an input signal period, a load is placed on the CPU when these values collected in hardware mode are checked and when they are compared to certain thresholds. The analog watchdog feature can reduce this CPU load by triggering an interrupt only when a fault occurs, instead of one time for the period, because the diagnosis check is performed in automatic mode.
3 Lighting application example architecture
Figure 6. Lighting application—example system concept is written in C language using the Green Hills compiler.
- Minimal microcontroller resources required
- Low Interrupt and CPU load
- Minimized usage of Memory resources
- Few ADC channels and pins needed The example application code has been implemented using the M0-6 Mother board for Power PC applications connected with the SPC56EC74L7 minimodule and the EVB using the J1 connector on the board following the connection reported in Figure 6. and in Figure 7.
Figure 7. SPC56EC74L7 Minimodule + M0-6 Board
3.1 Hardware architecture
- The same DSPI channel (DSPI_0) to drive all the M0-6 devices
- A dedicated chip select for each M06 device
- A PWM channel (EMIOS Channel) shared for all M06 devices to provide a common time base (M06 Clock)
- Four eMIOS channels configured in SAIC to manage the trigger signals
- An ADC channel for each M06 device shared for the four channels inside the same M06 device.
3.1.1 Generalities on M0-6
- VNQ6040S
- VNQ6004S These devices are made using STMicroelectronics VIPower technology. They are intended for driving resistive or inductive loads directly connected to ground. Devices are protected against voltage transient on Vcc pin. Programming, control and diagnostics are
Lighting application example architecture AN4300 implemented via the SPI Bus through the dedicated pins. Each device offers four channels that can drive different loads in term of power.
3.2 Software Implementation
The software implements the following features: Support of the SPI configuration of 16 channel of four M06 Adapt the PWM signal to drive the loads to the V_bat variations Collect the current sense values for each channel and for each period Low CPU load to collect the Current Sense The code allows to initialize the configuration of M06 devices and at the beginning of each period (10 msec) performs the following steps: Vbat Measurement via ADC Duty cycle update for all channels of M06 devices SPI frame for new information configuration Digital diagnosis on all M06 devices
3.2.1 Synchronous diagnosis
Figure 8 and Figure 9 represent the initial configuration of the Microcontroller and the Vbat measurement strategy in order to update the duty-cycle of the PWM signal.
Figure 8. Initial Configuration flowchart
Figure 9. Vbat measurement and duty-cycle update flowchart
3.3 Synchronous Analog Diagnosis
The reading of the current sense is done in a synchronous way with the M06 output signals. synchronized with the outputs of the M06 device.
Figure 10. Delay between the CS_Sync and Output channel/Current Sense signal active channel, by an internal timer expiration (e.g. 10 msec) of the micro in the latter.
- When in PWM mode, the CS_Sync signals is used to trigger the ADC conversion of the Current Sense of a channel after a 300 usec delay from its rising edge.
- The End of Conversion of the ADC activates a DMA channel that transfers the ADC value from the peripheral register to a SRAM location.
- At the end of a period all Current Sense are available to the same memory structure.
3.4 Implementation of the synchronous diagnosis
- A Channel of the eMIOS is configured as Input Capture
- The arrival of the input signal on the Input Capture triggers a DMA transfer intended to trigger a second eMIOS channel previously configured as SAOC (Single Action Output Compare mode) counting 300 usec
- The SAOC End of Counting event triggers another eDMA transfer triggering the ADC conversion. After the conversion the following action are performed:
- The end of ADC conversion triggers a DMA transfer moving the ADC values to a buffer in RAM.
- Via channel linking, a DMA transfer sends an SPI frame to a given M0-6 in order to link the multiplexer to the next current sense/CS_Sync.
4 MCU initialization
4.1 Setting up Mode Entry and clocks
This module enables clocks to all peripherals and sets the 12 MHz bus clock using the PLL. Figure 11. MC_Mode_Init function7
Figure 12. PLL initialization function source of 12MHz starting from an external oscillator of 40 MHz.
4.2 DSPI configuration
The following function allows to initialize the DSPI module used for the SPI transmission.
- Pad PA[12] as DSPI_0 SIN (Serial input)
- Pad PA[13] as DSPI_0 SOUT (Serial output)
- Pad PA[14] as DSPI_0 SCK (Serial Communication Clock)
- Pad PA[15] as DSPI_0 PCS0 (Peripheral Chip Select_0)
- Pad PF[10] as DSPI_0 PCS1 (Peripheral Chip Select_1)
- Pad PF[11] as DSPI_0 PCS2 (Peripheral Chip Select_2)
- Pad PE[06] as DSPI_0 PCS3 (Peripheral Chip Select_3) The CTAR register defines the following parameters:
- Set Double Baud rate disabled
- Frame size equal to 16
- Baud Rate Prescaler value equal to 3
- Baud Rate Scaler equal to 4
- Delay after Transfer Scaler equal to 32
- PCS to SCK delay prescaler equal to 7
Figure 13. DSPI master init function
- Set PCR[1] as E0UC[1] using PA[1]
- Set PCR[89] as E1UC[1] using PF[9]
- Set PCR[112] as E1UC[2] using PH[0]
- Set PCR[92] as E1UC[25] using PF[12]
- Set PCR[93] as E1UC[26] using PF[13]
- Set PCR[104] as E1UC[17] using PG[8]
- Set PCR[105] as E1UC[18] using PG[9]
Figure 16. eMIOS_0 configuration code to give the PWM clock to M06 devices. M06 devices work in DC mode. M06_3. Internally it triggers DMA_MUX 21. M06_4. Internally it triggers DMA_MUX 22. M06_1. Internally it triggers DMA_MUX 23. M06_2. Internally it triggers DMA_MUX 24.
4.4 DMA module
transfer, by SPI, the configuration to M06 devices about the PWM waves generation. read and PWM configuration is needed. Figure 21. Init DMA Vbat function 0 and 1 and for the DMA channel 6.
Figure 22. SPI_Vbat_SetTCD function
- DMA CH0, CH7, CH8 and CH9 are configured to trigger the start counter of the eMIOS0_CH1 when the SYNC_MUX comes from M06_1, M06_2, M06_3 and M06_4 respectively.
- DMA CH1 is configured to trigger the stop of counter of the eMIOS0_CH1
- DMA CH1 is linked to DMA CH2. In this way when the CH1 finishes it starts the DMA CH2 transmission which allows the start of the ADC conversion.
- DMA CH5 is configured to send, by SPI, the configuration to the MUX for the active M06 to select the right channel connected to the CS and with CS_SYNC.
- DMA CH4 is configured to transfer the value of the 4 Data Registers relative to the 4 ADC channels linked to the 4 M06 to a buffer in the memory, This is done each trigger because it is necessary to read all ADC channels that can trigger DMA transfers.
- DMA CH10 is configured to transfer the value converted by ADC to the final RAM structure. The scatter gather feature is used to change the TDC to adapt the ADC Data Register and Memory location relative to the M06 Channel selected.
Figure 23. initDMA_1 function part 1
Figure 24. initDMA_1 function part 2
Figure 25. init DMA_1 function part 3
4.5 ADC module
Conversion interrupt is set on this channel. (connected to eMIOS1_CH2) will trigger the ADC_0 CH0 to convert the Vbat.
Figure 26. ADC init function
Figure 27. ADC_0 CH0 EoC interrupt service routine
4.5.1 Check Voltage Battery function
by the CTU and only for the ADC0_CH0. to read the diagnosis is given manually with the same period used to read the Vbat. the M06 devices are configured in PWM mode with Duty Cycle based on the above relation. devices using the SPI connection.
Figure 28. Check Voltage Battery function part1
Figure 29. Check Voltage Battery function part2
4.6 CTU module
Figure 30. bctu_init function
4.7 Micro Resources summary
Table 1. Resources allocated on the microcontroller
10 DMA channels used
5 Conclusion
The SPC56EC74 lighting application example introduces MCU eMIOS, CTU, and ADC modules usage within a lighting application, which is in this case well suited for the lamp light bulbs control as well as for the lamp LEDs control with no major change required in the peripheral’s software. The benefit of using the CTU module is significant as opposed to using the timer to trigger ADC at a certain point within a PWM channel cycle. The timer produces frequent interrupts that need to be processed by the MCU CPU, causing an increase in the CPU load and suspending run time processes. Using the CTU gives the application designer a powerful tool to avoid diagnostic timer-configuration challenges and makes the lighting application simpler to design and test. The ADC module gives the designer the opportunity to use watchdog threshold interrupts to increase MCU performance, and enables fast responses in case of lamp light bulb failures. If required, the number of the ADC channels can be increased from 64 up to 95, using simple external logic circuitry fully controlled by the ADC module. The eMIOS module offers up to 64 PWM channels suitable for a lighting application as well as for other PWM-based applications. The eMIOS module provides PWM channels with high resolution and flexibility. The lighting application example consists of an example description and complete software demonstration based on the SPC56EC74L7 LQFP176 minimodule and EVB. This example is easily portable to each device of the SPC56xB/Cxx family; for devices which have DMA module, no particular modifications are required. For devices where DMA module is missing, the DMA feature can be replaced with interrupt routines but with a higher CPU load.
- SPC560B4x, SPC560B5x, SPC560C4x, SPC560C5x, 32-bit MCU family built on the embedded Power Architecture® (RM0017), available at www.st.com
- SPC564Bxx, SPC56ECxx 32-bit MCU family built on the embedded Power Architecture® (RM0070 DOC ID18196) A.2 Acronyms
Table 2. Acronyms
Revision history
Table 3. Document revision history 17-Sep-2013 2 Updated Disclaimer.