cancel
Showing results for 
Search instead for 
Did you mean: 

SPI_Transmit_AND_Receive_Interrupt_FLAG_At_Same_Time

M N
Associate II
Posted on January 27, 2017 at 23:28

Hi.

I have problem by SPI that is :

When i want to send data for example in slave mode during receiving from master. data will corrupt ( if i just receive data and send to UART it works fine). I think it happens Because both TXE and RXNE occurs at same time and when MCU is in ISR data will rewrite in data register before transfer to Tx/Rx buffer  . How can i Handle this in continuous transmission ?  . it's my code :

-------------------------------------------------------------------------↓

//Slave Part

void

SPI2_IRQHandler(

void

){ 

static char counter =

0x40

;

           

 if

( SPI2->SR & SPI_SR_RXNE ) {   

                sendToUart(SPI2->DR);

            }

          

 if

( SPI2->SR & SPI_SR_TXE ) {               

                SPI2->DR = counter;

                counter++;

                if(counter >=

0x5B

)counter=

0x40

;          

            }          

 }   

-------------------------------------------------------------------------↑

12 REPLIES 12
Posted on January 30, 2017 at 22:27

This is basic textbook stuff (although probably rarely taught on basic digital courses, or easily forgotten/overlooked) rather than ST-specific, that's why it's not mentioned in the DS/RM.

The high frequency content of digital signal depends more on the edges' slew rate than on the repetition frequency. And it's those gigahertzs which are causing all the nasty ringing and reflections which in turn get detected by the rather fast clock circuitry.

Never use a faster digital output than the absolute minimum you need.

JW

Suresh Palani
Associate
Posted on May 16, 2017 at 07:16

Hi...

Please can you give me your working SPI Program. (

mailto:jsureshp@gmail.com

 )

Thank you.....

Posted on May 16, 2017 at 07:23

Hi...

Please can you give me your working SPI Program. (

mailto:jsureshp@gmail.com

 )

Thank you.....