prodigyaj
Member level 2
dspic uart
hy all ,
I am very new to communicating the dsPIC's via UART. I use 2 controllers dsPICFJ128MC804 and dsPIC33FJ128MC802. The transmitter is 804 and reciver is 802.
my code for transmitter is as follows :
for the receiver code for 802 is as follows
In the setup i have set everything properly to the corresponding re programmable pins. My LED at _LATB7 is always ON. and there is no transmission taking place.
Both are configured to work at 80Mhz.
Any solution to the problem ? ANy error in code ?
let me add I use baud rate of 9600 and internal oscillator
hy all ,
I am very new to communicating the dsPIC's via UART. I use 2 controllers dsPICFJ128MC804 and dsPIC33FJ128MC802. The transmitter is 804 and reciver is 802.
my code for transmitter is as follows :
Code:
int main(void)
{
setup();
int i;
/* wait at least 104 usec (1/9600) before sending first char , we wait atleast 200uS for safety */
for(i = 0; i < 8000; i++)
{
Nop();
}
U1TXREG = 'a'; // Transmit one character
while(1)
{
}
}
void __attribute__((__interrupt__)) _U1TXInterrupt(void)
{
IFS0bits.U1TXIF = 0; // clear TX interrupt flag
U1TXREG = 'a'; // Transmit one character
}
for the receiver code for 802 is as follows
Code:
#include <p33fj128mc802.h>
#include <libpic30.h>
#define FCY 39613750L //define FCY = FOSC/2, before including mydelay.h
#include <mydelay.h>
extern void setup(void);
int main(void)
{
int flag=0;
char ReceivedChar;
_LATB1=_LATB6=_LATB7=_LATB8=_LATB9=1;
setup();
while(flag==0)
{
_LATB7=0;
// check for receive errors
if(U1STAbits.FERR == 1)
{
continue;
}
// must clear the overrun error to keep uart receiving
if(U1STAbits.OERR == 1)
{
U1STAbits.OERR = 0;
continue;
}
// get the data
if(U1STAbits.URXDA == 1)
{
ReceivedChar = U1RXREG;
flag = 1;
_LATB8=0;
}
}
if ( ReceivedChar == 'a' )
{
_LATB1=_LATB6=0;
}
while(1){}
}
Both are configured to work at 80Mhz.
Any solution to the problem ? ANy error in code ?
let me add I use baud rate of 9600 and internal oscillator
Code: