View previous topic :: View next topic |
Author |
Message |
KaraMuraT
Joined: 16 May 2006 Posts: 65 Location: Ankara/Turkey
|
PIC16F726 AUSART issue (solved) |
Posted: Tue Mar 31, 2009 8:40 am |
|
|
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
|
|
Posted: Tue Mar 31, 2009 9:48 am |
|
|
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
|
|
Posted: Tue Mar 31, 2009 9:51 am |
|
|
Let me give the answer
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
|
|
Posted: Tue Mar 31, 2009 9:57 am |
|
|
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
|
|
Posted: Tue Mar 31, 2009 10:03 am |
|
|
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). |
|
|
|