amit78
Joined: 17 Jul 2009 Posts: 22 Location: Kolkata, India
|
PIC18F452 device is not working in maximum speed for RS485 |
Posted: Fri Aug 28, 2009 7:21 am |
|
|
Hi All,
I wanted to establish two way communication from and to PC using PIC18F452 device.
I am trying to send data from PIC to PC. Please see the code mentioned below. When I set the #use delay value to 4000000 it is working as soon as I tried to set it to maximum that is 40000000 I do not receive any data in windows HyperTerm.
Please tell me where I am doing wrong?
Code: | #include <18F452.h>
#device *=16
#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT
//The below declaration works
#use delay(clock=4000000)
//When set to below value nothing is received by HyperTerm
//#use delay(clock=20000000)
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, stream=RS485, bits=8, ERRORS)
#include <stdio.h>
void main()
{
char ch;
while(true)
{
if (kbhit())
{
ch = getch();
printf("\n\rChar %c from device\n\r", ch);
}
}
} |
Regards,
Amit |
|
rberek
Joined: 10 Jan 2005 Posts: 207 Location: Ottawa, Canada
|
|
Posted: Fri Aug 28, 2009 7:32 am |
|
|
Well, what frequency is the crystal/oscillator you are using? You just can't pick random numbers and put them in the #use delay statement. You need to use the value that represents the clocking input to the device.
r.b. |
|