If the upper four bytes are guaranteed to always be inputs then you do not need to worry about how “they” are affected by your modifications of the lower four output bytes. Your
should work fine (all reads are of the actual values of the pins irrespective of any previous written values; all writes are read-modify-write operations).Code:PORTA = ~DCD digit
If the upper four bits could be outputs then you do need to worry and you can use one of the suggested fixes. If speed is an issue as you suggest (but I do not see why it would be, especially with a pause in the main loop), then you could 1) switch to real interrupts (see Darrel's methods) and 2) unroll your for-next loop. A possible version is shown below for the latter.
Code:' PORTA = XXXX1111 value_d = value dig 3 'Select the 3 Digit Value lookup value_d, [$7E,$0C,$B6,$9E,$CC,$DA,$FA,$0E,$FE,$DE], Segments PORTA = PORTA - 8 ' PORTA = XXXX0111 PORTB = Segments pause Scan MAIN: value_d = value dig 0 'Select the 0 Digit Value lookup value_d, [$7E,$0C,$B6,$9E,$CC,$DA,$FA,$0E,$FE,$DE], Segments PORTA = PORTA +7 ' PORTA = XXXX1110 PORTB = Segments pause Scan value_d = value dig 1 'Select the 1 Digit Value lookup value_d, [$7E,$0C,$B6,$9E,$CC,$DA,$FA,$0E,$FE,$DE], Segments PORTA = PORTA - 1 ' PORTA = XXXX1101 PORTB = Segments pause Scan value_d = value dig 2 'Select the 2 Digit Value lookup value_d, [$7E,$0C,$B6,$9E,$CC,$DA,$FA,$0E,$FE,$DE], Segments PORTA = PORTA - 2 ' PORTA = XXXX1011 PORTB = Segments pause Scan value_d = value dig 3 'Select the 3 Digit Value lookup value_d, [$7E,$0C,$B6,$9E,$CC,$DA,$FA,$0E,$FE,$DE], Segments PORTA = PORTA - 4 ' PORTA = XXXX0111 PORTB = Segments pause Scan Goto MAIN
and for clarity – any change to a single pin in PBP actually is writing to the entire port. (i.e, if you do this PORTA.0=1 then the microprocessor does this PORTA = uuuuuuu1 where the u is the value of the port pin at the time of the execution of the command)
Bookmarks