I think that clrf STATUS does clear C and that is not the issue. I suspect that this is for a long program that pushes the jump table out of page 0 and that the page bits need to be set as per the commented-out code. However, that will add another cycle to the timing so more work will have to be done, someday.
Jeff
Announcement
Collapse
No announcement yet.
12-bit cores with SEROUT #
Collapse
X
-
12-bit cores with SEROUT #
This one falls into that "How the hell has nobody found this before" category.
On the 12-bit cores, when sending a value from SEROUT with the # (DEC) modifier ...
When the value is from 0-9 the baud rate changes to really slow (~10 baud) and the value doesn't display or is corrupt.
In the PBPPIC12.LIB
This is part of the SEROUT command.
I assume the line in red was intended to clear the carry flag (STATUS,C).
But CLRF STATUS doesn't clear the carry flag.
So the following RLF rotates the carry flag into the jump offset, and jumps to the wrong place. The baud rate doesn't get set, and it uses whatever is in the registers for the baud.
Code:sergettbl ;movlw ((sertable >> 4) & 60h) ; 1 Set PC latch high ; movwf STATUS ; 1 clrf STATUS ; 1 rlf R0, W ; 1 Get value for jump * 2 ; TABLE?C 16 ; 2 Do jump addwf PCL, F ; 2 Do jump (clears Carry) sertable movlw (SDELAY_2400) >> 8 ; 1 goto serdelayh ; 2 movlw low (SDELAY_2400) ; 1 goto serdelayl ; 2 movlw (SDELAY_1200) >> 8 goto serdelayh movlw low (SDELAY_1200) goto serdelayl movlw (SDELAY_9600) >> 8 goto serdelayh movlw low (SDELAY_9600) goto serdelayl movlw (SDELAY_300) >> 8 goto serdelayh movlw low (SDELAY_300) goto serdelayl
Code:sergettbl ;movlw ((sertable >> 4) & 60h) ; 1 Set PC latch high ; movwf STATUS ; 1 ; clrf STATUS ; 1 bcf STATUS,C rlf R0, W ; 1 Get value for jump * 2 ; TABLE?C 16 ; 2 Do jump addwf PCL, F ; 2 Do jump (clears Carry) sertable movlw (SDELAY_2400) >> 8 ; 1 goto serdelayh ; 2 movlw low (SDELAY_2400) ; 1 goto serdelayl ; 2 movlw (SDELAY_1200) >> 8 goto serdelayh movlw low (SDELAY_1200) goto serdelayl movlw (SDELAY_9600) >> 8 goto serdelayh movlw low (SDELAY_9600) goto serdelayl movlw (SDELAY_300) >> 8 goto serdelayh movlw low (SDELAY_300) goto serdelayl
Tags: None
Leave a comment: