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

PIC18F13K50 Serial Problem

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



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PIC18F13K50 Serial Problem
PostPosted: Sun Jul 24, 2011 1:36 pm     Reply with quote

Hi I am trying to receive serial text from PIC18F13K50.

I can see some Zeros in the HEX window of the Serial Monitor. But Nothing in the ASCII Window.

http://imageshack.us/photo/my-images/16/serialmonitorimage.jpg/

I tried HyperTerminal also there is nothing being received in Hyperterminal either.

I have connected a Oscilloscope probe to TX Pin of the Pic there is a waveform as can be seen in the jpg attachment

http://imageshack.us/photo/my-images/190/oscilloscopeimage.jpg/

Can anyone please tell me what could be the problem here.

Many Thanks

Code:

#include <18F13K50.h>   //

#fuses  NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600,parity=N,xmit=PIN_B7,rcv=PIN_B5,bits=8)


//    M A I N
void main(void) {


while (1){

printf("hello");
       
 }
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Sun Jul 24, 2011 3:39 pm     Reply with quote

What is your oscillator?.
You have not selected an oscillator fuse, so the chip will be running some default - probably the internal oscillator. It looks as if the waveform is about 50+% fast, so possibly clocking at something like 16MHz, rather than the 10Mhz you have everything set to use....

Select an oscillator.

Best Wishes
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Sun Jul 24, 2011 4:50 pm     Reply with quote

Hi it is a external 10 MHz crystal
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jul 24, 2011 4:53 pm     Reply with quote

Also be sure to add 'errrors' to the use rs232(...) options..
and you do have a MAX232 or equal in your circuit right ??!!
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Sun Jul 24, 2011 4:56 pm     Reply with quote

I am using the CCS Software Development kit. This has a RS232 ic built in.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jul 24, 2011 6:42 pm     Reply with quote

Quote:
I am using the CCS Software Development kit

I looked at the following CCS page and I don't see anything with that name:
http://www.ccsinfo.com/content.php?page=development-kits
Post a link to CCS kit that you actually have.

Quote:
it is a external 10 MHz crystal.

Then you need to add the HS fuse to your #fuses statement.

Also, post your compiler version. It's given at the top of the .LST file,
which will be in your project directory. It's a 4-digit number in this
format: x.xxx
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 2:05 am     Reply with quote

deltatech wrote:
Hi it is a external 10 MHz crystal


Good. The point is though that your _code_, does not use this.

You need the fuse selected to say what oscillator to use. You have no oscillator fuse in your code. hence the crystal won't be used. The code is _not_ running at 10MHz, from the waveforms published. The default for fuse bits, is for them to be set to '1', if not programmed to another state. The pattern 1x, on the oscillator selection fuses, selects the _internal_ clock.

HS says 'use the external crystal'.

Best Wishes
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 5:47 am     Reply with quote

Thanks PCM programmer . The KIT is called

ACE Kit
Sku: S-137

Compiler version is 4.093
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 5:51 am     Reply with quote

Ttelmah thanks for your advice. But I don't know how to set the code for external crystal.

When I used the Project Wizard there was no option for selecting external crystal only the frequency was set to 10MHz.

Would be kind enough to send me this line of code.

Many Thanks
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 6:38 am     Reply with quote

I have added the following line to the fuse code but still there is nothing being received on hyper terminal


Code:

#fuses XT,HS, NOWDT, BROWNOUT, PUT, NOLVP
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 7:34 am     Reply with quote

You must _not_ enable two oscillators.
Just one. The oscillator fuses are 'either or' selections not 'turn on more as needed'. You need the HS fuse, not the XT fuse. Setting both, gives potentially an impossible combination. XT in fact overrides HS, and should probably work, but you also need to disable the PLL, the default is for this to be enabled, so you will be running at 40MHz, not 10MHz.
It is in the Wizard. Third line down in the fuses box. A pulldown offering you what type of oscillator to use.
Code:

#include <18LF13K50.h>
#device adc=10
#FUSES NOWDT, CPUDIV1, USBDIV1, HS, NOPLLEN, NOPCLKEN, NOFCMEN, NOIESO, NOBROWNOUT, NOLVP, NOXINST
#use delay(clock=10000000)


Best Wishes
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 8:24 am     Reply with quote

Ttelmah I added the Fuses you advised the compiler didn't like NOPCLKEN I removed this fuse and compiled.

And it is working perfectly. Now I am getting text in hyperterminal perfect.

Thanks you your help you are great
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Jul 25, 2011 8:42 am     Reply with quote

That depends on compiler version. The NOPCLKEN, is not in 4.099, but is there from a couple of versions latter. It controls whether the primary clock is enabled, or under software control.

Best Wishes
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