Jump to content
leebr

Problems with Serial using interrupts

Recommended Posts

Hi,

I am developing a monitor that will wake up every 15 minutes read and sensor and send some data. I'm using an EXP430G2  onto which I have successfully soldered the 32KHz crystal. The interrupts are working OK, waking every 16 seconds and toggling a LED. I'm using TACTL = TASSEL_1 +ID_3 + MC_2 +TAIE and Timer0-A1.

My problem occurs whenever I try to use either the serial port (using Serial.print) or the AirBooster Pack. Then nothing happens - the system freezes. I'm assuming this has something to do with use of interrupts by the Serial and Airbooster libraries but I have no idea what. 

Any pointers on how to resolve this much appreciated. (Note serial and airbooster work fine when not using interrupts)

Cheers

brian

Share this post


Link to post
Share on other sites

Just curious, are you trying to do the Serial.print inside the interrupt?  Somewhere in the documentation it says you shouldn't do that.

What I do, is use and "Event" variable to trigger something time consuming (e.g., Serial writes)  outside of the ISR.  So something like this:

#include "Event.h"

Event SampleTaken;
volatile (datatype)  SampleValue;


setup:
   setup/start timer
   SampleTaken.begin();
loop:
   SampleTaken.waitFor();
   print SampleValue;

ISR:
   Grab SampleValue;
    SampleTaken.send();
  
jrd

 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×