Jump to content

A few beginner questions

Recommended Posts

Hi All,


I have never used an MCU with interrupts before (previous experience using the Propeller which does not have interrupts), and am trying to nut out the main routines in my upcoming project. Hoping I can get some insight from people here!


My program needs to sample 3 sensors, 1 every 2.5ms, 1 every 10ms, 1 every 25ms, perform some logic and write 256 bytes to SPI Flash memory every 25ms.

I plan to use interrupts for each of these tasks, and synchronise the start times so the time periods line up at the end of 1 second (i.e. in 1 second I will have recorded 400 samples, 100 samples and 40 samples, before writing all this to dataflash and starting over.

Each sensor will have a bit of fixed point math applied to the results.


I'm not sure yet if I will include this math in the sensor interrupts (which will spread the load but make my interuprts longer), or to put the in the main routine and perform them once an interrupt returns with a new sensor reading (which will allow the math to be interrupted and keep my sensor readings more in sync). Im leaning towards the later.


Question 1: My question relating to this is, what happens if an interrupted is triggered while i'm handling an earlier interrupt? Does it queue up and start once i'm done with the first one? Do interrupts have certain priorities and an interrupt with a higher priority will interrupt one with a lower priority?


Regarding writing 256 bytes to DF. It seems I can only write 1 byte at a time using the USCI.


Question 2: Is my thinking correct, that to send larger chunks of data I can trigger an interrupt once the byte is sent, and in that interrupt increment a pointer to the next byte then start transmitting the next byte etc etc until 256 bytes have been sent?


Question 3: Do timers restart automatically once they have triggered their interrupt (thus staying in sync) or do they restart after the interrupt has been handled (thus, I need to re-sync them)?


Question 4: Last question for now is just a general electronics question.


I am using a super cap in this design which I have never done before. I have it in parallel with the 3.3V LDO output, and calculate it will hold the system above 2.7V for ~8 seconds in the event of battery disconnection or brownout. Do I need to put a resistor in series with the supercap to prevent it discharging too much power into my devices, or can I just use it as is?


Sorry for the wall of text and thanks in advance!

Link to post
Share on other sites

Check the data sheet for the chip you're working with for interrupt priority - http://www.ti.com/lit/ds/symlink/msp430g2553.pdf for the 2553.  It's on page 11.


For USCI - you would write each of the 256 bytes sequentially (the TX interrupt for USCI).  There is an interrupt to indicate that the byte has been sent - you can use that to send the next byte in your list.  Once you complete your array of bytes - just don't send the next.


Regarding one interrupt stopping another - here's a discussion on the e2e forum that looks promising - http://e2e.ti.com/support/microcontrollers/msp430/f/166/t/311830.aspx


Timers - I believe they continuously count and the interrupt is handled separately.  I seem to remember running into an issue where I expected the counter to be 0 but it was a bit above due to the time it took the interrupt to start.  You'll probably need to look a bit on that one or do some testing.


Can't help you on the super cap one unfortunately.  I don't have any experience with those.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...