PIC32 UART interrupt

Status
Not open for further replies.

varunme

Advanced Member level 3
Joined
Aug 10, 2011
Messages
741
Helped
17
Reputation
36
Reaction score
17
Trophy points
1,318
Activity points
5,764
For this program to initiate by interrupt
Code:
void Send_SMS(char *s1, char *s2, const char *s3, const char *s4, const char *s5, const char *s6, const char *s7, char *s8, unsigned int *idx, char *gsmAttempt, char clr) {

    while(strstr(s1, CopyConst2Ram(s2, s3)) == 0) {

        GSM_Send_Const_Command(s1, s2, s3, s5, idx, gsmAttempt, 1);
        GSM_Send_Const_Command(s1, s2, s3, s6, idx, gsmAttempt, 1);
        GSM_Send_Const_Command(s1, s2, s4, s7, idx, gsmAttempt, 1);

        UART1_Write_Text(s8);
        Delay_ms(500);
        UART1_Write(0x1A);

        DelayXSec(6);
    }

    memset(gsmBuffer, '\0', sizeof(gsmBuffer));
    (*idx) = 0;

}

Below interrupt code is correct?
Code:
unsigned cnt, cnt1;
char rxchar, i = 0, flag = 0; // Variable for storing the data from UART and array counter
unsigned char rxarray[80];   // array to store the received charaters
unsigned short j;

  void interrupt() {
  if (PIR1.RCIF) {          // test the interrupt for uart rx
    rxchar = Uart1_Read();  //
    rxarray[i] = rxchar;
    i++;
    // ******************************************************
    // Only select one of the following statements
    if (rxchar == 36) {  // select this if looking for a terminating character
      flag = 1;
      } // end if (rxchar == "$")
    PIR1.RCIF = 0;       // clear RCIF
    } // end  if (PIR1.RCIF)

  }
 

yes, mikroC

- - - Updated - - -

The UART system is sim900a

AT commands for the same is

Code:
const char atCommand1[] = "AT\r";
const char atCommand2[] = "ATE0\r";
const char atCommand3[] = "ATE1\r";
const char atCommand4[] = "AT+IPR=9600\r";
const char atCommand5[] = "AT+CMGF=1\r";
const char atCommand6[] = "AT+CPMS=\"SM\",\"SM\",\"SM\"\r";
const char atCommand7[] = "AT+CNMI=2,1\r";
const char atCommand8[] = "AT+CMGR=";
const char atCommand9[] = "AT+CMGS=\"XXXXXXXXXX\"\r";
//const char atCommand9[] = "AT+CMGS=\"+XXXXXXXXXXX\"\r";
const char atCommandA[] = "AT+CMGD=1,4\r";

const char atResponse1[] = "\r\nOK\r\n";
const char atResponse2[] = "ERROR";
const char atResponse3[] = "+CMTI: \"SM\",";
const char atResponse4[] = "> ";
const char atResponse5[] = "RING";
const char atResponse6[] = "NO CARRIER";
const char atResponse7[] = "NO ANSWER";
const char atResponse8[] = "+CFUN: 1";
const char atResponse9[] = "+CPIN: READY";
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…