I have written code to run 4 seven segment displays not using the library. I am using the Oshonsoft bootloader which I have used hundreds of times, so I can't fault that.
The program worked up to the time I added an array. As long as I don't use arrays, the program scans 4 digits and I can vary the brightness. In what follows I cut code to basics.
This works, that is, all segments of the display light up. But the following doesn't. I looked at the .asm file and I can't see the problem. Is it possible the assembler is not working properly. Why should just loading these to array elements cause a problem.
There was a bug in the addition handling code in GCBASIC. Instead of writing the third memory location of the array, it was writing the third memory location of the PIC - the STATUS register. Writing 0x7f to the STATUS register was selecting bank 3, and so the PIC was setting TRISB and nothing rather than PORTB and PORTD.
I have written code to run 4 seven segment displays not using the library. I am using the Oshonsoft bootloader which I have used hundreds of times, so I can't fault that.
The program worked up to the time I added an array. As long as I don't use arrays, the program scans 4 digits and I can vary the brightness. In what follows I cut code to basics.
#chip 16F877A, 10
#config HS_OSC,WDT_OFF,LVP_OFF
#mem 368
#option bootloader
dim dbuf(8)
main:
dir portb out
dir portd out
'dbuf(0) = 0x7f
'dbuf(3) = 0x1f
PORTB=0x7f
set portD.7 on
End
This works, that is, all segments of the display light up. But the following doesn't. I looked at the .asm file and I can't see the problem. Is it possible the assembler is not working properly. Why should just loading these to array elements cause a problem.
#chip 16F877A, 10
#config HS_OSC,WDT_OFF,LVP_OFF
#mem 368
#option bootloader
dim dbuf(8)
main:
dir portb out
dir portd out
dbuf(0) = 0x7f
dbuf(3) = 0x7f
PORTB=0x7f
set portD.7 on
End
There was a bug in the addition handling code in GCBASIC. Instead of writing the third memory location of the array, it was writing the third memory location of the PIC - the STATUS register. Writing 0x7f to the STATUS register was selecting bank 3, and so the PIC was setting TRISB and nothing rather than PORTB and PORTD.
This should now be fixed - http://gcbasic.sourceforge.net/newfiles/update.zip
Also, the #mem directive is no longer needed - GCBASIC ignores it and uses the RAM size in the chip data file instead.