I am having terrible time trying to figure out how to read and write to Port D on BL1800 JackRabbit Single-Board Computer right from within the Processor. I have searched through documentations and found very few useful information but the following:
This library contains 3 RS485 serial interface functions for the JackRabbit
board. These functions are to be used with the serial port D library functions
in rs232.lib because serDopen utilizes PC0 (TXD) and PC1 (RXD), which are
connected to pin 4 and pin 1 of the RS485 chip. This chip is half duplex
requiring pin 3 (Data Enable) to be high for pins 6 and 7 to act as output and
low for those pins to act as input.
-------------------------
| |
| DI 4|------- (PC0 on JackRabbit)
(485+ on JackRabbit) -------|6 DO/RI RO 1|------- (PC1 on JackRabbit)
| |
| __ __ |
(485- on JackRabbit) -------|7 DO/RI |
| DE 3|------- (PD5 on JackRabbit)
| RE 2|O-----------|
------------------------- |
SP483EN |
\/
void Jr485Init(); Setup parallel port D pins for 485 use
void Jr485Tx(); Sets (high) pin 3 (DE) of the RS485 chip to disable Rx, enable Tx
void Jr485Rx(); Resets (low) pin 3 (DE) of the RS485 chip to disable Tx, enable Rx
Apparently, I can write and read to Port D from a PC, but I can only write to Port D from within the processor and not able to read. Am I missing a key information about Port D?
This is how I write on Port D from Dynamic C program:
Jr485Tx();
waitfordone { cof_serDwrite(&dxout[0],5) };
while(BitRdPortI(SDSR,SS_TFULL_BIT) != 0);
while(BitRdPortI(SDSR,SS_TPRG_BIT) == 1);
This is how I read on Port D from Dynamic C program:
Jr485Rx();
waitfordone { dxin[0] = cof_serDgetc() };
if(dxin[0] == 0xff) // if-1
{ waitfordone { myret = cof_serDread(&dxin[1],5,20) };
Again, these codes can communicate flawlessly with a PC through port D but not when the Jackrabbit itself is trying to read the incoming bytes from an external device. Is Port D meant for RS232 communication only?
Any help or hints will be greatly appreciated.