2023-03-01 01:08 PM
Hi All,
I'm trying to convert deividAlfa's LCD library to use on a L412 micro but I'm having an issue that I don't understand.
He has a routine in the LCD.C file:
static void setSPI_Size(int8_t size){
if(config.spi_sz!=size){
__HAL_SPI_DISABLE(&LCD_HANDLE);
config.spi_sz=size;
if(size==mode_16bit){
LCD_HANDLE.Init.DataSize = SPI_DATASIZE_16BIT;
LCD_HANDLE.Instance->CR1 |= SPI_CR1_DFF;
}
else{
LCD_HANDLE.Init.DataSize = SPI_DATASIZE_8BIT;
LCD_HANDLE.Instance->CR1 &= ~(SPI_CR1_DFF);
}
}
}
The problem is there is no SPI_CR1_DFF register in the L412 code. I want to use 8 bits for the SPI bus.
Is there a way around this issue?
Thanks,
Richard
2023-03-01 02:41 PM
STM32F103 and STM32L412 are different MCUs and integrate different peripherals or peripheral revisions.
For instance the SPI is different so the registers are also different.
For STM32L412, the data size is defined in CR2 register in bitfield DS:
Bits 11:8 DS[3:0]: Data size
These bits configure the data length for SPI transfers.
0000: Not used
0001: Not used
0010: Not used
0011: 4-bit
0100: 5-bit
0101: 6-bit
0110: 7-bit
0111: 8-bit
1000: 9-bit
1001: 10-bit
1010: 11-bit
1011: 12-bit
1100: 13-bit
1101: 14-bit
1110: 15-bit
1111: 16-bit
To do the porting you need to check the reference manual RM0394 for STM32L412:
It is likely there are other locations in the code where you have to apply changes due to register differences between the 2 MCUs.