AnsweredAssumed Answered

Access variable outside interrupt

Question asked by NTan on Jun 2, 2013
Latest reply on Jun 7, 2013 by NTan

Good Day Everyone!

 

     I'm using a BF537 EZ Kit Lite and Visual DSP ++ 5.0, Update 10.1. I have an UART RX interrupt which stores the data in rcvbuf. It is declared as char rcvbuf[STRINGSIZE]; in my uart.c file. However, I would like to access the value of rcvbuf in my main function (found in main.c). I've tried initializing it as volatile char rcvbuf[STRINGSIZE], but it still doesn't work.

 

     May I have any suggestions on how I may access a variable outside an interrupt? Below are the snippets of the code. (I've removed some code so it would be easier to understand).

 

===== UART.C FILE =====

char rcvbuf[STRINGSIZE];

 

EX_INTERRUPT_HANDLER(UartInterruptsHandlerData)

{

          /* some code here */

         if (*pUartLsr & DR) {

                   UartGets(UartNum, rcvbuf);

}

 

===== MAIN.C FILE =====

int main(void)

{

    /* some code here */

    while(*pIMASK & 0x4000 && check < 30 ) {  //Sends A 30 times and stops when interrupt in rx pin is disabled

                   UartPutc(0, 'A');

          check ++; 

    }

   

    if (rcvbuf[0] == 'B'){

           printf("success");

          return 0;

     }

     else{

          /*some code here*/

     }

}

 

Thank you and any suggestion would be appreciated

 

Regards,

Nicole

Outcomes