PDA

View Full Version : PBP LONG and string-formatting not working ?



Marcick
- 20th January 2021, 15:57
Hi all,
I'm using PbP3.1 with a PIC18F device.
I need to use the LONG option in a particular program, but seems like the string-formatting modifier does not work properly.
For example


FileOffset VAR WORD
FileOffset=12345
Hserout2 ["Fileoffset=",DEC FileOffset,13,10]

Should send this string

Fileoffset=12345

but I see only this

Fileoffset=,

Also the other modifiers BIN, HEX does not work
If I remove the "LONG" option in the compiler settings the string is formatted properly.

Any idea ?

HenrikOlsson
- 20th January 2021, 16:23
That's weird. I'm working on a large project right now, have LONGs enabled and, except for one thing*, have not noticed any such problems. Have been using DEC, BIN, HEX extensively.

You show a comma being output after the equal-sign, is that actually being output or is that an error?

Have you tried with HSEROUT instead of HSEROUT2? Have you tried actually USING a LONG as your variable, instead of a WORD as you're currently doing (both should work of course).

The one thing I stumbled upon is that using the #modifier does not work properly with LONG variables as it rolls over at 65535 so when outputting decimal digits of a LONG variable I had to specifically use DEC.

Marcick
- 21st January 2021, 14:24
ok, it seems troubles are related to a wrong use of "DEFINE RESET_ORG" statement (I'm working on a bootloader code).
Without it everything works fine also with the "PBP LONG" option enabled.
Thanks

Marcick
- 21st January 2021, 14:27
That's weird. I'm working on a large project right now, have LONGs enabled and, except for one thing*, have not noticed any such problems. Have been using DEC, BIN, HEX extensively.

You show a comma being output after the equal-sign, is that actually being output or is that an error?

Have you tried with HSEROUT instead of HSEROUT2? Have you tried actually USING a LONG as your variable, instead of a WORD as you're currently doing (both should work of course).

The one thing I stumbled upon is that using the #modifier does not work properly with LONG variables as it rolls over at 65535 so when outputting decimal digits of a LONG variable I had to specifically use DEC.

I see just now your reply. As I told, removing the "DEFINE RESET_ORG" statement then no problem at all.
And yes, I also discovered the # does not work and a DEC is required.
Thanks !

Marcick
- 22nd January 2021, 12:18
Me again guys, problem still exist....

I'm working on a bootloader, based on this thread (http://www.picbasic.co.uk/forum/showthread.php?t=21100&highlight=bootloader)
This code require the PBP LONG option enabled as I have to write code above 64K and LONG variables are required.
In my adapted bootloader code, I have to use HEX and DEC modifiers, as in the example of the first post.
Testing normally with ORG 0, everything work fine, but then the code needs to be compiled with

"DEFINE RESET_ORG 1D800h ' Move all library sub and code to start from that location "

so the bootloader will stay in the last area of the memory.
And with this DEFINE, the first line where I use a DEC or HEX modifiers cause a reset of the chip.

Hope I have explained well. I don't know what to do now.
Not using DEC or HEX is really hard, they are very powerful ....
Any idea ?

Marcick
- 22nd January 2021, 13:38
I'm turning crazy ... I see the problem also without the PBP LONG option

I copy here the full code to show the problem.



DEFINE RESET_ORG 1EC00h
' device=PIC18F67K22
' PBP LONG option enabled

#CONFIG
CONFIG RETEN = ON ; Enabled
CONFIG INTOSCSEL = LOW ; LF-INTOSC in High-power mode during Sleep
CONFIG SOSCSEL = DIG ;
CONFIG XINST = OFF ; Disabled
CONFIG FOSC = INTIO2 ; Internal RC oscillator
CONFIG PLLCFG = OFF ; Enabled
CONFIG FCMEN = OFF ; Disabled
CONFIG IESO = OFF ; Disabled
CONFIG PWRTEN = OFF ; Disabled
CONFIG BOREN = SBORDIS ; Enabled in hardware, SBOREN disabled
CONFIG BORV = 2 ; 2.0V
CONFIG BORPWR = ZPBORMV ; ZPBORMV instead of BORMV is selected
CONFIG WDTEN = OFF
CONFIG WDTPS = 256 ; 1:256
CONFIG RTCOSC = SOSCREF ; RTCC uses SOSC
CONFIG CCP2MX = PORTC ; RC1
CONFIG MSSPMSK = MSK7 ; 7 Bit address masking mode
CONFIG MCLRE = ON ; MCLR Enabled, RG5 Disabled
CONFIG STVREN = ON ; Enabled
CONFIG BBSIZ = BB2K ; 2K word Boot Block size
CONFIG DEBUG = OFF ; Disabled
CONFIG CP0 = OFF ; Block 0 (000800, 001000 or 002000-003FFFh) not code-protected
CONFIG CP1 = OFF ; Block 1 (004000-007FFFh) code-protected
CONFIG CP2 = OFF ; Block 2 (008000-00BFFFh) code-protected
CONFIG CP3 = OFF ; Block 3 (00C000-00FFFFh) code-protected
CONFIG CP4 = OFF ; Block 4 (010000-013FFFh) code-protected
CONFIG CP5 = OFF ; Block 5 (014000-017FFFh) code-protected
CONFIG CP6 = OFF ; Block 6 (01BFFF-018000h) code-protected
CONFIG CP7 = OFF ; Block 7 (01C000-01FFFFh) code-protected
CONFIG CPB = ON ; Boot Block (000000-0007FFh) code-protected
CONFIG CPD = OFF ; Data EEPROM code-protected
CONFIG WRT0 = OFF ; Block 0 (000800, 001000 or 002000-003FFFh) not write-protected
CONFIG WRT1 = OFF ; Block 1 (004000-007FFFh) not write-protected
CONFIG WRT2 = OFF ; Block 2 (008000-00BFFFh) not write-protected
CONFIG WRT3 = OFF ; Block 3 (00C000-00FFFFh) not write-protected
CONFIG WRT4 = OFF ; Block 4 (010000-013FFFh) not write-protected
CONFIG WRT5 = OFF ; Block 5 (014000-017FFFh) not write-protected
CONFIG WRT6 = OFF ; Block 6 (01BFFF-018000h) not write-protected
CONFIG WRT7 = OFF ; Block 7 (01C000-01FFFFh) not write-protected
CONFIG WRTC = OFF ; Configuration registers (300000-3000FFh) not write-protected
CONFIG WRTB = OFF ; Boot Block (000000-007FFF, 000FFF or 001FFFh) not write-protected
CONFIG WRTD = OFF ; Data EEPROM not write-protected
CONFIG EBRT0 = OFF ; Block 0 (000800, 001000 or 002000-003FFFh) not protected from table reads executed in other blocks
CONFIG EBRT1 = OFF ; Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
CONFIG EBRT2 = OFF ; Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
CONFIG EBRT3 = OFF ; Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
CONFIG EBRT4 = OFF ; Block 4 (010000-013FFFh) not protected from table reads executed in other blocks
CONFIG EBRT5 = OFF ; Block 5 (014000-017FFFh) not protected from table reads executed in other blocks
CONFIG EBRT6 = OFF ; Block 6 (018000-01BFFFh) not protected from table reads executed in other blocks
CONFIG EBRT7 = OFF ; Block 7 (01C000-01FFFFh) not protected from table reads executed in other blocks
CONFIG EBRTB = OFF ; Boot Block (000000-007FFF, 000FFF or 001FFFh) not protected from table reads executed in other blocks
#ENDCONFIG

DEFINE OSC 8
DEFINE HSER2_RCSTA 90H
DEFINE HSER2_TXSTA 24H
DEFINE HSER2_BAUD 19200
DEFINE HSER2_CLROERR 1

CLEAR
OSCCON =%01100000 ; Primary oscillator, internal 8MHz
OSCCON2.0 =1
OSCTUNE.7 =1
Adr VAR WORD

loop1:
FOR Adr=1000 TO 1005
HSEROUT2 ["test1: ",13,10] ' -->>>> this works always
HSEROUT2 ["test2: ", DEC4 Adr,13,10] ' -->>>> this works only if you comment the first line "DEFINE RESET_ORG 1EC00h"
NEXT Adr
PAUSE 1000
CLEARWDT
goto loop1