Infineon's high side chip is one of the BTS series. The high side switch is controlled by SPI, so it's not troublesome to record.
1, Overall characteristics
1. One chip supports four high side switch channels, two channels of input IO, and these two channels support PWM input.
2.8-bit spi communication, with the maximum working frequency of 3MHZ, is generally used with the 12V high side switch of the vehicle, such as lighting, indicator light, heating, etc. there are two load control modes: bulbs and LEDS.
3. The voltage range of control switch is 5.5-28V, and the logic level is 3.8-5.5V.
4. Provide common protection and diagnosis functions of vehicles.
5.block diagram, as shown in the figure below, mainly includes spi interfaces and four outputs
6. Mode. The five modes mainly use operational to control the switch.
After power on, enter stand by, then register OUT.OUTn to 1, enter Ready mode, and then dcr.mux= 111 can enter the normal mode.
2, SPI communication
spi communication is an 8-bit unique register. Generally, it's OK to pay attention to a few points for communication with muc. Of course, the specific spi communication has to look at other people's articles, not the core of this article. This time, I use NXP automotive MCU chip.
1. Clock frequency configuration bit communication frequency involves baud rate configuration
/* DBR =0 BR=8 PBR=5 FP=40MHZ BUAD= (40/5)*[(1+0)/8]=1M*/ SPI_2.MODE.CTAR[0].B.PBR=0b10; SPI_2.MODE.CTAR[0].B.BR=0b0011;
2. Register configuration of transmission data bits. For example, the default 16 bit transmission data bits I use are generally 16 bits, and FMSZ needs to be set to 8 bits
/*frame size*/ SPI_2.MODE.CTAR[0].B.FMSZ=0b0111;
3. The clock polarity and phase should be consistent with the high side chip. The clock polarity and phase of bts5404 are divided into 0,1
SPI_2.MODE.CTAR[0].B.CPOL=0; //High side chip polarity and phase 0 1 SPI_2.MODE.CTAR[0].B.CPHA=1;
4. Read and write the pseudo code of the function
u8 FUN_HW_BTS54040_Read(u8 address) { u8 result; FUN_HW_Time_Delayus(1); SPI2_SendAndGetData_byte(address); FUN_HW_Time_Delayus(1); result=SPI2_SendAndGetData_byte(address); FUN_HW_Time_Delayus(1); return result; }
void FUN_HW_BTS54040_Write(u8 data) { FUN_HW_Time_Delayus(1); SPI2_SendAndGetData_byte(data); FUN_HW_Time_Delayus(1); SPI2_SendAndGetData_byte(data); FUN_HW_Time_Delayus(1); }
3, BTS54040 register
The register of bts5404 is relatively simple and not many.
1. The status register will be returned every time the register is read or written.
2. Initialization chip, including Hardconfig, swap mode and DigControl registers, must be set.
void FUN_HW_BTS54040_Init() { /*LHI set low*/ SIUL2.MSCR[PD2].B.SSS = 0; /* Source signal is DSPI_0 SOUT */ SIUL2.MSCR[PD2].B.OBE = 1; /* OBE=1. */ SIUL2.MSCR[PD2].B.SRC = 0; /* Full strength slew rate */// SIUL2.GPDO[PD2].B.PDO=0; BTS54040.HardConfig.R=HWCRCONFIG; /*hard reset*/ FUN_HW_BTS54040_Write(BTS54040.HardConfig.R); BTS54040.SwapConfig.R=SWCRCONFIG; /*swag mode 0->output 1->input*/ FUN_HW_BTS54040_Write(BTS54040.SwapConfig.R); BTS54040.DigControl.R=0XF6; /*diog*/ FUN_HW_BTS54040_Write(BTS54040.DigControl.R); }
3. The switch of the high side switch register is mainly set by the OUT.OUTn bit, and then the read-write bit is set.
void FUN_HW_BTS54040_HSD1_ON(u32 CS) { BTS54040.OutConfig.B.OUT1=1; BTS54040.OutConfig.B.WRITE_READ=1; FUN_HW_BTS54040_Write(BTS54040.OutConfig.R,CS); }
void FUN_HW_BTS54040_HSD1_OFF(u32 CS) { BTS54040.OutConfig.B.OUT1=0; BTS54040.OutConfig.B.WRITE_READ=1; FUN_HW_BTS54040_Write(BTS54040.OutConfig.R,CS); }