Unable to display floats

Discussion on both general simulation and Proteus VSM microcontroller simulation.
Post Reply
TimBox100
Professional User
Posts: 87
Joined: Wed 2019-03-13 13:26

Unable to display floats

Post by TimBox100 »

Hi,

I had this issue before in that the VSM will not display floats

The resolution I was given before was to use DT_FLOAT=MICROCHIP_BIGENDIAN

However this no longer works.

This is a deal breaker. I invested in Proetus to debug code but unless I use some really old Pic device I cannot get the VSM to function properly. I'm spending more time trying to find out why the VSM is not working than I do working on my code.
David
Site Admin
Posts: 2267
Joined: Mon 2006-02-20 14:56
Location: Head Office
Contact:

Re: Unable to display floats

Post by David »

Hi Tim,

Please can you email me your project and I will pass it to the dev guys, thanks.

Regards,
Dave.
Ettore
Labcenter Staff
Posts: 2932
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: Unable to display floats

Post by Ettore »

I tested DT_FLOAT=MICROCHIP_BIGENDIAN with PIC18F27Q10, PIC18F13K22, PIC16F1847 and PIC16F18877 and found them still working.
Kind regards,
Ettore Arena - Labcenter Electronics.
Ettore
Labcenter Staff
Posts: 2932
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: Unable to display floats

Post by Ettore »

TBH, PIC18F27Q10 and PIC16F18877 work with DT_FLOAT=MICROCHIP_BIGENDIAN only when .bas is loaded not .cof. Probably this is the issue.
Kind regards,
Ettore Arena - Labcenter Electronics.
TimBox100
Professional User
Posts: 87
Joined: Wed 2019-03-13 13:26

Re: Unable to display floats

Post by TimBox100 »

Hello

Attached is the project

Its as simple as I can make it to show the issue with
1 Floats
Other devices using COFF is not an issue. I have a sim a 1813k22 using a coff file and an 18F27Q10 and it displays floats OK on the 13k22 and not on the 27Q10 (image below) There may be a chance that the COFF generated for that device is different but I doubt it.

2 An issue where somewhere in the pic model it is messing up timing. e.g a delay of 245ms is correct and a delay of 1000ms is ignored
Just to state the obvious I have tested it in real life. The compiler produces the right code and it runs at the right speed in a real device
Its been an issue for a while and checked by the compiler writer here https://protoncompiler.com/index.php/topic,966.0.html

This is the code

Now since there are so many compilers for the pics I do not expect you to have to buy them all. In this case I will pay for it. If you can let me know where to send it (PM me) I will purchase a copy and get it sent to that email address

Code: Select all

    Device 18F27Q10

'-------------------------------------------------------------------------------
'**** Added by Fuse Configurator ****
' Use the Fuses Tab to change these settings

Config_Start
  FEXTOSC = OFF              ;Oscillator not enable
  RSTOSC = HFINTOSC_64MHZ    ;HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:
  CLKOUTEN = OFF             ;CLKOUT function is disable
  CSWEN = ON                 ;Writing to NOSC and NDIV is allowed
  FCMEN = ON                 ;Fail-Safe Clock Monitor enable
  MCLRE = EXTMCLR            ;MCLR pin (RE3) is MCL
  PWRTE = Off                 ;Power up timer is off
  LPBOREN = OFF              ;Low power BOR is disable
  BOREN = SBORDIS            ;Brown-out Reset enabled , SBOREN bit is ignore
  BORV = VBOR_190            ;Brown-out Reset Voltage (VBOR) set to 1.90
  ZCD = OFF                  ;ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCO
  PPS1WAY = ON               ;PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycl
  STVREN = ON                ;Stack full/underflow will cause Rese
  XINST = OFF                ;Extended Instruction Set and Indexed Addressing Mode disable
  WDTCPS = WDTCPS_31         ;Divider ratio 1:65536; software control of WDTP
  WDTE = OFF                 ;WDT Disable
  WDTCWS = WDTCWS_7          ;window always open (100%); software control; keyed access not require
  WDTCCS = SC                ;Software Contro
  WRT0 = OFF                 ;Block 0 (000800-003FFFh) not write-protecte
  WRT1 = OFF                 ;Block 1 (004000-007FFFh) not write-protecte
  WRT2 = OFF                 ;Block 2 (008000-00BFFFh) not write-protecte
  WRT3 = OFF                 ;Block 3 (00C000-00FFFFh) not write-protecte
  WRT4 = OFF                 ;Block 4 (010000-013FFFh) not write-protecte
  WRT5 = OFF                 ;Block 5 (014000-017FFFh) not write-protecte
  WRT6 = OFF                 ;Block 6 (018000-01BFFFh) not write-protecte
  WRT7 = OFF                 ;Block 7 (01C000-01FFFFh) not write-protecte
  WRTC = OFF                 ;Configuration registers (300000-30000Bh) not write-protecte
  WRTB = OFF                 ;Boot Block (000000-0007FFh) not write-protecte
  WRTD = OFF                 ;Data EEPROM not write-protecte
  SCANE = ON                 ;Scanner module is available for use, SCANMD bit can control the modul
  LVP = ON                   ;Low voltage programming enabled. MCLR/VPP pin function is MCLR. MCLRE configuration bit is ignore
  CP = OFF                   ;UserNVM code protection disable
  CPD = OFF                  ;DataNVM code protection disable
  EBTR0 = OFF                ;Block 0 (000800-003FFFh) not protected from table reads executed in other block
  EBTR1 = OFF                ;Block 1 (004000-007FFFh) not protected from table reads executed in other block
  EBTR2 = OFF                ;Block 2 (008000-00BFFFh) not protected from table reads executed in other block
  EBTR3 = OFF                ;Block 3 (00C000-00FFFFh) not protected from table reads executed in other block
  EBTR4 = OFF                ;Block 4 (010000-013FFFh) not protected from table reads executed in other block
  EBTR5 = OFF                ;Block 5 (014000-017FFFh) not protected from table reads executed in other block
  EBTR6 = OFF                ;Block 6 (018000-01BFFFh) not protected from table reads executed in other block
  EBTR7 = OFF                ;Block 7 (01C000-01FFFFh) not protected from table reads executed in other block
  EBTRB = OFF                ;Boot Block (000000-0007FFh) not protected from table reads executed in other block
Config_End

'**** End of Fuse Configurator Settings ****
'-------------------------------------------------------------------------------

    Xtal 64

;**** Compiler Defs *****

    Declare Create_Coff On




    '------------------------------------------------------------------------------------
    ' Setup the internal oscillator to operate at 64MHz
    ' Input     : None
    ' Output    : None
    ' Notes     : None
    ''
    Proc Osc_64MHz()
        OSCCON1 = $60               ' NOSC HFINTOSC, NDIV 1
        OSCCON3 = $00               ' CSWHOLD may proceed, SOSCPWR Low power
        OSCEN   = $00               ' MFOEN disabled, LFOEN disabled, ADOEN disabled, SOSCEN disabled, EXTOEN disabled, HFOEN disabled
        OSCFRQ  = $08               ' HFFRQ 64_MHz
        OSCTUNE = $00
    EndProc


    Dim myByte as Byte
    Dim myWord as Word
    Dim myDword as Dword
    Dim myFloat as Float


    Osc_64MHz()


    While 1 = 1

        Inc myByte
        Inc myWord
        Inc myDword
        inc myFloat

        Delayms 245

        Inc myByte
        Inc myWord
        Inc myDword
        inc myFloat

        delayms 1000

    Wend
Floats.png
Floats.png (115.8 KiB) Viewed 1333 times
test1.pdsprj
(16.86 KiB) Downloaded 949 times
Ettore
Labcenter Staff
Posts: 2932
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: Unable to display floats

Post by Ettore »

TimBox100 wrote: Fri 2023-04-14 10:07 ...
Now since there are so many compilers for the pics I do not expect you to have to buy them all. In this case I will pay for it. If you can let me know where to send it (PM me) I will purchase a copy and get it sent to that email address
I bought from Les the Positron compiler for my personal use only and to support him. Nevertheless, Labcenter don't use it for official tests.
Kind regards,
Ettore Arena - Labcenter Electronics.
Ettore
Labcenter Staff
Posts: 2932
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: Unable to display floats

Post by Ettore »

I tried your test and for that concerning the floats it seems there is something in the COFF loader that making floats not showing in the data window. When I use .BAS then floats are correctly displayed.

About the 1000ms delay time the problem is a more tricky as it involves the compiler's library routines. When delay time is greater than 255ms then __delay_ms_wreg_ library routine is called and things screw up in that assembly instuctions. When delay is less than 256ms then it calls __delay_ms_ and things work.
Kind regards,
Ettore Arena - Labcenter Electronics.
TimBox100
Professional User
Posts: 87
Joined: Wed 2019-03-13 13:26

Re: Unable to display floats

Post by TimBox100 »

Hello Ettor

Thanks for looking at all this

Some info. Yes I know the delays issue is related to the routine using a byte or a word to determine the delay. That is why I used it in my example.
I tried producing an standalone delay in ASM so it could be stepped and I could see where the issue was. The trouble is the VSM does not like stepping asm embedded in the code. I gave up as it was such hard work tracking it down. I just work around it.

I cannot read the COFF file to see the differences between what is generated for a 13k22 to that of a 27Q10. Considering the COFF file generator was written by a 3rd party I'm not sure I can find out. But I will say that based off of all the issues the 27Q10 model has I'm not immediately blaming the coff file. I will try again on a standalone ASM version I can see what is happening.

But I will say that the VSM can see the floats in a COFF file generated for a 18f13k22 using DT_FLOAT=MICROCHIP_BIGENDIAN

I'm not sure how you used a .bas file as the 27Q10 does not accept .bas and if you try and force it, the VSM dies instantly
Ettore
Labcenter Staff
Posts: 2932
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: Unable to display floats

Post by Ettore »

PIC18FxxQ10 and PIC18FxxK40 will accept DT_FLOAT property again when .coff is loaded. The fix is scheduled for the next service pack or release.
Kind regards,
Ettore Arena - Labcenter Electronics.
Post Reply