With osc set to 8MHz and baud set to 2400bps (software mode ), then with Hitec compiler baud = 758bps an error of 68%
Unable to set custom to adjust for error as this is not supported with V5.
Is there anything I could try please?
Martin
RS232 not working in software mode
Moderator: Benj
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- 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: RS232 not working in software mode
Hi Martin,
Sorry to hear this isn't working, I tried very hard to get this code bulletproof but it seems you may have found a hole.
Right the file you are looking for is as follows.
"C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_UART.c"
Near the top of the file you will see the definitions that regulate the software UART baud rate.
What version of HiTech are you using as I tested the HiTech define and it seems to work ok for me. Maybe I didn't take the baud as low as 2400 on the HiTech tests. I do know BoostC was tested a lot more thoroughly.
There should be a constant defined for HiTech which I used for testing. Try editing this constant until the bps error is as low as possible.
Sorry to hear this isn't working, I tried very hard to get this code bulletproof but it seems you may have found a hole.
Right the file you are looking for is as follows.
"C:\Program Files\Flowcode\v5\CAL\PIC\PIC_CAL_UART.c"
Near the top of the file you will see the definitions that regulate the software UART baud rate.
What version of HiTech are you using as I tested the HiTech define and it seems to work ok for me. Maybe I didn't take the baud as low as 2400 on the HiTech tests. I do know BoostC was tested a lot more thoroughly.
There should be a constant defined for HiTech which I used for testing. Try editing this constant until the bps error is as low as possible.
Code: Select all
#ifdef _BOOSTC
#define INST_COUNT 45 //65 for lower speeds or 40 for higher speeds.
#endif
#ifdef HI_TECH_C
#define INST_COUNT 315
#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
- 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: RS232 not working in software mode
Thinking about it does your HiTech still have optimisations enabled. Could be something to do with this.
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: RS232 not working in software mode
yes, new pc with new Microchip mplab installed so optimisations is enabled.Benj wrote:Thinking about it does your HiTech still have optimisations enabled. Could be something to do with this.
I will try your suggestion, and will let you know how it goes.
Hitec version is 9.81
Thanks for a very fast response Ben.

Martin
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: RS232 not working in software mode
Now sorted. With Hitec version is 9.81 setting for 2400 has to be 672 to give a baud rate of 2400
Can the custom for software baud be re-enabled for V5?
That would be handy especially if there is a variance between Hitec versions.
Thanks again.
Martin
Can the custom for software baud be re-enabled for V5?
That would be handy especially if there is a variance between Hitec versions.
Thanks again.
Martin
Martin
- 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: RS232 not working in software mode
Great glad you got it working Martin,
I will see if I can move these constants back into the C code component files so the values are customisable.
I will see if I can move these constants back into the C code component files so the values are customisable.
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
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: RS232 not working in software mode
That would be great!Benj wrote: I will see if I can move these constants back into the C code component files so the values are customisable.
Thanks Ben
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: RS232 not working in software mode
Hi Ben, I have made the following change to PIC_CAL_UART.c
which allows a software custom setting for RS232.
It does work and appears to be the easiest way I can think of.
Do you see any issues with this?
Martin
which allows a software custom setting for RS232.
It does work and appears to be the easiest way I can think of.
Code: Select all
//#ifndef MX_SOFT_BAUD_1
//#error "UART Baud Rate not supported in Software Mode"
//#endif
//#else
#define MX_SOFT_BAUD_1 (((MX_CLK_SPEED / MX_UART_BAUD_1) - 16) / 16)
Martin
Martin
- 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: RS232 not working in software mode
Hi Martin,
Ah I see what your doing there, good thinking. Yes that sounds good to me and glad it is working well as its certainly an elegant solution. Maybe a little difficult to explain to a user but I guess most won't be using the HiTech compiler and therefore need the workaround anyway.
Thanks for letting me know.
Ah I see what your doing there, good thinking. Yes that sounds good to me and glad it is working well as its certainly an elegant solution. Maybe a little difficult to explain to a user but I guess most won't be using the HiTech compiler and therefore need the workaround anyway.
Thanks for letting me know.
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