I am using the rabbit RCM 4010 dev. kit for serial communication. my code:
#class auto
///////
// change serial buffer name and size here
///////
#define DINBUFSIZE 7
#define DOUTBUFSIZE 7
#use “RCM40xx.lib”
///////
// change serial baud rate here
///////
#ifndef _232BAUD
#define _232BAUD 57600
#endif
// Define timeout between bits being received
#define MAXS 100
void main()
{
// Declaratioins
auto char cOut;
auto int tranflag;
char s[8];
char t[8];
char init[2];
auto int length;
auto int written;
auto int read;
auto int n;
// Define variables
length = sizeof(s);
init[0] = 128;
init[1] = 131;
// Open serial, clear buffers, turn off Flw Cntrl
serDopen(_232BAUD);
serDwrFlush();
serDrdFlush();
serDflowcontrolOff();
// Initialize communicatin and put robot in X mode
serDwrite(init,2);
for(;;)
{
costate
{
s[0] = 128;
s[1] = 128;
// Query Robot
//written = serDwrite(s,length);
//printf("peek %d
",serDpeek());
read = serDread(t, 2, MAXS);
if (read != 0)
printf("Read: %d
",read);
}
}
}
there is a lot of extra crap in there from me debugging and etc. Basically i have a device that spits out serial data at 5v ttl and i wanna read it and send commands to it. so i have the transmit of my device going into the receive of the board which is pc1 and my (i’m using port D as my serial port) and the receive of my device connected to transmit of the board.
The strange part is that i can send and receiver perfectly fine when i connect a computer to the db9 cable connected to the header on the little dev. board that the rabbit core plugs into (this is rs232 and just used to test). Also i can send serially to my device with no problem using pc0 pin (ttl level). When i try to receive though on pc1 it won’t read anything…just says the receive buffer is empty(using the serDpeek() function). i read somewhere that you might have to remove the 0 ohm resistors to use the 5/3.3v ttl level pins (pc0 and pc1). Do i need to do this…i can’t figure this out so any ideas are welcome.
Basically when i use RS232 with the db9 cable from the proto board Tx and Rx work fine. When i use PC0 and PC1 to talk to my device i can only transmit…it won’t receive anything.