problem with baudrate

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Andi
Posts: 19
Joined: Thu Nov 29, 2007 12:08 pm
Contact:

problem with baudrate

Post by Andi »

My problem is:
i set the baud rate in the rs232 component properties to 9600
when i compile the flowcodefile in the c-file stands:

#define FC_RS232_SPBRG_VAL 127

and if i check my baudrate via a scope then i have 16 baud...
what did i do wrong?

regards, andi

User avatar
mytekcontrols
Posts: 95
Joined: Sun Aug 19, 2007 6:38 pm
Location: Santa Rosa, California
Has thanked: 4 times
Been thanked: 7 times
Contact:

Re: problem with baudrate

Post by mytekcontrols »

Since the RS232 is hardware based, the baudrate is also determined by what clock speed you are running the chip at (e.g.; crystal frequency). So it would be important to have the flowcode clock speed setting be the same as the actual crystal in use, in order to get an accurate baudrate. Although I doubt if you are off by as much as your message indicated, because "16" would be an extremely slow baud rate 8)
Michael St. Pierre
FlowCode V3&V4 Pro Registered User
Manufacture: Heat Load Controllers,
and a variety of other widgets.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: problem with baudrate

Post by Benj »

Thats spot on. :mrgreen:

You also have to tell the chip to use the XTAL configuration (HS in expert mode for a 19.6608MHz crystal).

This is done through the Chip -> Configure menu. You will also have to switch your hardware to XTAL mode if you are using our programmer boards.

Let us know if you are still having problems.

Andi
Posts: 19
Joined: Thu Nov 29, 2007 12:08 pm
Contact:

Re: problem with baudrate

Post by Andi »

i use the internal oscilator from the pic (19Mhz)

i send one character via rs232 ( 'a' ) to a max232 and then to the hyperterminal of a pc
i watch the outputs/inputs with an osciloscope
(one scope at the tx output of the pic one scope at the max232 output)

the programm works fine, also the character 'a' can be sent and received correctly
just in the hyperterminal i dont receive anything, because for the hyperterminal its impossible to work with 16 Baud

but when i look at the whole transmitted data, i recognised, that i send each single bit form 'a' with 16Hz so that means i have 16Baud... right?

do you have any tipps to solve my little problem? :roll:

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: problem with baudrate

Post by Benj »

Hello Andi

Which PICmicro are you using. I dont think any of the internal oscillators run at 19MHz. I have seen some that can be made to run at 8MHz.

Sounds like the problem is due to the chip running far slower then it actually is. Try reducing the speed in Flowcode to 4MHz or 8MHz.

Andi
Posts: 19
Joined: Thu Nov 29, 2007 12:08 pm
Contact:

Re: problem with baudrate

Post by Andi »

i changed now the oszillator frequenzy to 4MHz
i use the internal oscilator, (output on RA6 and RA7)
when i measure the frequenzy on these outputs, i measure a frequenzy of 313Hz...

how is this possible? What is my mistake?

I also added some pics, and my programme codes

this is the frequenzy on RA7, the upper siganl is the output on the TX pin
Image

this are the pic configurations
Image

this is the frequenzy configuration
Image
Attachments
Test.c
(6.68 KiB) Downloaded 332 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: problem with baudrate

Post by Benj »

Hello Andi

For a start disable the watchdog timer in your configuration. This will provide you with no end of problems as the watchdog timer resets the microcontroller on a regular timeout if it is enabled.

Next try adding a C code block to the start of your program with the following line of code.

Code: Select all

osccon = osccon | 0x70;
This should assign the 8MHz Clock to the internal oscillator.

It might also be worth playing around with the different configuration settings that are available.

My advice would be to set the clock speed in Flowcode to 8000000.
Then create the following simple program:

Loop Begin
switch on a LED
wait a second
Switch off the LED
Wait a second etc
Loop End

Then start playing around with the configuration settings until you have a program that is switching on and off the LED roughly every second. You will not get an exact clock as the internal clock is RC driven and as such fluctuates with pressure, humidity and temperaure. However it should get fairly close eg so you would not physically be able to tell the difference.

Post Reply