News:

Let's find out together what makes a PIC Tick!

Main Menu

HSerial2_ChangeBaud

Started by galvinfreeman, May 19, 2025, 10:40 AM

Previous topic - Next topic

galvinfreeman

Pic 18F47K40 @ 64Mhz
I get an Error when using "HSerial2_ChangeBaud"
ASM error 113    A.S 4710:Symbol not previously defined (SP2BRGLH)
How and where do I set These?

Thanks.

DaveS

Quote from: galvinfreeman on May 19, 2025, 10:40 AMPic 18F47K40 @ 64Mhz
I get an Error when using "HSerial2_ChangeBaud"
ASM error 113    A.S 4710:Symbol not previously defined (SP2BRGLH)
How and where do I set These?
Thanks.
Hi Galvin

In the PPI file P18F47K40.ppi
Located at C:\Program Files (x86)\ProtonIDE\PDS\Includes\PPI\
Mchip keeps changing the names it's missing from the PPI file
You will find listed
SP2BRG EQU 0X0E9B
SP2BRGL EQU 0X0E9B
SPBRG2 EQU 0X0E9B

SP2BRGH EQU 0X0E9C
SPBRGLH2 EQU 0X0E9C
SPBRGH2 EQU 0X0E9C

SP2BRGLH is not listed, SPBRGLH2 is

Add this to your bas file
$ifndef SP2BRGLH
  $ifdef SPBRGLH2
    $define SP2BRGLH SPBRGLH2
  $endif
$endif

Regards Dave

top204

#2
What compiler version are you using?

There are no assembler errors in the latest Positron8 compiler. Tested with the code listing below:

    Device = 18F47K40
    Declare Xtal = 64
'
' Setup USART2
'
    Declare Hserial2_Baud = 9600
    Declare HRSOut2_Pin   = PORTC.6
    Declare HRSIn2_Pin    = PORTC.7

'--------------------------------------------------------------------
' The main program starts here
'
Main:  
    HSerial2_ChangeBaud(115200)
    HRSOut2Ln "Hello World"

I've tried various Xtal values and Baud values, to see if the re-arrangement of the 8-bit or 16-bit Baud generator is the problem when the compiler uses its calculations to see what is better, and more accurate, to use, then sets up the SFRs. But they all compile and assemble correctly.

I even compiled it with an earlier version 4.0.5.6 Positron8 compiler, and it compiled and assembled correctly.

Can you post a code listing snippet showing the problem, as I may have missed checking for a particular SFR with the calculations and the SFR juggling that takes place for different devices, and give the compiler version?