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 CCS Technical Support

HS PLL and RS232

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



Joined: 06 Mar 2008
Posts: 35
Location: pakistan

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

HS PLL and RS232
PostPosted: Tue Apr 22, 2008 11:24 pm     Reply with quote

hi
this is my code
Code:
#include<18F4620.h>
#fuses [b]H4[/b],NOWDT,NOLVP, NODEBUG
#use delay (clock=20000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,stream=LRF,parity=N)
#include<stdlib.h>
#include<input.c>
void main()
{
char c,d;
int data,result;
    {
    delay_ms(50);
    fprintf(LRF,"\n\rEnter the value\n\r");
    while(TRUE)       
           {
           c=fgetc(LRF);             
           data=c-48 ;                 
            result=data*5;                       
            d=result;               
            fprintf(LRF,"\n%d",c);               
            } 
    }
}


When I use oscillator in HS-PLL (H4) mode i am getting garbage data at RS 232. but when i change it to HS i am getting correct data.

Please don't consider the calculations.

Rolling Eyes
_________________
sohail khan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 22, 2008 11:39 pm     Reply with quote

What is your crystal frequency ?
sohailkhanonline



Joined: 06 Mar 2008
Posts: 35
Location: pakistan

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Tue Apr 22, 2008 11:42 pm     Reply with quote

my crystal frequency is 20Mhz
_________________
sohail khan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 22, 2008 11:49 pm     Reply with quote

Use the HS fuse, and the PIC will run at 20 MHz.
sohailkhanonline



Joined: 06 Mar 2008
Posts: 35
Location: pakistan

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Tue Apr 22, 2008 11:57 pm     Reply with quote

My application is configured at 40Mhz H4 configuration, above code is sample for the rs232 problem. Is there any way to fix the rs232 communication keeping same settings (40Mhz). Confused
_________________
sohail khan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 23, 2008 12:02 am     Reply with quote

Use a 10 MHz crystal with the H4 fuse. (Remove the 20 MHz crystal).
Set the #use delay() frequency to 40 MHz.
sohailkhanonline



Joined: 06 Mar 2008
Posts: 35
Location: pakistan

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Wed Apr 23, 2008 12:09 am     Reply with quote

Thank you PCM
TCP/IP stack file ccstcpip.h
contains the code (i am using it)

Code:
#if STACK_USE_CCS_PICENS
#include <18F4620.h>
#use delay(clock=40000000)
#fuses H4, NOWDT, NOLVP, NODEBUG


Above configuration is by CCS stack
SO is there any possibility for rs232 working in above conditions Exclamation
_________________
sohail khan
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 23, 2008 12:12 am     Reply with quote

It should work. Add a #use rs232() statement below those statements.
sohailkhanonline



Joined: 06 Mar 2008
Posts: 35
Location: pakistan

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Wed Apr 23, 2008 2:02 am     Reply with quote

Its not working. Everything is working except rs232. Sad
_________________
sohail khan
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Wed Apr 23, 2008 6:45 am     Reply with quote

I am not sure you are understanding what PCM said. Did you change the crystal to 10MHZ as he indicated?

Just to be clear H4 means the oscillator frequency is multiplied times 4.
This means you CANNOT use the H4 fuse with a 20MHZ crystal. With a 20MHZ crystal your only option is 20MHZ.

You can use, for example, 4MHZ crystal+H4 to get 16MHZ or in this case as
PCM said 10MHZ crystal+H4 to get 40MHZ.

The use Delay() statement value must then match the resulting frequency of the oscillator AFTER the multiplier has been applied.

If you are clear on this I apologize for the short lesson but I wanted to make sure you understood.
sohailkhanonline



Joined: 06 Mar 2008
Posts: 35
Location: pakistan

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Wed Apr 23, 2008 10:11 pm     Reply with quote

Thanks
I understand..
May be the quality of crystal might be the reason
Any ways Thanks to PCM and all fellows.
Smile
_________________
sohail khan
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