joeman112
Junior Member level 2
- Joined
- Jun 11, 2011
- Messages
- 22
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,459
Hi,
Ive got a USB to RS485 converter for PC and trying to communicate with PIC16f887.
I am trying to simulate in Proteus, Here is my Schematic:
Here is my Code
I flick the switch to transmit, then put it back before the recieve (my previous code version had a delay in before writing)
Any ideas?
Thanks
Joe
Ive got a USB to RS485 converter for PC and trying to communicate with PIC16f887.
I am trying to simulate in Proteus, Here is my Schematic:
Here is my Code
Code:
unsigned char ch;
void InitUsart(void) {
// TX Pin - output
TRISC=0b01000000;
TRISD=0b00000000;
PORTD=0;
// RX Setting, 8bit, enable receive,
RCSTA = 0x90;
// TX Setting, 8bit, Asinchronius mode, High speed
TXSTA = 0x24;
// Set Baudrade - 9600 (from datasheet baudrade table)
SPBRG = 129;
}
// main function
void main( void ) {
InitUsart();
UART1_Init(9600);
while(1){
if(UART1_Data_Ready()){
ch = UART1_Read();
PORTD=10;
UART1_Write(ch);
PORTD=0;
}
}
}
I flick the switch to transmit, then put it back before the recieve (my previous code version had a delay in before writing)
Any ideas?
Thanks
Joe