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.
The fix is easy enough, only one line needs to be added (magenta) ...
Then the output looks like this (0-9 are showing) ...
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 [COLOR="red"] clrf STATUS ; 1[/COLOR] 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 ;[COLOR="red"] clrf STATUS ; 1 [/COLOR] [COLOR="magenta"]bcf STATUS,C[/COLOR] 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
Comment