CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC18F452 device is not working in maximum speed for RS485

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
amit78



Joined: 17 Jul 2009
Posts: 21
Location: Kolkata, India

View user's profile Send private message

PIC18F452 device is not working in maximum speed for RS485
PostPosted: Fri Aug 28, 2009 7:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Aug 28, 2009 7:32 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group