UART receive problem

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

UART receive problem

1,788 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by taskihcp on Wed Apr 16 09:09:13 MST 2014
Hallo,

I want to receive Data from one mikrocontroller(avr)  to another mikrocontroller(lpc1343)

Data send from avr is ok but I can'd receive data to lpc1343.

I took the code uart.c and uart.h from examples.

the configuration for RXD and TXD have done in codes I think.

I added this method in c source:

uint8_t UARTReceive()
{
    uint8_t c;
while ( LPC_UART->LSR & LSR_RDR )
  {
c = LPC_UART->RBR;
  }
return c;
}

the Baudrate is  9600.

can anybody help me :)

thanks

taskihcp





Original Attachment has been moved to: uart.c.zip

Original Attachment has been moved to: uart.h.zip

Original Attachment has been moved to: uarttest.c.zip

Labels (1)
0 Kudos
9 Replies

1,114 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by taskihcp on Tue May 13 05:21:34 MST 2014
thats right,

ich have on RXD only a 3,3V signal, but can't receive data (triggern).

I only know that the receive data comes to shift register and then to Receive-Buffer(RBR).

But I can send data from lpc over TXD that works.

sorry I cant't debug it seems complicated.


0 Kudos

1,114 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Tue May 13 04:31:12 MST 2014

Quote: taskihcp
I measure the signal which comes from avr to rx from lpc.there is the same data.


I hope that means that RxD pin is showing a nice 3.3V signal with 9600 bps data  :quest:

Quote: taskihcp
It can be any problems on my hardware but is there any command to read the receive files ??
...is with this code the data in LPC_UART->RBR saved and can use this data??


This loop is retransmitting the received buffer. Are you familiar with buffering?

As mentioned already I would strongly recommend to [color=#f00]debug your code[/color]. That will show you if the interrupt is triggered (= data are received) and also show you the buffer content  :) 
0 Kudos

1,115 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by taskihcp on Tue May 13 02:08:27 MST 2014
hi R2D2,

thanxs for your answer I measure the signal which comes from avr to rx from lpc.there is the same data.

It can be any problems on my hardware but is there any command to read the receive files ??

you wrote:

  while (1)
  {/* Loop forever */
if ( UARTCount != 0 )
{
  LPC_UART->IER = IER_THRE | IER_RLS;/* Disable RBR */
  UARTSend( (uint8_t *)UARTBuffer, UARTCount );
  UARTCount = 0;
  LPC_UART->IER = IER_THRE | IER_RLS | IER_RBR;/* Re-enable RBR */
}
  }

is with this code the data in LPC_UART->RBR saved and can use this data??

0 Kudos

1,115 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Fri May 09 04:03:25 MST 2014

Quote: hastaskiran
I connect tx from avr to rx from lpc. I dropped the 5V voltage to 3.3V with an external circuit.


That's not excluding possible problems. Which 'external circuit' is doing this job and did you measure (Oszilloscope) it?


Quote: hastaskiran
In original Uart.c file is not a method how to receive a data over RxD.



And what do you think is this:

  while (1) 
  {/* Loop forever */
if ([color=#f00] UARTCount != 0[/color] )
{
  LPC_UART->IER = IER_THRE | IER_RLS;/* Disable RBR */
  UARTSend( (uint8_t *)UARTBuffer, UARTCount );
  UARTCount = 0;
  LPC_UART->IER = IER_THRE | IER_RLS | IER_RBR;/* Re-enable RBR */
}
  }



0 Kudos

1,115 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hastaskiran on Fri May 09 01:01:31 MST 2014
Hallo R2D2,

1- at90can128.It is running with 5V

2- I can transmit data (0xAA) from Avr to lpc but not sure that lpc receive the data


Generally I want to control a Lamp over lpc. The Control data (0-200) also 1 Byte comes from avr and want to send to lpc microcontroller.
I connect tx from avr to rx from lpc. I dropped the 5V voltage to 3.3V with an external circuit.

In original Uart.c file is not a method how to receive a data over RxD. So I have to write a method....
You can only see a method to send data and the and of the file.

I am using the original codes uart.c and uart.h

in lpc the baudrate is 9600 so I want to run the lpc also with 9600.

I added the UARTReceive() in uart.c file after sen method.

I found the uart.c and uart.h files in internet(nxp).

UARTinit(115200)  must be of course 9600.






0 Kudos

1,115 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Thu May 08 05:50:51 MST 2014
I'm not sure what you have tried already...

1. Which AVR are we talking about? Is it running with 3.3V?

2. Why are you sure it's transmitting? Did you scope it?

3. Did you try to connect something else to your LPC1343?

4. Did you try to connect RxD and TxD of your LPC1343 to receive own data?

5. Did you debug the code? Is an UART interrupt triggered while you are receiving data?

6. Which code are you using? Uarttest.c is showing:

  UARTInit(115200);


:quest:

You are talking about UARTReceive(), where is it  :quest:
0 Kudos

1,115 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hastaskiran on Thu May 08 05:33:16 MST 2014
Hello,

taskihcp is also my nickname so its me :)

if this missunderstand has been solved than can we continue with the main Problem :)


0 Kudos

1,115 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Thu May 08 04:41:49 MST 2014

Quote: hastaskiran
has anybody no idea for my Problem??



:quest:

This is your first post here, so what problem are we talking about?

Problem of taskihcp?
0 Kudos

1,115 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hastaskiran on Thu May 08 01:18:48 MST 2014
has anybody no idea for my Problem??

I can give more Information if my Explanation is too short.

best regards

hastaskiran
0 Kudos