STM32F446 SPI DMA too fast for SSD1362
Hello,
I have implemented 4 wire SPI for my SSD1362 OLED controller. Here are my SPI transfer functions (both normal and DMA)
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) {
// Deselect when Tx Complete
if (hspi == &hspi1) {
HAL_GPIO_WritePin(GPIOA, OLED_CS_Pin, GPIO_PIN_SET);
}
}
void SSD1362_SPI_Tx(uint8_t data) {
while (!__HAL_SPI_GET_FLAG(&hspi1, SPI_FLAG_TXE));
HAL_SPI_Transmit_DMA(&hspi1, &data, 1);
}
void SSD1362_SPI_TxBuffer(uint8_t *buffer, uint16_t len) {
while (!__HAL_SPI_GET_FLAG(&hspi1, SPI_FLAG_TXE));
HAL_SPI_Transmit_DMA(&hspi1, buffer, len);
}
void writeCommand(uint8_t byte) {
HAL_GPIO_WritePin(GPIOA, OLED_CS_Pin, GPIO_PIN_RESET); // select OLED
HAL_GPIO_WritePin(GPIOA, OLED_DC_Pin, GPIO_PIN_RESET); // command
SSD1362_SPI_Tx(byte);
}
void writeData(uint8_t byte) {
HAL_GPIO_WritePin(GPIOA, OLED_CS_Pin, GPIO_PIN_RESET); // select OLED
HAL_GPIO_WritePin(GPIOA, OLED_DC_Pin, GPIO_PIN_SET); // data
SSD1362_SPI_Tx(byte);
}
void writeData2(uint8_t *adat, uint16_t meret) {
HAL_GPIO_WritePin(GPIOA, OLED_CS_Pin, GPIO_PIN_RESET); // select OLED
HAL_GPIO_WritePin(GPIOA, OLED_DC_Pin, GPIO_PIN_SET); // data
SSD1362_SPI_TxBuffer(adat, meret);
}
I am using big arrays to store the displayed pixels. The OLED is 256x64 so for the whole screen, I need an uint8_t array with the size of 8192.
What I have noticed is that when I use the DMA transfer function the display is unstable (shifted, or some pixels jitter). It looks like it is too fast for the SSD1362 so I need to introduce a small delay (even 1 ms works), then it works correctly. I suspect it has to do something with the DMA buffer.
