Custom Baud rate assistance

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Custom Baud rate assistance

Post by Ondra »

Good day all.
I am working with a esp8266 module. On start up is spits out data at a fixed baud rate of 74880. I want to be able to receive at the fixed rate than change over to 2400 bps. looking at the help file my options don't allow me to select outside of the options available. I thought to set the main speed to 74880 then change to 2400, question is how do I convert back to the custom speed of 74880 and or how do I add a custom speed to the ChangeHWBaud (Newbaud) function?

ChangeHWBaud (Newbaud)
Allows the baud rate for a hardware UART channel to be updated on the the fly.
The New baud parameter specifies the rate for the new baud.
0 = 1200 bps
1 = 2400 bps
2 = 4800 bps
3 = 9600 bps
4 = 19200 bps
5 = 38400 bps
6 = 57600 bps
7 = 115200 bps

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: Custom Baud rate assistance

Post by Benj »

Hello,

If you look in the PIC_CAL_UART file in the "Flowcode 5\PIC\CAL\PIC\" folder using a text editor.

Browse to line 317 and you should see this section of code.

Code: Select all

	#define MX_HARD_BAUD_1200	(((MX_CLK_SPEED / 1200) - 16) / 16)
	#if (MX_HARD_BAUD_1200 > 255)
		#undef MX_HARD_BAUD_1200
		#define MX_HARD_BAUD_1200	(((MX_CLK_SPEED / 1200) - 16) / 64)
		#define MX_HARD_SLOW_1200	1
	#else
		#define MX_HARD_SLOW_1200	0
	#endif
Change the 1200 for your new rate 74880 and you can then use the 1200 baud setting in the ChangeHWBaud function to switch to 74880.

Code: Select all

	#define MX_HARD_BAUD_1200	(((MX_CLK_SPEED / 74880 ) - 16) / 16)
	#if (MX_HARD_BAUD_1200 > 255)
		#undef MX_HARD_BAUD_1200
		#define MX_HARD_BAUD_1200	(((MX_CLK_SPEED / 74880 ) - 16) / 64)
		#define MX_HARD_SLOW_1200	1
	#else
		#define MX_HARD_SLOW_1200	0
	#endif
Of course you could override any of the other baud rates or even append your own rates to the end, I just chose 1200 because it's the first one.

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: Custom Baud rate assistance

Post by Ondra »

Hi Benj
Thanks for the quick response. I made the changes but I just get garbled characters.
I created an echo loop that takes/captures the received character and sends it back via second port.
I also did this with the native usart values and it worked fine. If it makes a difference and if it helps
I am using a Pic 18lf46k80 with a 19660800 external crystal .

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Re: Custom Baud rate assistance

Post by Ondra »

Good day all.
Hi Ben, any additional suggestions on this?
thanks in advance

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: Custom Baud rate assistance

Post by Benj »

Hi Ondra,

I'm not sure I can suggest much more for you, maybe you could post your modified file and I'll have a quick look.

v5 and for that matter v6 is no longer under support so I can't do too much.

Are you sure of the baud rate of the initial data?

Post Reply