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
Custom Baud rate assistance
Moderator: Benj
- 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
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.
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.
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.
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
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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Custom Baud rate assistance
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 .
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 .
Re: Custom Baud rate assistance
Good day all.
Hi Ben, any additional suggestions on this?
thanks in advance
Hi Ben, any additional suggestions on this?
thanks in advance
- 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
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?
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?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel