cancel
Showing results for 
Search instead for 
Did you mean: 

Stop code execution during 8 timer interrupts

mnemxys
Associate II
Posted on July 03, 2015 at 14:14

Hi everyone,

I'm working with the stm32f405 microcontroller and I am trying to send some characters using a simple GPIO pin. My problem is that I have to send each bit of one character every 20ms. For that I use a timer interruption. In this case, every 8 executions of the interrupt I will have sent a complete character and I can start sending the next one.

The problem is that I have to wait until 8 interruptions have execute or the code continues executing between interruptions and the character value will change. Therefore, I would need to stop the code durint 8 interruptions. To do that, I use a counter into the interruption and a while(counter < 8); in my main code but nothing happens. The code executes entirelly before the interrupts and only can send the last character.

What could I do to stop the code during 8 interruptions?

I hope you can help me. Thank you very much in advance.

Regards!!

mnemxys

 
2 REPLIES 2
Posted on July 03, 2015 at 15:58

Couldn't you just buffer the data properly so this doesn't happen?

Have the interrupt pull it's OWN copy of the data every 8 cycles, and have a FIFO (Ring) Buffer hold the subsequent character(s). Have the filling side check if it's FULL, and spin in a loop until the interrupt frees up space.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mnemxys
Associate II
Posted on July 10, 2015 at 16:20

Oh, Clive1, I forgot to answer you. I finally did as you adviced me and now I have my code working smoothly although I'm having other problems, but that's another story.

Thank you very much for your help.

mnem