Announcement

Collapse
No announcement yet.

12-bit cores with SEROUT #

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

    Click image for larger version

Name:	12-BIT_SEROUT.jpg
Views:	1
Size:	15.9 KB
ID:	5437

    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
    The fix is easy enough, only one line needs to be added (magenta) ...
    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
    Then the output looks like this (0-9 are showing) ...

    Click image for larger version

Name:	12-BIT_SEROUT_2.jpg
Views:	1
Size:	17.3 KB
ID:	5438
    PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
    Never download a PIC datasheet from anywhere but microchip.com

  • #2
    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

    Comment

    Working...
    X