From 6214d673938632c47b75c6366340bdb73141bc3e Mon Sep 17 00:00:00 2001 From: polymurph Date: Tue, 2 Aug 2022 17:09:24 +0200 Subject: [PATCH] working better example of alternating On Off Frame test with MAX7219 --- ked/csl/stm32f042/Src/imp_spi.c | 2 ++ main.c | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ked/csl/stm32f042/Src/imp_spi.c b/ked/csl/stm32f042/Src/imp_spi.c index 3b2c31e..dd7f8eb 100644 --- a/ked/csl/stm32f042/Src/imp_spi.c +++ b/ked/csl/stm32f042/Src/imp_spi.c @@ -157,6 +157,8 @@ uint8_t spiTrx(spiCH_t spi_hw_ch, uint8_t tx_data) //SPI1->DR = tx_data; // send data + + // this masking must be done. otherwise 16bits frame will be used *(uint8_t*)&(SPI_BASE->DR) = tx_data; // Wait for RXNE to set -> This will indicate that the Rx buffer is not empty diff --git a/main.c b/main.c index 1383364..3970258 100644 --- a/main.c +++ b/main.c @@ -11,27 +11,29 @@ void max7219_test_display(spi_ch_t* spi_ch) { // set mode to display test - +/* pinWrite(spi_ch->pin, 0); spiTrx(spi_ch->spi, 0x0F); - spiTrx(spi_ch->spi, 0x00); + spiTrx(spi_ch->spi, 0x01); pinWrite(spi_ch->pin,1); - - //spiWrite16bit(spi_ch, 0x0C01); +*/ + spiWriteReg(spi_ch,0x0F,0x01); + +// spiWrite16bit(spi_ch, 0x0F01); //delayMs(50); // spiWrite16bit(spi_ch, 0x0F01); delayMs(1000); - +/* pinWrite(spi_ch->pin, 0); - spiTrx(spi_ch->spi, 0x0C); - spiTrx(spi_ch->spi, 0x01); + spiTrx(spi_ch->spi, 0x0F); + spiTrx(spi_ch->spi, 0x00); pinWrite(spi_ch->pin,1); - +*/ // set mode to shutdown -// spiWrite16bit(spi_ch, 0x0C00); + spiWrite16bit(spi_ch, 0x0F00); delayMs(1000); - +/* pinWrite(spi_ch->pin, 0); spiTrx(spi_ch->spi, 0x0C); spiTrx(spi_ch->spi, 0x00); @@ -40,7 +42,7 @@ void max7219_test_display(spi_ch_t* spi_ch) // set mode to shutdown // spiWrite16bit(spi_ch, 0x0C00); - delayMs(1000); + delayMs(1000);*/ } void max7219_setIntensity(spi_ch_t* spi_ch, uint8_t intensity)