Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

UART communication using 2 dsPIC's

Status
Not open for further replies.

prodigyaj

Member level 2
Joined
Jan 10, 2007
Messages
50
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,591
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 :
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){}
}
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
Code:
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top