News:

;) This forum is the property of Proton software developers

Main Menu

Using Positrons USART Baud calcs

Started by TimB, Apr 13, 2023, 06:13 PM

Previous topic - Next topic

TimB

Hi all

I have in my code been using the declare for the baud rate

   Declare Hserial_Baud = 38400 ' Set Baud rate to 38400

It works great but unless I actually use HRsout it does not set the regs. As I have my own usarts interrupt code I really need to set SPBRGH1 etc my self

The issue as that all the baud rate calcs do not produce the right value value. So I searched the ASM for the setting but cannot find it.

Any idea how the compiler sets the reg?


John Lawton

#1
Quote from: TimB on Apr 13, 2023, 06:13 PMThe issue as that all the baud rate calcs do not produce the right value value.
I've always used PIC multi-calc from Mr E and it has worked on all the devices I've needed it for. What device are you using?

Here is a link to the version I have: https://www.picbasic.co.uk/forum/attachment.php?attachmentid=7551&d=1225550328

TimB


I'm using a Pic18F27Q10

I used a VSM to extract the value from the SPBRGH1 etc regs but never found it in the asm

Thanks for the file but it does not run on my machine it says msstdfmt.dll is missing


I found the right setting for a the 18f27Q10 at 64mhz using the VSM method above to be

        SPBRGH1 = 0                                                             'EUSARTx Baud Rate Generator Register High Byte
        SPBRG1 = $67                                                            'EUSARTx Baud Rate Generator Register Low Byte

John Lawton

Sorry the program doesn't run, my PC is running Win 7 and it works fine. If you want to pursue this problem, this video shows how you can fix the missing DLL file issue on Win 10.

https://www.youtube.com/watch?v=GNes-h75rzc


Using PIC Multicalc, there are two good options with BRG16 = 1:

BRGH = 0  SPBRGH = 0 SPBRG = 103  Baud = 38462 Error 0.16%
BRGH = 1  SPBRGH = 1 SPBRG = 160  Baud = 38369 Error -0.08%



TimB


Thanks John

BRGH = 0  SPBRGH = 0 SPBRG = 103  Baud = 38462 Error 0.16%
BRGH = 1  SPBRGH = 1 SPBRG = 160  Baud = 38369 Error -0.08%

Is right so I will make the effort to get the util working.

RGV250

Hi Tim,
I think I had this problem but not sure if I copied the file from an older PC or downloaded it.
This might help  https://thegeekpage.com/msstdfmt-dll-not-found/

Bob

top204

The USART declares only generate the code if a command that needs them is used, otherwise, they will waste code space with loading SFRs that are never required.

What I normally do in a situation like that is either create my own HRsoutX and HRsoutX command code in the main program's listing, if they are going to perform something extra in them, or issue a dummy HRsoutX or HRsinX command somewhere in the code listing that is never called, so the compiler sees them and generates the code for the declares for Baud and PPS at the beginning of the program.