Hi,
Yes, one instruction cycle is 4 Clock cycles. That's where the Fosc/4 you see all around comes from. At 32MHz each instruction cycle (1/32M)*4 or 125ns.
Reading a whole port is obviously faster than Reading the 8 pins indvidually if that's what you're asking.
Four "sets" of those two line compiles toI count 20 instructions. Some of them (the btfsc) may take two cycles to execute but when they do the instruction AFTER the btfsc is skipped so in the end it'll still take 20 cycles, something I didn't take into account in the previous post. 20 * 125ns = 2.5us.Code:000004 M L00001 000004 8082 M bsf PORTC, 000h 000006 0E00 M movlw 0 000008 B282 M btfsc PORTC, 001h 00000A 0E01 M movlw 1 00000C 6E1A M movwf _Sw1 00000E 8482 M bsf PORTC, 002h 000010 0E00 M movlw 0 000012 B682 M btfsc PORTC, 003h 000014 0E01 M movlw 1 000016 6E1B M movwf _Sw2 000018 8882 M bsf PORTC, 004h 00001A 0E00 M movlw 0 00001C BA82 M btfsc PORTC, 005h 00001E 0E01 M movlw 1 000020 6E1C M movwf _Sw3 000022 8082 M bsf PORTC, 000h 000024 0E00 M movlw 0 000026 B282 M btfsc PORTC, 001h 000028 0E01 M movlw 1 00002A 6E1D M movwf _Sw4 00002C D7EB M bra L00001
With that said I'm far from an expert in assembly programming so I truly hope someone that is corrects me if I'm wrong.
If you can explain what you're trying to do it may be easier to help you choose the best/fastest option.
/Henrik.




Bookmarks