esp32c3 > spi > send words fail
Posted: Thu Dec 19, 2024 10:52 am
Hello,
Why is the last data packet (see picture) always one of the next transmission?
Why is the last data packet (see picture) always one of the next transmission?
Code: Untitled.c Select all
void spi_write_words( uint16_t * _data, uint8_t _length )
{
if( _length > 16 ) _length = 16;
REG_WRITE( SPI_MS_DLEN_REG,( ( 16 * _length) -1 ) );
spi_write_buffer( (uint32_t*)_data, _length );
REG_SET_BIT( SPI_CMD_REG, SPI_UPDATE_bm );
while ( REG_READ( SPI_CMD_REG ) & SPI_UPDATE_bm ){};
REG_SET_BIT( SPI_CMD_REG, SPI_USR_bm );
while ( REG_READ( SPI_CMD_REG ) & SPI_USR_bm ){};
}
Code: Untitled.c Select all
void max7219_write( uint16_t* _data, uint8_t _length )
{
spi_write_words( _data, _length );
}
Code: Untitled.c Select all
while (1)
{
uint16_t *pData, buffer[ 4 ];
pData = buffer;
for (uint8_t i = 0; i < 4; i++)
{
*pData++ = REG_DISPLAY_TEST << 8 | 1;
}
max7219_write( buffer, 4 );
pData = buffer;
for (uint8_t i = 0; i < 4; i++)
{
*pData++ = REG_DISPLAY_TEST << 8 | 0;
}
max7219_write( buffer, 4 );
}