I'm not that great on pic assembly language yet, so I could be reading this wrong, but
it seems it always turns portb.0 to zero first, then sets it to ptst. bcf sets it to zero, right?
This seems to be causing my problems.
If it was already = 1, and ptst is = 1, I don't want it turned to zero and then back to one.
For a normal variable, this behavior would be irrelevant, and indeed, probably more efficient.
But for a physical port output, it matters. Is there some way to override this behavior?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I agree, that is a glitch.
The end result is correct but you can get a quick low pulse on the port pin.
I've seen this before on other compilers and it caused issues.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's best to declare a variable as a bit if you plan to use it that way (i.e. Dim PTST as bit).
Otherwise any bit set within the 8 bits of PTST can make the PORTB,0 get set to a 1.
When I declared PTST as a bit the code still had the issue though a little different code.
;portb.0 = ptst
bcf PORTB,0
btfsc SYSBITVAR0,0
bsf PORTB,0
This would work fine if one more line was added
;portb.0 = ptst
btfss SYSBITVAR0,0 ;Add this line
bcf PORTB,0
btfsc SYSBITVAR0,0
bsf PORTB,0
So applying that same logic to the original code:
;portb.0=ptst
movf PTST,F ;move this up
btfss STATUS,Z ;move this up
bcf PORTB,0
btfsc STATUS,Z ;add this
bsf PORTB,0
I believe this will fix it.
Again I don't know where that is to fix but I'm sure Hugh will consider this for the next release.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
the following code
compiles to
I'm not that great on pic assembly language yet, so I could be reading this wrong, but
it seems it always turns portb.0 to zero first, then sets it to ptst. bcf sets it to zero, right?
This seems to be causing my problems.
If it was already = 1, and ptst is = 1, I don't want it turned to zero and then back to one.
For a normal variable, this behavior would be irrelevant, and indeed, probably more efficient.
But for a physical port output, it matters. Is there some way to override this behavior?
I agree, that is a glitch.
The end result is correct but you can get a quick low pulse on the port pin.
I've seen this before on other compilers and it caused issues.
It's best to declare a variable as a bit if you plan to use it that way (i.e. Dim PTST as bit).
Otherwise any bit set within the 8 bits of PTST can make the PORTB,0 get set to a 1.
When I declared PTST as a bit the code still had the issue though a little different code.
;portb.0 = ptst
bcf PORTB,0
btfsc SYSBITVAR0,0
bsf PORTB,0
This would work fine if one more line was added
;portb.0 = ptst
btfss SYSBITVAR0,0 ;Add this line
bcf PORTB,0
btfsc SYSBITVAR0,0
bsf PORTB,0
So applying that same logic to the original code:
;portb.0=ptst
movf PTST,F ;move this up
btfss STATUS,Z ;move this up
bcf PORTB,0
btfsc STATUS,Z ;add this
bsf PORTB,0
I believe this will fix it.
Again I don't know where that is to fix but I'm sure Hugh will consider this for the next release.