Skip to content

Commit

Permalink
fix PIC16F TRISx mirror value at reset
Browse files Browse the repository at this point in the history
  • Loading branch information
lcgamboa committed Mar 2, 2024
1 parent 11e2d0e commit cf05ed7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,18 @@ int pic_reset(_pic* pic, int flags) {
(*pic->P16map.TRISE) = 0x07;
if (pic->P16map.PR2)
(*pic->P16map.PR2) = 0xFF;

if (pic->port_mirror) {
pic->ram[(0x0180) | (sfr_addr(pic->P16map.TRISA) & 0x007F)] = 0xFF;
if (pic->P16map.TRISB)
pic->ram[(0x0180) | (sfr_addr(pic->P16map.TRISB) & 0x007F)] = 0xFF;
if (pic->P16map.TRISC)
pic->ram[(0x0180) | (sfr_addr(pic->P16map.TRISC) & 0x007F)] = 0xFF;
if (pic->P16map.TRISD)
pic->ram[(0x0180) | (sfr_addr(pic->P16map.TRISD) & 0x007F)] = 0xFF;
if (pic->P16map.TRISE)
pic->ram[(0x0180) | (sfr_addr(pic->P16map.TRISE) & 0x007F)] = 0xFF;
}
periferic16_rst(pic);

break;
Expand Down

0 comments on commit cf05ed7

Please sign in to comment.