DRM157, Light Control Module Reference Design based on Kinetis EA MCU and Q ...

Light Control Module Reference
Design based on Kinetis EA MCU and
Quad High-side Switch
(MC10XS3425)
Document Number: DRM157
Rev 0, 02/2015
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
2
Freescale Semiconductor, Inc.
Contents
Section number
Title
Page
Chapter 1
Introduction
1.1 Introduction.......................................................................................................................................................................5
Chapter 2
Kinetis EA Series
2.1 Kinetis EA.........................................................................................................................................................................7
Chapter 3
Hardware Design
3.1 System concept................................................................................................................................................................. 9
3.2 Board diagram...................................................................................................................................................................11
3.3 Quad high-side switch.......................................................................................................................................................11
3.3.1 Introduction............................................................................................................................................................ 11
3.3.2 MC10XS3425 device features............................................................................................................................... 12
3.3.3 SPI protocol description.........................................................................................................................................12
3.3.4 Logic, commands and registers..............................................................................................................................13
3.3.4.1 Serial input communication..................................................................................................................... 13
3.3.4.2 Serial Output Communication (Device Status Return Data)................................................................... 14
Chapter 4
Software
4.1 Software description......................................................................................................................................................... 17
4.2 Functions description........................................................................................................................................................ 18
4.3 Software logic flow...........................................................................................................................................................25
Chapter 5
Application Control
5.1 FreeMASTER tool............................................................................................................................................................ 27
5.2 FreeMASTER graphical user interface.............................................................................................................................27
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
3
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
4
Freescale Semiconductor, Inc.
Chapter 1
Introduction
1.1 Introduction
This document is used to introduce the technical implementation for Light Control
Module Reference Design (LCM).
The LCM system uses Kinetis EA series Microcontroller (MCU) to control and diagnose
up to four automotive lamps, using a quad high-side driver eswitch. Control signals are
mainly from switches; and a potentiometer to control the brightness bulbs. The LCM
system also includes a user graphical interface using FreeMASTER. This user interface
controls the light intensity of the lamps connected to the light output connector, turns the
lamps on/off /toggles them, and it is also used to check faults in the system.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
5
Introduction
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
6
Freescale Semiconductor, Inc.
Chapter 2
Kinetis EA Series
2.1 Kinetis EA
The Kinetis EA Series MCUs for Automotive is a highly scalable portfolio of 32-bit
ARM® Cortex®-M0 based processors and MCUs aimed for the automotive markets. The
family is optimized for cost-sensitive applications offering low pin-count option with
very low power consumption. With 2.7-5.5 V supply and focus on exceptional EMC/ESD
robustness, Kinetis EA series devices are well suited to a wide range of applications
ranging from body applications to generic sensor nodes. In automotive body application,
the Kinetis EA Series MCUs for Automotive is a great option for entry level body
controller or gateway module, window/roof/sun-roof controller, immobilizer or seat/
mirror controller just to mention a few.
Many modules are available on KEA128 including ARM Cortex-M0+ core based
processors, system module such as SIM/PMC/WDOG/AIPS/BME/MCM, memories such
as up to 128 KB flash memory and up to 8 KB SRAM, Clocks, ADC, Timers such as
RTC/PIT/FTM, communication modules such as UART/SPI/I2C/CAN and HMI module.
LCM system uses SPI to communicate with E-switch, the ADC module to sample the
signal from the potentiometer, and the KBI module to read button states. It also includes
LIN and CAN transceivers for Automotive Network communications.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
7
Kinetis EA
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
8
Freescale Semiconductor, Inc.
Chapter 3
Hardware Design
3.1 System concept
The LCM system is designed to control up to 4 lamps using the KEA128 and a quad
high-side driver eswitch (MC10XS3425). The system board has the following features:
• ARM Cortex-M0 based Kinetis KEA128 and automotive microcontroller in 64
LQFP package.
• MC10XS3425EK Quad High-side Switch.
• Output Connector to connect up to 4 Lamps.
• MC33662 LIN transceiver.
• MC33901 CAN transceiver.
• 4 User LEDs
• 4 Potentiometers
• 4 User buttons
• SWD connector interface for debugging and communication with FreeMASTER.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
9
System concept
Figure 3-1. System block diagram
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
10
Freescale Semiconductor, Inc.
Chapter 3 Hardware Design
3.2 Board diagram
Figure 3-2. Board diagram
3.3 Quad high-side switch
3.3.1 Introduction
The 10XS3425 is one in a family of devices designed for low-voltage automotive lighting
applications. Its four low RDS(on) MOSFETs (dual 10 mΩ/dual 25 mΩ) can control four
separate 55 W / 28 W bulbs, and/ or Xenon modules, and/or LEDs.
Programming, control, and diagnostics are accomplished using a 16-bit SPI interface. Its
output with selectable slew-rate improves electromagnetic compatibility (EMC) behavior.
Additionally, each output has its own parallel input or SPI control for pulse-width
modulation (PWM) control if desired. The 10XS3425 allows the user to program via the
SPI the fault current trip levels and duration of acceptable lamp inrush.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
11
Quad high-side switch
The four channels can be controlled individually by external/internal clock-signals or by
direct inputs. Using the internal clock allows fully autonomous device operation.
Programmable output voltage slew rates (individually programmable) helps improve
EMC performance. To avoid shutting off the device upon inrush current, while still being
able to closely track the load current, a dynamic overcurrent threshold profile is featured.
Switching current of each channel can be sensed with a programmable sensing ratio.
Whenever communication with the external microcontroller is lost, the device enters a
fail-safe operation mode, but remains operational, controllable, and protected.
3.3.2 MC10XS3425 device features
• Four protected 10 mΩ and 25 mΩ high side switches
• Operating voltage range of 6.0 to 20 V with sleep current < 5.0 μA, extended mode
from 4.0 to 28 V
• 8.0 MHz 16-bit 3.3 V and 5.0 V SPI control and status reporting with daisy chain
capability
• PWM module using external clock or calibratable internal oscillator with
programmable outputs delay management
• Smart overcurrent shutdown, severe short-circuit, over-temperature protections with
time limited auto-retry, and fail-safe mode in case of MCU damage
• Output OFF or ON open-load detection compliant to bulbs or LEDs and short-tobattery detection. Analog current feedback with selectable ratio and board
temperature feedback.
Freescale analog ICs are manufactured using the SMARTMOS process, a combinational
BiCMOS manufacturing flow that integrates precision analog, power functions and dense
CMOS logic together on a single cost-effective die.
3.3.3 SPI protocol description
The SPI interface has a full duplex, three-wire synchronous data transfer with four I/O
lines associated with it: Serial Input (SI), Serial Output (SO), Serial Clock (SCLK), and
Chip Select (CSB).
The SI/SO pins of the MC10XS3425 follow a first-in first-out (D15 to D0) protocol, with
both input and output words transferring the most significant bit (MSB) first. All inputs
are compatible with 5.0 or 3.3 V CMOS logic levels.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
12
Freescale Semiconductor, Inc.
Chapter 3 Hardware Design
Figure 3-3. Single 16-Bit Word SPI communication
3.3.4 Logic, commands and registers
3.3.4.1 Serial input communication
To communicate to the MC 10XS3425 device it is necessary to send a 16-bit command
using SPI. A message is transmitted by the KEA128 starting with the MSB D15 and
ending with the LSB, D0. MC 10XS3425 commands are listed in the table below.
Table 3-1. Serial input commands1
SI
Register
SI Data
D15
D14
D13 D12
D11
D10
D9
D8
D7
D6
D5
D4
D3
STATR_s
WIN
D
X
X
0
0
0
0
0
0
0
0
SOA4 SOA3 SOA2 SOA2 SOA0
PWMR_s
WIN
D
A1
A0
0
0
1
0
28W_ ON_s PWM PWM PWM PWM PWM PWM PWM
s
6_s
5_s
4_s
3_s
2_s
1_s
0_s
CONFR0_ WIN
s
D
A1
A0
0
1
0
0
0
0
0
CONFR1_ WIN
s
D
A1
A0
0
1
1
0
0
0
Retry Retry OS_d OLO OLO OLLE CSN
_unli _dis_ is_s N_dis FF_di D_en S_rati
mited s
_s
s_s
_s
o_s
_s
OCR_s
A1
A0
1
0
0
0
Xeno BC1_ BC0_ OC1_ OC0_ OCHI OCL OCL OC_
n_s
s
s
s
s
_s
O1_s O0_s mode
_s
WIN
D
D2
D1
D0
DIR_ SR1_ SR0_ DELA DELA DELA
dis_s s
s
Y2_s Y1_s Y0_s
Table continues on the next page...
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
13
Quad high-side switch
Table 3-1. Serial input commands1 (continued)
SI
Register
SI Data
GCR
WIN
D
0
0
1
0
1
0
VDD_ PWM CLO TEM CSN CSN
FAIL_ _en
CK_s P_en S_en S1
en
el
CSN
S0
X
OV_d
is
CALR
WIN
D
0
0
1
1
1
0
1
0
1
0
1
1
0
1
1
0
0
X
X
X
0
0
0
0
0
0
0
0
0
0
Register
0
state after
RST=0 or
VVDD or
VSUPPLY(P
OR)Conditi
on
1. x=Don't care
The first column is the name of registers, and registers ending with a 's' means there are
four of them each representing one channel. The table below shows bit assignment of the
command.
Table 3-2. Serial input command bit assignment
Bit significance
MSB
LSB
SI msg bit
Message bit description
D15
Watchdog in:toggles to satisfy Watchdog
requirements.
D14:D13
Register adddress bits used in some
cases for input selection.
D12:D10
Register address bits.
D9
Not used (set logic [0]
D8:D0
Used to configure the inputs,outputs,
and the device protection feature and
SO status content.
3.3.4.2 Serial Output Communication (Device Status Return Data)
SO data will represent information ranging from fault status to register contents, user
selected by writing to the STATR bits OD4, OD3, OD2, OD1, and OD0. The value of the
previous bits SOA4 and SOA3 will determine which output the SO information applies to
for the registers, which are output specific, that is, Fault, PWMR, CONFR0, CONFR1,
and OCR registers.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
14
Freescale Semiconductor, Inc.
Chapter 3 Hardware Design
Note that the returned status data is based on the previous STATR_S command, so if a
specific register needs to be read, it is needed to send two STATR_S commands. The first
command is to tell the MC 10XS3425 which register is requested, and the second
command is to retrieve the requested data.The returned data format is shown in the
following table.
Table 3-3. Serial out status data
Previous STATR
SO SO SO SO SO
A4 A3 A2 A1 A0
SO Returned Data
OD
15
OD
14
OD
13
OD
12
OD
11
OD
10
OD
9
OD
8
OD
7
OD
6
OD
5
OD
4
OD
3
OD
2
OD
1
OD
0
UV
OV
OL
ON
_s
OL OS_ OT_ SC_ OC
OFF s
s
s
_s
_s
STA A1
TR_s
A0
0
0
0
WDI SO
N
A4
SO
A3
SO
A2
SO
A1
SO
A0
NM PO
R
PWM A1
R_s
A0
0
0
1
WDI SO
N
A4
SO
A3
SO
A2
SO
A1
SO
A0
NM 28 ON
W_s _s
PW PW PW PW PW PW PW
M6_ M5_ M4_ M3_ M2_ M1_ M0_
s
s
s
s
s
s
s
CON A1
FR0_
s
A0
0
1
0
WDI SO
N
A4
SO
A3
SO
A2
SO
A1
SO
A0
NM X
X
X
CON A1
FR1_
s
A0
0
1
1
WDI SO
N
A4
SO
A3
SO
A2
SO
A1
SO
A0
NM X
X
Retr Retr OS_ OL OL
y_u y_di dis_ ON OFF
nlim s_s s
_dis _dis
ited
_s _s
_s
OCR A1
_s
A0
1
0
0
WDI SO
N
A4
SO
A3
SO
A2
SO
A1
SO
A0
NM Xen BC1 BC OC OC OC OC OC OC
on_ _s O_s 1_s 0_s HI_ LO1 LO0 _mo
s
s
_s _s de_
s
GCR 0
0
1
0
1
WDI SO
N
A4
SO
A3
SO
A2
SO
A1
SO
A0
NM VD PW CL TE CS CS CS X
D_F M_e OC MP NS_ NS1 NS0
AIL n
K_s _en en
_en
el
DIAG 0
R0
0
1
1
1
WDI SO
N
A4
SO
A3
SO
A2
SO
A1
SO
A0
NM X
X
X
X
X
DIAG 0
R1
1
1
1
1
WDI SO
N
A4
SO
A3
SO
A2
SO
A1
SO
A0
NM X
X
X
X
IN3 IN2 IN1 IN0 WD
_en
DIAG 1
R2
0
1
1
1
WDI SO
N
A4
SO
A3
SO
A2
SO
A1
SO
A0
NM X
X
X
X
X
X
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Regi N/A N/A N/A N/A N/A 0
ster
state
after
RST
=0
VDD(F
AIL) or
Vsuppl
0
X
DIR SR1 SR0 DEL DEL DEL
_dis _s _s AY2 AY1 AY0
_s
_s _s _s
X
CL
OC
K_f
ail
OLL
ED_
en_
s
CS
NS_
ratio
_s
OV_
dis
CAL OT
_fail W
y(POR)
condi
tion
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
15
Quad high-side switch
The 10XS3425 enters in Normal mode after start-up if following sequence is provided:
• VPWR and VDD power supplies must be above their under voltage thresholds,
• generate wake-up event (wake-up = 1) from 0 to 1 on RSTB. The device switches to
Normal mode with the SPI register content reset (as defined in Table 3-1 and Table
3-3). All features of the 10XS3425 will be available after 50 µs (typical), and all SPI
registers are set to default values (set to logic [0]).
• Toggle WD bit from 0 to 1.And, in case the PWM module is used (PWM_en bit is
set to logic [1]) with an external reference clock.
• Apply the PWM clock on the IN0 input pin after a maximum of 200 µs (min. 50 µs).
If the correct start-up sequence is not provided, the PWM function is not guaranteed.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
16
Freescale Semiconductor, Inc.
Chapter 4
Software
4.1 Software description
This software demonstrates the functionality of the KEA128LEDLIGHTING board.
The software communicates the KEA128 with the MC10XS3425 eswitch via SPI, to
control the duty cycle of the eswitch outputs, and to receive faults that occur in the
system. SPI0 is configured in master mode, with automatic chip select, CPHA =1 and
CPOL =0. SPI0 is set to work on KEA128 pins PTE0, PTE1, PTE2, and PTE3.
Faults detected by eswitch will be reported to the KEA128 via SPI. The KEA128 shows
the faults in the system via the FreeMASTER interface.
In case of an under voltage fault, the system will turn off. In the next time, when the
system is on, the LED on PTB5 will turn on, indicating that an under voltage fault has
occurred and the outputs will be off. To clear the under voltage fault to return the system
to its normal operation, press any SW2-5 or click in "Clear Under Voltage Fault" button
in FreeMASTER.
NOTE
When an under voltage fault occurred, communication with the
board and FreeMASTER will be lost. To reestablish
communication, stop the FreeMASTER communication and
start it again once the board has recovered from the under
voltage condition.
After the under voltage fault is removed, the LED on PTB5 will turn off and the system
will return to its normal operation.
Potentiometers are connected to ADC channels 12-15 to update the PWM duty cycle of
the eswitch outputs. Each potentiometer modifies one duty cycle of the eswitch output.
ADC is configured with 8-bit resolution and uses software trigger to read the voltage
from the potentiometers.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
17
Functions description
Based on the ADC value read by each potentiometer the duty cycle value will be send to
the eswitch via an SPI command, and the duty cycle will be updated. The duty cycle of
the outputs can be also changed with the sliders in the FreeMASTER interface.
Board switches, SW2-5, are connected to KBI 1 channels 16-19 of the KEA128. Each
switch controls one output state. KBI is configured to enable channels 16-19 and to
generate an interrupt on the falling edge.
Every time that one of these switches is pressed an interrupt will be generated. When a
switch is pressed the corresponding output will change their state to toggle, turn ON or
turn OFF the lamp. This output state can be also modified using the "Output Control"
button in the FreeMASTER interface.
The RTC is configured to generate an interrupt every 500 ms. This interrupt determines
the period at which the outputs will toggle in case they are in the toggle state. Also an
LED on PTB2 will toggle at this period to indicate that the KEA128 is working.
4.2 Functions description
Functions inside the software are divided by Kinetis EA peripherals, MC10XS3425
driver library, and lighting application functions.
The Kinetis EA peripherals functions are in the following files: ADC.c, CLK.c, GPIO.c,
KBI.c, RTC.c, and SPI.c. These files contain functions to initialize and use each
peripheral. Below is a description of the peripheral functions.
ADC
ADC_Init(uint8_t mode). Initialize ADC module. ADC is configured in continuous
mode operation, trigger by software and bus clock selected for ADC.
Received parameter: ADC desired resolution, 8-,10-,12-bit mode.
Return value: none.
uint16_t ADC_Read(uint8_t channel). Reads ADC selected channel.
Received parameter: ADC channel to read.
Return value: ADC conversion value.
Enable_ADC_CH(channel). This macro enables desired ADC channel.
Received parameter: ADC channel to enable.
Return value: none.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
18
Freescale Semiconductor, Inc.
Chapter 4 Software
CLK.
Clk_Init( ). Initialize the clocks to run at 20 MHz from the 8 MHz external XTAL
Received parameter: none
Return value: none
GPIO
GPIO_Init(). Initialize pin PTB2-5 as outputs.
Received parameter: none
Return value: none
KBI
KBI_Init(). Initialize KB1 1 module. Enables KBI channels 16, 17, 18, and 19. Polarity
set to falling edge
Received parameter: none.
Return value: none.
KBI_SetCallback(pt2FuncU8 ptr). Set a callback function to execute on a falling edge
of an enabled KBI pin
Received parameter: pointer to function with an UINT8 argument.
Return value: none
KBI1_IRQHandler(). KBI interrupt routine, calls the user callback.
Received parameter: none.
Return value: none.
RTC.
RTC_Init(). Initialize RTC counter to generate an interrupt every 500 ms.
Received parameter: none.
Return value: none.
RTC_SetCallback (pt2FuncU8 ptr). Set the callback function to call on successful
matches from any channel
Received parameter: pointer to function with an UINT8 argument.
Return value: none.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
19
Functions description
RTC_IRQHandler(). RTC interrupt routine, calls the user callback.
Received parameter: none.
Return value: none.
SPI.
SPI_Init(). Configures SPI0 on pins PTE0, PTE1, PTE2, and PTE3. SPI is configured in
master mode, with automatic chip select, CPHA =1 and CPOL =0.
Received parameter: none
Return value: none
uint8_t SPI_Read(). Reads SPI data once the buffer is full.
Received parameter: none
Return value: SPI received data.
SPI_Write(uint8_t data). Send SPI data once buffer is empty.
Received parameter: data to be send via SPI
Return value: none.
The MC10XS3425 library is located in the eswitch.c file. This field contains the
functions related to initialize, reset, disable PWM, enable PWM, send commands, read
registers status, turn on and turn off switch outputs. Below is a description of the
functions included in the switch file.
eswitch.
reset_es(). Reset eswitch device.
Received parameter: ECMD structure.
Return value: none.
eswitch_init(). Initialize eswitch. Calls SPI_Init(), to set up an SPI communication of
9600 baud rate. Calls pwm_enable() to enable PWM in eswitch.
Received parameter: ECMD structure.
Return value: none.
send_cmd(ECMD _ecmd). Send command to eswitch.
Received parameter: ECMD structure.
Return value: none.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
20
Freescale Semiconductor, Inc.
Chapter 4 Software
ECMD read_status(ECMD _ecmd). Read eswitch status.
Received parameter: ECMD structure.
Return value: ECMD structure.
pwm_enable( ). Enable PWM in eswitch.
Received parameter: none.
Return value: none.
pwm_disable( ). Disable PWM in eswitch
Received parameter: none.
Return value: none.
light_on(uint8_t ch). Turn on eswitch channel.
Received parameter: channel to turn on as a parameter. Ch value must be between 0-3.
Return value: none.
light_off(uint8_t ch). Turn off eswitch channel.
Received parameter: channel to turn on as a parameter. Ch value must be between 0-3.
Return value: none.
light_pwm_on(uint8_t ch, uint8_t lvl). Turn on using PWM in eswitch channel.
Received parameter: receives eswtich channel to turn on, duty cycle of the PWM as
parameters. Ch value must be between 0-3. Lvl value must be between 0-128.
Return value: None
ECMD read_statr(uint8_t ch). Read status register from switch.
Received parameter: eswitch channel to read status register
Return value: ECMD structure with status register value
ECMD read_pwmr(uint8_t ch). Read PWM register from eswitch
Received parameter: eswitch channel to read PWM register
Return value: ECMD structure with PWM register value
ECMD read_gcr(void). Read global configuration register from eswitch.
Received parameter: none.
Return value: ECMD structure with global configuration register value.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
21
Functions description
ECMD read_cnfr0(uint8_t ch). Read configuration register 0 from eswitch.
Received parameter: eswitch channel to read configuration register 0.
Return value: ECMD structure with configuration register 0 value.
ECMD read_cnfr1(uint8_t ch). Read configuration register 1 from eswitch.
Received parameter: eswitch channel to read configuration register 1.
Return value: ECMD structure with configuration register 1 value.
ECMD read_ocr(uint8_t ch). Read overcurrent register from switch.
Received parameter: eswitch channel to overcurrent register.
Return value: ECMD structure with overcurrent register value.
ECMD read_diagr0(uint8_t ch). Read diagr0 data.
Received parameter: eswitch channel to diagr0.
Return value: ECMD structure with diagr0 value.
ECMD read_diagr1(uint8_t ch). Read diagr1 data.
Received parameter: eswitch channel to diagr1.
Return value: ECMD structure with diagr1 value.
ECMD read_diagr2(uint8_t ch). Read diagr2 data.
Received parameter: eswitch channel to diagr2.
Return value: ECMD structure with diagr2 value.
Functions related to the system application are located in the Ligthing_Applications.c
file. This file contains the functions that check for faults in the outputs, check for under
voltage fault, update PWM output duty cycle based on potentiometers or FreeMASTER
interface, and output states based on board switches and FreeMASTER interface. Below
is a description of the functions included in the Lighting_Applications file.
Lighting_Applications
Read_Status_Ch0(void). Read the status register to check faults on Ch0
Received parameter: none.
Return value: none.
Read_Status_Ch1(void). Read the status register to check faults on Ch1
Received parameter: none.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
22
Freescale Semiconductor, Inc.
Chapter 4 Software
Return value: none.
Read_Status_Ch2(void). Read the status register to check faults on Ch2
Received parameter: none.
Return value: none.
Read_Status_Ch3(void). Read the status register to check faults on Ch3
Received parameter: none.
Return value: none.
Check_Under_Voltge_Fault(void). Checks if an under voltage fault is generated
Received parameter: none.
Return value: none.
Update_Duty_Cycles_Pot(void). Updates the duty cycle array based on the
potentiometers
Received parameter: none.
Return value: none.
Update_Ch0_State(void). Updates state of CH0 based on button state, and update PWM
duty_cycle of CH0
Received parameter: none.
Return value: none.
Update_Ch1_State(void). Updates state of CH1 based on button state, and update PWM
duty_cycle of CH1
Received parameter: none.
Return value: none.
Update_Ch2_State(void). Updates state of CH2 based on button state, and update PWM
duty_cycle of CH2
Received parameter: none.
Return value: none.
Update_Ch3_State(void). Updates state of CH3 based on button state, and update PWM
duty_cycle of CH3
Received parameter: none.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
23
Functions description
Return value: none.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
24
Freescale Semiconductor, Inc.
Chapter 4 Software
4.3 Software logic flow
Start
System init
Init eswitch, GPIO KBI,RTC, ADC
No
Under Voltage
fault occurred?
Under Voltage
fault cleared?
Yes
No
Read output status
to check for faults
Yes
Read switch state
FreeMASTER
PWM control
ON?
Yes
Update output
PWM duty cycle by
FreeMASTER slider
No
Update output
PWM duty cycle by
potentiometer
Send command to
eswitch
End
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
25
Software logic flow
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
26
Freescale Semiconductor, Inc.
Chapter 5
Application Control
5.1 FreeMASTER tool
The FreeMASTER run-time debugging tool is used to control the application and monitor
application variables during run-time. The document KEA128LEDLIGHTRD Quick start
Guide, available at freescale.com, contains information on how to set up the
FreeMASTER application in order to control the reference design application.
5.2 FreeMASTER graphical user interface
The following figure shows and explains how to use the FreeMASTER user interface to
control the reference design application.
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
Freescale Semiconductor, Inc.
27
FreeMASTER graphical user interface
FreeMASTER PWM Control Button
States: ON/OFF
If PWM control is ON, output PWM duty cycle will be
updated by FreeMASTER slider. If PWM control is
OFF output PWM duty cycle will be updated by
potentiometer.
Normal Mode Label
When system is working in normal mode, label will
turn red.
Fault Status Label
When an over voltage fault or an under voltage
fault has occurred, label will turn red.
Over Voltage Label
When an over voltage fault has occurred, label
will turn red.
Under Voltage Label
When an under voltage fault has occurred, label
will turn red.
Clear Under Voltage Fault Button
When an under voltage fault has occurred, click
the button to return the system to its normal mode.
Output Control Button
States: OFF/ON/TOGGLE
Turn OFF, ON, or TOGGLE the output connected to
channel x.
Short Circuit Label
When a short circuit fault has occurred in output
channel x, label will turn red.
PWM Duty Cycle Slider
Change PWM duty cycle for output channel x. Slider
updates duty cycle only if FreeMASTER PWM control
is ON.
Output Vpwr Label
When an output to Vpwr fault has occurred in output
channel x, label will turn red.
Overcurrent Label
When an overcurrent fault has occurred in output
channel x, label will turn red.
Open Load[ON] Label
When an open load in ON state fault has occurred in
output channel x, label will turn red.
Open Load[OFF] Label
When an open load in off state fault has occurred in
output channel x, label will turn red.
Figure 5-1. FreeMASTER user interface
Light Control Module Reference Design based on Kinetis EA MCU and Quad High-side Switch
(MC10XS3425), Rev. 0, 02/2015
28
Freescale Semiconductor, Inc.
How to Reach Us:
Home Page:
freescale.com
Web Support:
freescale.com/support
Information in this document is provided solely to enable system and
software implementers to use Freescale products. There are no express
or implied copyright licenses granted hereunder to design or fabricate
any integrated circuits based on the information in this document.
Freescale reserves the right to make changes without further notice to
any products herein.
Freescale makes no warranty, representation, or guarantee regarding
the suitability of its products for any particular purpose, nor does
Freescale 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 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 does not convey any license
under its patent rights nor the rights of others. Freescale sells products
pursuant to standard terms and conditions of sale, which can be found
at the following address: freescale.com/SalesTermsandConditions.
Freescale, the Freescale logo, and Kinetis are trademarks of Freescale
Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. ARM and Cortex are
registered trademarks of ARM Limited (or its subsidiaries) in the EU
and/or elsewhere. All other product or service names are the property of
their respective owners.
© 2015 Freescale Semiconductor, Inc.
Document Number DRM157
Revision 0, 02/2015