UART1 LPC2148 stop sending data after amount of data transmited

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART1 LPC2148 stop sending data after amount of data transmited

1,175 Views
rtoribio
Contributor II

Hello everyone,

I have configured the UART1 of my LPC2148 with speed: (9600 / 8bits / N /1bit Stop) with interruption. The UART1 connects to an ESP-01 I can send and receive information perfectly. The problem I present is when receiving a certain amount of data from the ESP-01, the microcontroller for some reason stops transmitting information and I do not understand what the reason is. below I leave the configuration and the information that I am receiving from the ESP, when receiving 6 times this frame the microcontroller stops.

Data frame:

//----------------------------------------Data frame received---------------------

+IPD,4,346:HTTP/1.1 200 OK

Server: xxxxx/x.x.xx (xxxxxx)

Vary: Accept-Encoding

Content-Length: 155

Connection: close

Content-Type: text/html; charset=UTF-8

[{"count":"6","image":"0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,

 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,"}]

OK

//------------------------------------------------------------------------------

Code:

//----------------------------Structure for Data recieved------------------------------------------

typedef struct {

int in;

int out;

char buffer[400];

}p;

p *ptr2,datos_serial2;

//---------------------------Init UART1---------------------------------------------

void uart1_init(void)//9600 BAUD pclock 48MHZ
{
     PCONP |= 0x00000010;/* PCRTC = 1 */
     PINSEL0 |= 0x00050000; /* Enable RxD1 and TxD1*/
     U1LCR=0X83;            //8-data bits, 1 Stop bit, Disable Parity and Enable DLAB
     U1DLL=0x38;// MULVAL = 0x5 and DIVADDVAL = 14
     U1DLM=1;
     U1LCR=0X03;            //cleared DLAB
     U1IER= 0x00000001;//Enable Interrupt
}

//---------------------------------Send Char----------------

void SendCharUART1 (char str){

   U1THR = str;

    while( (U1LSR & 0x40) == 0 ); /* Wait till THRE bit becomes 1 which tells that transmission is completed */

}

//--------------------------------Interrupt enable------------------------------------------------------

void UART1_Interrupt_EN(void)

{

    // VICIntSelect = 0x00000000; 

     VICVectAddr7 = (unsigned) UART1Handler;//Vector 7

     VICVectCntl7 = 0x00000020 | 7; //select UART1 interrupt as IRQ i.e vector 7

    VICIntEnable |=(1UL<<7);//interrupt ena.

}

//------------------------------------------Interrupt IRQ--------------------------------------------

void UART1Handler (void)  __irq

{

//    /* Serial Receive Interrupt. */

char recieved;

if ((U1IIR & 0x0E) == 0x04) {

     recieved=U1RBR;

     ptr2 = &datos_serial2;

     if(ptr2->in>=399)

          ptr2->in=0;

     ptr2->buffer[ptr2->in++]=recieved;

  }

   VICVectAddr = 0x00;

}

//-----------------------------------------Main-------------------

int main()

{

uart1_init();

UART1_Interrupt_EN();

while(1){

  sendata_esp01();      //Process to send data to ESP01

  delay()

   //----------------- Algorithm to process the received data------------------//

   Process_Datareceived();

  //--------------------------------------------------------------------------------------//

  }

}

Labels (1)
0 Kudos
Reply
1 Reply

1,079 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Raul,

From the code, I see that the api function void SendCharUART1 (char str) is used to transmit data, but I do not see where you call the function.

Anyway, because you use interrupt mode, I suppose that you can transmit the char in the ISR.

Pls have a try.

BR

XianJun Rong

//------------------------------------------Interrupt IRQ--------------------------------------------

void UART1Handler (void)  __irq

{

//    /* Serial Receive Interrupt. */

char recieved;

if ((U1IIR & 0x0E) == 0x04) {

     recieved=U1RBR;

     ptr2 = &datos_serial2;

     if(ptr2->in>=399)

          ptr2->in=0;

     ptr2->buffer[ptr2->in++]=recieved;

  }

if(U1LSR & 0x40) U1THR = str; //Rong wrote

   VICVectAddr = 0x00;

}

0 Kudos
Reply