This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
Not able to get response of an AT commands in response buffer when baud rate is 115200 and frequency 1MHZ
code which i have written for an interrupt and for UART init is below
/*****************for uart initialization*********************
P3SEL |= BIT4+BIT5; // select p3.4 and p3.5 as TXD and RXD respectively
P3DIR |= 0x1A; // Set TX, RTS as output. P3.4 = 1 & P3.3 = 1
UCA0CTL1 |= UCSWRST ; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 9; // 1MHz 115200(see User's Guide)
UCA0BR1 = 0; //1MHZ 115200
UCA0MCTL |= UCBRS_1 + UCBRF_0; // + UCOS16; // Modln UCBRSx=0, UCBRFx=0,
//UCA0MCTL = UCBRS_0 + UCBRF_13+ UCOS16;
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
__no_operation();
UCA0IE |= UCTXIE;
UCA0IE |= UCRXIE; // Enable USCI_A3 RX interrupt
//__bis_SR_register(LPM0_bits + GIE);
__no_operation();
/******************************code for interrupt***********************
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,4))
{
case 0: break; // Vector 0 - no interrupt
case 2: x = UCA0RXBUF; // Vector 2 - RXIFG
if((gsmResponseFlag == 1) && (gsmResponseIndex < 300)){
gsmRresponse[gsmResponseIndex] = x;
gsmResponseIndex++;
}
if((x == '{') ){ // check for starting of sting for server data
server_data_flag = 1; // if starting { detected then start storing data
server_data_index = 0;
}
if((server_data_flag == 1) && (server_data_index < SERVER_DATA_SIZE-1)){
server_data[server_data_index] = x; // store server data
server_data_index++;
}
//if(x == '}') // end of server string
if((x == '}'))
{
server_data_flag = 0;
server_data[server_data_index] = '\0';
server_data_index++;
SERVER_DATA_FUNCTION(); // parse data and get time,messege id etc..
}
break;
case 4: break; // Vector 4 - TXIFG
default: break;
}
return;
}
What does "not able to get a response" mean? Received nothing? Half a response? Missing every other byte?
1) I don't see where you "__enable_interrupt()"
2) At 115200, you can expect an Rx byte every 87usec. At 1MHz, that's 87 CPU clocks, or maybe 20 instructions. Your ISR is probably using more than that. (Symptom: dropped bytes). I suggest you use your ISR only to buffer Rx bytes (maybe until a '\n'), then let main sort out what arrived at its leisure.
3) > P3DIR |= 0x1A; // Set TX, RTS as output. P3.4 = 1 & P3.3 = 1
P3OUT is undefined at Reset. You should make sure the RTS pin is set properly (probably =0).
Hello,
I mean to say missing every bytes ....and now i have checked and i think problem in interrupt generation,
can you please suggest something for that.
Hi shreya,
You need to enable interrupt by this code :
__bis_SR_register(LPM0_bits + GIE);
Best Regards
Johnson
Hello Johnson,
I have enabled the RX and TX bit .
UCA0IE |= UCTXIE;
UCA0IE |= UCRXIE;
Hello johnson,
As you mention that GIE is needed to enable for any interruption i have enabled it already but still i'm not able to get response in my response buffer when baud rate is 115200 with SIM 7600E module
Hi shreya,
Can you capture the waveforms on TX and RX with an oscilloscope?
Best Regards
Johnson
hello,
Issue is not solved yet...not able to get the data in UART Receive buffer.
Hi shreya,
You replied earlier that the problem has been solved. Is the new problem encountered now?
Best Regards
Johnson
Hello Johnson,
Ya I thought it was solved that's why, but same issue is still present that not getting proper data in buffer some times it will give proper response sometimes miss some letter or digits and some time empty buffer present so please check my code which I have attached above .
Thank you.
Are you referring to the code in your original post? If you made the changes I suggested (back in November) it is probably very different now.
Hello ,
Change is only that now I'm using baud rate of 9600 and that's why the registers value of an UART are changed...which is mentioned below.
void UART_INIT(void)
{
P3SEL |= BIT4+BIT5; // select p3.4 and p3.5 as TXD and RXD respectively
P3DIR |= 0x1A; // Set TX, RTS as output. P3.4 = 1 & P3.3 = 1
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 6; // 1MHz 9600 (see User's Guide)
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS_0 + UCBRF_13 + UCOS16; // Modln UCBRSx=0, UCBRFx=0,
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
__no_operation();
UCA0IE |= UCTXIE;
UCA0IE |= UCRXIE; // Enable USCI_A3 RX interrupt
__no_operation();
}
Hi shreya,
Refer to those example code, your issue will resolved.
http://dev.ti.com/tirex/explore/node?node=AMeniTJMh0RHZCGVNwzJsw__IOGqZri__LATEST
Best Regards
Johnson
Thanks Johnson
Your response is helpful, do you have any idea about level shifting because one more doubt i have which is related to level shifting my GSM module UART is 1.8v and controller have 3.3V so may be because of that issue may occur that buffer miss data some times,so if have any idea about how to handle level shifting in code let me know.
Thanks
Hi Shreya,
You can use the TXB0102 chip to achieve level shifting.
http://www.ti.com/product/TXB0102?keyMatch=TXB0102&tisearch=Search-EN-everything&usecase=part-number
Best Regards
Johnson
**Attention** This is a public forum