Jump to content
Sign in to follow this  
trossin

Tblrd*+ Does Not Advance Pointer In Simulator

Recommended Posts

trossin    0

Assembly code TBLRD*+ in version 6.89 (I can't upgrade due to a previous bug where newer versions do not simulate at all with any version of MPLAB) does not advance the table pointer after the read. Multiple calls return the same value. The code works fine when programmed into a PIC18F4620 but does not simulate correctly.

 

Here is some context. All 4 address variables are loaded with the same table entry in the simulator but in hardware, the code works fine.

 

 

 	clrf 	TBLPTRU; address of the memory block
movlw	RomImageStart>>8
movwf 	TBLPTRH
movlw	RomImageStart & 0xff
movwf 	TBLPTRL
TBLRD*+ 			; read into TABLAT and increment
movf	TABLAT, w 	; get data
movwf	AddrHigh
TBLRD*+ 			; read into TABLAT and increment
movf	TABLAT, w 	; get data
movwf	AddrLow
TBLRD*+ 			; read into TABLAT and increment
movf	TABLAT, w 	; get data
movwf	AddrHighEnd
TBLRD*+ 			; read into TABLAT and increment
movf	TABLAT, w 	; get data
movwf	AddrLowEnd

Edited by trossin

Share this post


Link to post
Share on other sites
joli    0

I'm amazed by the fact of five years later this bug keep living with us.

 

David / Pavel... do you have planed to solve it, or this is something that we should forget ?

 

br

Share this post


Link to post
Share on other sites
Pavel    0

I'm amazed by the fact of five years later this bug keep living with us.

 

David / Pavel... do you have planed to solve it, or this is something that we should forget ?

 

br

 

Isn't this issue fixed in 7.x release?

 

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
joli    0

Nope i don't think so, Pavel

 

Unless the successive upadates left behind the old simulator.

I can´t tell you cause i don't know what executable the simulator is.

 

All exe files are 2015 except; "boostbuild_server_.exe" & "vcredist_x86_SP1.exe" - JUN 2012

 

and

 

plugins.exe - 2009

 

br

Share this post


Link to post
Share on other sites
joli    0

Please compile and simul the snipet. and sorry can't figure out how to insert code in a specific window.

 

You will see two versions of reading flash. first one simulates bad and the second simulates ok.

 

 

br

 

 

////////////////////////////////////////////////////////////////////////////////

// This is a small example with minimal settings just for demo purpose

// It is intended to read a block of 8 bytes from program memory (flash)

////////////////////////////////////////////////////////////////////////////////

 

#include <system.h>

 

 

// F U S E S C O N F I G U R A T I O N

 

#pragma config OSC = INTOSCPLL // Internal osc PLL can be enable/disable

#pragma config CP0 = OFF // Program memory unprotected

#pragma config FCMEN = ON // Enable osc monitor

#pragma config WDTEN = OFF // Watchdog disabled, could be enable by soft

#pragma config WDTPS = 512 // 1:512

#pragma config XINST = OFF // Disable extended instruction set

#pragma config IOL1WAY = OFF // works either way

 

 

/////////////////////////////////////////////////////////////////////////////////

// F L A S H T A B L E

//-------------------------------------------------------------------------------

// Data block defined below will be included during device programming

/////////////////////////////////////////////////////////////////////////////////

#define FLASH_ADR 0x3000

 

#pragma DATA 0x3000, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 \

 

#define TBL_SIZE 8

 

unsigned char flashbuf[TBL_SIZE];

 

/////////////////////////////////////////////////////////////////////////////////

// R E A D 8 B Y T E S O F F L A S H

/////////////////////////////////////////////////////////////////////////////////

void ReadFlash( void )

{

eecon1.WREN = 0;

 

tblptru = 0;

tblptrh = FLASH_ADR >> 8;

tblptrl = FLASH_ADR;

 

 

for( unsigned char i=0; i<TBL_SIZE; i++ )

{

asm tblrd*+ // <<<< not increment tblptr

flashbuf = tablat;

}

}

 

/////////////////////////////////////////////////////////////////////////////////

// A L T E R N A T E R E A D 8 B Y T E S O F F L A S H

/////////////////////////////////////////////////////////////////////////////////

void AltReadFlash( void )

{

eecon1.WREN = 0;

 

tblptru = 0;

tblptrh = FLASH_ADR >> 8;

tblptrl = FLASH_ADR;

 

 

for( unsigned char i=0; i<TBL_SIZE; i++ )

{

asm tblrd*+ // <<<< not increment tblptr

flashbuf = tablat;

tblptrl++; // forced increment

}

}

 

 

////////////////////////////////////////////////////////////////////////////////

// M A I N

////////////////////////////////////////////////////////////////////////////////

 

void main( void )

{

 

// M A I N O S C C O N F I G

 

osccon = ((1<<IRCF2)|(1<<IRCF1)|(1<<IRCF0)); // Select 8MHZ

osctune |= ( 1 << INTSRC );

osctune &= ~( 1 << PLLEN );

 

 

ReadFlash(); // << simulator bug

 

AltReadFlash(); // << simulation OK and in real as well

 

 

while( 1 )

{

}

}

Edited by joli

Share this post


Link to post
Share on other sites
joli    0

Sorry about the uggly code in the early post.

Please consider this new snipet with some minimal corrections.

////////////////////////////////////////////////////////////////////////////////
// This is a small example with minimal settings just for demo purposes
// It is intended to read a block of 8 bytes from program memory (flash)
////////////////////////////////////////////////////////////////////////////////

#include <system.h>


// F U S E S   C O N F I G U R A T I O N

#pragma config OSC = INTOSCPLL      // Internal osc PLL can be enable/disable
#pragma config CP0 = OFF            // Program memory unprotected
#pragma config FCMEN = ON           // Enable osc monitor
#pragma config WDTEN = OFF          // Watchdog disabled, could be enable by soft
#pragma config WDTPS = 512          // 1:512
#pragma config XINST = OFF          // Disable extended instruction set
#pragma config IOL1WAY = OFF        // works either way


/////////////////////////////////////////////////////////////////////////////////
// F L A S H   T A B L E
//-------------------------------------------------------------------------------
// Data block defined below will be automatically included on the flash during
// device programming.
// The 0x3000 start page address could be different depending on pic used.
// Note:  a good thing about sourceboost is that if we define table address to
// low, the linker? don't let the code overwrite it.... That's nice 
/////////////////////////////////////////////////////////////////////////////////
#define FLASH_ADR   0x3000

#pragma DATA  0x3000, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08                            \

#define TBL_SIZE    8

unsigned char flashbuf[TBL_SIZE];
  
/////////////////////////////////////////////////////////////////////////////////
// R E A D   8   B Y T E S   O F   F L A S H
/////////////////////////////////////////////////////////////////////////////////
void ReadFlash( void )
{
    eecon1.WREN = 0;
    
    tblptru = 0;
    tblptrh = FLASH_ADR >> 8;
    tblptrl = FLASH_ADR;
    

    for( unsigned char i=0; i<TBL_SIZE; i++ )
    {
        asm tblrd*+             // <<<< not increment tblptr
        flashbuf[i] = tablat;
    }
}

/////////////////////////////////////////////////////////////////////////////////
// A L T E R N A T E   R E A D   8   B Y T E S   O F   F L A S H
/////////////////////////////////////////////////////////////////////////////////
void AltReadFlash( void )
{
    eecon1.WREN = 0;
    
    tblptru = 0;
    tblptrh = FLASH_ADR >> 8;
    tblptrl = FLASH_ADR;
    

    for( unsigned char i=0; i<TBL_SIZE; i++ )
    {
        asm tblrd*              // just to update tablat
        flashbuf[i] = tablat;
        tblptrl++;              // forced increment
    }
}


////////////////////////////////////////////////////////////////////////////////
// M A I N
////////////////////////////////////////////////////////////////////////////////

void main( void )
{
    
    // M A I N   O S C   C O N F I G
    
    osccon = ((1<<IRCF2)|(1<<IRCF1)|(1<<IRCF0));  // Select 8MHZ
    osctune |= ( 1 << INTSRC );
    osctune &= ~( 1 << PLLEN );


    ReadFlash();        // << simulator bug
    
    AltReadFlash();     // << simulation OK and in real as well
    
    
    while( 1 )
    {
    }
}


br

Edited by joli

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×