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

Bad Baudrate at 64MHz

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



Joined: 22 Jan 2018
Posts: 34
Location: North of France

View user's profile Send private message

Bad Baudrate at 64MHz
PostPosted: Mon May 21, 2018 11:53 am     Reply with quote

Hello to all.

I try to use the EUSART at 19200 baud on a 18F26K80 and i can't understand why at 32MHz with the internal oscillator, the baudrate is equal at 19200 and can be read on my laptop at 19200 Baud and
when i configure the PIC at 64MHz (internal oscillator), the baud rate can be only read when i configure the laptop at 14400 Baud!!!

When i use a baudrate like 9600..... everything is fine.... at 32MHz and 64 MHz!


Do you have an idea on this kind of problem?

Wish you all the best!

MAnu
_________________
CCS + ICD3 + PIC18F46K80
temtronic



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

View user's profile Send private message

PostPosted: Mon May 21, 2018 12:35 pm     Reply with quote

Please post your small, compilable test program. It must be an old laptop if it's got a real RS-232 comport ! You aren't using a TTL<>USB module are you?

I've run an 18F46K22 at 64 MHz, internal, looped BOTH HW UARTS to itself then a PC (old, REAL Comports) with problems....

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Mon May 21, 2018 12:36 pm     Reply with quote

Try adding BRGHOK to your RS232 setup.
Not having this enabled limits the settings the UART can do. May be causing an issue. However it is difficult to see how it'd get /1.33....
Manu59114



Joined: 22 Jan 2018
Posts: 34
Location: North of France

View user's profile Send private message

PostPosted: Mon May 21, 2018 2:21 pm     Reply with quote

Thanks for your quick reply! Wink

To Ttelmah,
I add "BRGH1OK" with no success!

What i forget to explain....
When i use this config:
#use delay(internal=32000000)
#use rs232(baud=256000,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1,BRGH1OK)

I can read with my laptop all baudrate...;no problem with 256000.

with i change the value with 64000000.

The program works at 64Mhz...timing is right.... Led blinking fine at the right timing but the RS232 output is wrong!
If i choose Baud=19200 on CCS...i can read all values at 14400 on my laptop (with a new cable USB FTDI Chip).

Code:

works like a charm:

#include <18F26K80.h>
#device ADC=16

//#FUSES WDT                      //Watch Dog Timer
//#FUSES WDT1                     //Watch Dog Timer uses 1:1 Postscale

#use delay(internal=32000000)
#use rs232(baud=256000,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1,BRGH1OK)     
#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3,force_hw)
                           
#define LED PIN_B5           
#define DELAY 1000 


Doesn't work

#include <18F26K80.h>
#device ADC=16

//#FUSES WDT                      //Watch Dog Timer
//#FUSES WDT1                     //Watch Dog Timer uses 1:1 Postscale

#use delay(internal=64000000)
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1,BRGH1OK)     
#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3,force_hw)
                           
#define LED PIN_B5           
#define DELAY 1000



Main.c
#include <test uart 64MHz.h>

void main()             
{

   while(TRUE)
   {
                                           
      //Example blinking LED program
      output_low(LED);
      printf("OFF");
      delay_ms(DELAY);
      output_high(LED);
      printf("ON");
      delay_ms(DELAY);

      //TODO: User Code
   }




Wish you a great and sunny day!!!
_________________
CCS + ICD3 + PIC18F46K80
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Mon May 21, 2018 2:49 pm     Reply with quote

Critical question.
What compiler version?.

That way we can compile and see what register values are being set with the same compiler.....
MikeW



Joined: 15 Sep 2003
Posts: 184
Location: Warrington UK

View user's profile Send private message

PostPosted: Tue May 22, 2018 1:36 am     Reply with quote

I would bet its because he is using the internal RC oscillator.

Its not that accurate.

Try an external crystal, also is the PIC well decoupled at the Vcc/gnd pins ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Tue May 22, 2018 1:59 am     Reply with quote

He is using that when he is at 32MHz as well.
Not 33% error.
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Tue May 22, 2018 8:05 am     Reply with quote

OK. I've just built it with the current compiler, and the settings are right:
Code:

#include <18F26K80.h>
#device ADC=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOXINST
#FUSES NOMCLR
#FUSES NOIESO
#FUSES NOFCMEN
#FUSES STVREN

#use delay(internal=64MHz)
#use rs232(BAUD=19200, PARITY=N, UART1, BITS=8, ERRORS, BRGH1OK)

void main()
{

   while(TRUE)
   {
      //At this point PLLEN is set to 1 (so 64 MHz selected).
      //TXSTA1 = 0xA6 clock from BRG, ASYNC, TXEN, HSEN
      //RCSTA1 = 0x90 CREN, SPEN
      //BAUDCON1 = 0x48 16bit BRG selected, RX idle
      //SPBRG1= 0x340 Fosc/(4*n+1) n = 833 (/3332) -> 19207Hz
      putc('A');

      delay_ms(10);
   }
}


When it arrives at the putc, all the UART1 registers are set correctly to generate 19200bps (actually set to generate 19207 bps).
Manu59114



Joined: 22 Jan 2018
Posts: 34
Location: North of France

View user's profile Send private message

PostPosted: Wed May 23, 2018 5:11 am     Reply with quote

Hi Ttelmah, Hi Temtronic, Hi MikeW
This morning, i investigated the problem and i found the solution. it's Resolved!!!

I used a scope and i finally view that the voltage on the TX output was only 2 volts.

I measured Voltage on the PCB on these point:
Main input power connector: 3.3Volts.
On the SMD decoupling capacitor very closed to VDD pin of the PIC, i measured 3.3Volts.

And..........On the PIC18F26K80 VDD pin....... the voltage was......2.12Volts!
On the VDD pad there was a micro wire cut! ....need a magnifying glass to see the brake between the wire and the VDD pad.

The difficulty for me to found where was the problem was that all of lectronic parts of the PCB working fine....

Everything work at 32MHz (PIC, All hardware parts and Uart at all Baudrate!)

at 64MHz
Every electronic parts working except baudrate up to 9600.
Good Timing...except for the UART)

Found in the PIC18F66K80 Family Datasheet.....
VOLTAGE-FREQUENCY GRAPH fig 31.1
For VDD values 1.8V to 3V, FMAX = (VDD – 1.72)/0.02 MHz

in my case

(2.12-1.72)/0.02= 20MHz!!!
I was Lucky because at 32MHz...i had no problem!


Hope that my problem will help some people....
Thank you to all for help me....
Thank you to all for your quick answers.
Wish you all the best!
_________________
CCS + ICD3 + PIC18F46K80
temtronic



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

View user's profile Send private message

PostPosted: Wed May 23, 2018 6:13 am     Reply with quote

Glad you found BOTH problems, 1 hardware, one software..

I need a *5 mag to see PCBs these days, sigh, getting old...

Usually I think of PICs running off 5 volts( again I'm old..somr of my PICs have windows on them !). The frequency vs VDD is an important spec, all too often overlooked. The other is the 'stability' or 'accuracy' of the internal oscillators vs temperature. Get too hot or too cold and ...'hmm it doesn't work anymore'....

cheers
Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Wed May 23, 2018 6:57 am     Reply with quote

Yes. I'm the only person at my company who will debug SMD stuff. I even have a SMD microscope.

Makes amazing 'sense' the chip running off a lower voltage than it should be...
Even more amazing was that it worked at 9600bps. Think about it the chip would stll have been clocking at 64Mhz!...

Glad you have found it.
newguy



Joined: 24 Jun 2004
Posts: 1911

View user's profile Send private message

PostPosted: Wed May 23, 2018 7:23 am     Reply with quote

We have a fully featured assembly line consisting of a paste machine, pick & place, and a reflow oven. Pick & place is capable of 0201 components. I spec'd this: http://www.st.com/en/power-management/led2472g.html for a prototype (in the 5mm VFQFPN leadless package) and I managed to successfully solder 3/5 prototypes by hand using solder paste, a microscope, and a cheapo drawer-based reflow oven. Despite that, and despite our line's capabilities I still caught grief from our production staff that the component was "too small for the machine."

...Since the hand soldered prototypes we've run nearly a thousand with zero issues.

OP: congratulations on finding such a non-obvious problem. Well done!
Manu59114



Joined: 22 Jan 2018
Posts: 34
Location: North of France

View user's profile Send private message

PostPosted: Fri May 25, 2018 6:15 am     Reply with quote

Hello

Just for information

I tested my board with a Numerique adjustable power supply.

( PIC18F26K80)
All is ok at 64MHz with a voltage of 2.70V.

At 2.62Volt... the UART is the first part to give up! but the rest work!

Wish you a nice weekend!

Manu
_________________
CCS + ICD3 + PIC18F46K80
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Fri May 25, 2018 6:20 am     Reply with quote

Something has to be first... Smile

Just amazing that everything else was working!.
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