Jump to content
Sign in to follow this  
Zapo

PIC16F819 - Bank Switching Bug?

Recommended Posts

Sorry, previous postingS "took off" !!!

 

I might have found a bug in the compiler. I'm using the 16F819 CHIP and I think there is a bug when swithcing banks.

Compiler version is the newest 5.2 (registered).

 

I have declared "global" variable FLAGS at top without giving the exact location.

 

** CLIP from C-source **

char FLAGS;

...

void initChip()

{

 porta = 0;

 portb = 0;

 trisb = 0;

 trisa = 0;

 FLAGS = 0xff;

 FLAGS = 0x00;

}

** CLIP END **

 

** Resulting ASM-Code **

*Definition part *

## The flag goes to address 0x51, which is in BANK0

_FLAGS                          equ 0x51 ;1

 

* Code Part *

 

## Bank is set to 0 correctly

bcf STATUS, RP0

bcf STATUS, RP1

clrf _porta

;;;;;;;; portb = 0; // Init PORTB

clrf _portb

;;;;;;;; trisb = 0; // Set all PORTB as outputs.

 

## Bank is set to 1

bsf STATUS, RP0

clrf _trisb

;;;;;;;; trisa = 0; // Set all PORTA as outputs.

clrf _trisa

;;;;;;;; FLAGS = 0xff; // Zero all FLAGS

 

## Current BANK is still 1, even the FLAGS variable

## is in BANK 0

movlw D'255'

movwf _FLAGS

;;;;;;;; FLAGS = 0x00; // Zero all FLAGS

clrf _FLAGS

 

** CLIP END **

 

As far as I know, the compiler should check the variable addresses and switch the banks when necessary. I think this didn't happen in this case? Or am I just doing something wrong?

Share this post


Link to post
Share on other sites
Guest Pavel
*Definition part *

## The flag goes to address 0x51, which is in BANK0

_FLAGS                          equ 0x51 ;1

...

As far as I know, the compiler should check the variable addresses and switch the banks when necessary. I think this didn't happen in this case? Or am I just doing something wrong?

Looks like the compiler applies 16F818 register map to 16F819. Will check this.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

This could be true because I also noted that the amount of memory available is much smaller than 256 bytes. The 818 only has 128bytes I think...

 

Well, if you happen to find a bug, are you going to publish some patch shortly or should I find some workaround for this problem temporarily?

Share this post


Link to post
Share on other sites
Guest Pavel
Looks like the compiler applies 16F818 register map to 16F819. Will check this.

Yes that was the problem. I will post patch shortly.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji 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  

×
×
  • Create New...