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

PIC16F726 AUSART issue (solved)

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



Joined: 16 May 2006
Posts: 65
Location: Ankara/Turkey

View user's profile Send private message Send e-mail

PIC16F726 AUSART issue (solved)
PostPosted: Tue Mar 31, 2009 8:40 am     Reply with quote

Hi,

I had problems with internal oscillator of 16F726. But I solved it with direct access to OSCCON. (CCS v4.084 does not write the OSCCON register correctly).

But with the right operation of both Internal oscillator or External crystal, the AUSART does not work correctly at 16 MHz. It behaves like the real speed of the PIC and the #use delay statement is not equal. The characters become just random rubbish. I tried to solve that with tuning the Internal oscillator with OSCTUNE, but it didn't help.

The PIC must run at 16 MHz speed. It is very strict because of the analog side of my design. And it runs on every speed, except 16 MHz. (I tried it with 8,4 and 2 MHz and it works)

Any suggestions are appreciated.

P.S: Actual PIC speed is 16 MHz. I measured it via CLK_OUT pin (4 MHz as Fosc/4)

CCS version: 4.084
MPLab version: 8.20a
PIC: PIC16F726-I/P Revision:0x07

Datasheet of 16F726:
http://ww1.microchip.com/downloads/en/DeviceDoc/41341B.pdf

Errata document:
http://ww1.microchip.com/downloads/en/DeviceDoc/80382C.pdf
_________________
/// KMT
/// www.muratursavas.com
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 31, 2009 9:48 am     Reply with quote

1. Post your #use rs232() statement.

2. What device is the PIC UART talking to ? Is it a PC ?
KaraMuraT



Joined: 16 May 2006
Posts: 65
Location: Ankara/Turkey

View user's profile Send private message Send e-mail

PostPosted: Tue Mar 31, 2009 9:51 am     Reply with quote

Let me give the answer Smile

I tried the possibilities and saw that somehow, with the correct #use delay and #use rs232 statements, the SYNC bit is set not correctly. It has to be "0" for Asynchronous transmisson, but it becomes 1 with the 16 MHz setup.

So, with the 4.084 CCS version, 16 MHz 16F72X PIC series, you have to set the OSCCON and SYNC bit yourself.

Here is the code:

Code:
// Register addresses:
#byte OSCCON    = 0x90
#byte SPBRG     = 0x99
#bit  BRGH      = 0x98.2
#bit  SYNC      = 0x98.4

// Register Values:
OSCCON = 0x30;
SPBRG  = 0x19;
BRGH   = 0;
SYNC   = 1;

_________________
/// KMT
/// www.muratursavas.com
KaraMuraT



Joined: 16 May 2006
Posts: 65
Location: Ankara/Turkey

View user's profile Send private message Send e-mail

PostPosted: Tue Mar 31, 2009 9:57 am     Reply with quote

Hi PCM programmer,

You have posted your reply while I was writing the answer.

Here are the statements:

Code:

#use delay(clock=16000000,RESTART_WDT)

#use rs232(stream=AUX,baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,ERRORS)


The PIC is communicating with PC via level converter.

As I said before, this is a problem with #use delay statement.

I think the 16F72X series is new, and CCS has some issues about them. I don't know whether the issues are solved or not with a new version. But I can see more problems in the header file like multiple definitions, and wrong oscillator values like OSC_16MHZ.

Also #use delay statement does not accept 500 KHz, but this PIC can run even with 62.5 KHz. So the limits are not defined right.

Correction: It accepts the concerning speeds. The PLLEN fuse was set while I was trying.

Regards,
_________________
/// KMT
/// www.muratursavas.com
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 31, 2009 10:03 am     Reply with quote

Report the bugs to CCS support (in detail). It's possible that they might
give you that version when they fix it. (If your maintenance has run out).
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