Announcement

Collapse
No announcement yet.

Huge Problem with 16F1946/1947 and 16F946

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

  • Huge Problem with 16F1946/1947 and 16F946

    On the 16F1946/1947, most PBP commands will not work on PORTF or PORTG.

    The issue is in the way the library tries to locate the TRIS bits.
    It does so (in many locations) by setting bit-7 of the address to the PORT.
    This works fine when the PORT is in BANK0

    PORTA = $00C, set bit-7 and you get $08C which is the address of TRISA.

    But with PORTF = $28C, bit-7 is already set.
    It tries to set bit-7, which has no effect since it's already 1. Then changes the PORTx bit instead of the TRISx bit.
    When it tries to go back to the PORT, it clears bit-7 which puts it in the bank previous to where the PORT is ... $20C which is unimplemented.

    When using PORTG, it ends up reading/changing WPUB instead of the PORT.

    The problem is prevalent throughout the 14e library.
    And it comes in several different forms.
    For instance, in the PULSIN command, it sets/clears bit-7 directly.
    Code:
      LIST
    PULSINT movwf   RM1             ; Save bit mask
            bsf     FSR0L, 7        ; Point to TRIS
            iorwf   INDF0, F        ; Set bit to input
            bcf     FSR0L, 7        ; Point back to port
    The above is the most common in the library.

    This is from the SHIFTIN command where it OR's $80 with the address, and the same technique is found in several other commands.
    Code:
            movf    RS1, W          ; Get data port
            movwf   FSR1H           ; Put it into FSR1
            movf    RR1, W
            iorlw	80h		; Point to TRIS
            movwf   FSR1L
            movf    RM1, W          ; Get data bit mask
    	iorwf	INDF1, F	; Set data to input
    	bcf	FSR1L, 7	; Point back to port

    The LCDOUT command assumes ALL TRIS registers are in BANK1, and all PORTS are in BANK0. It doesn't even try to add $80 to the PORT.
    Code:
            bcf     LCD_RSREG, LCD_RSBIT    ; Set command register select
    	bcf     LCD_RWREG, LCD_RWBIT    ; Set RW low (write)
    
            movlb	1		; Point to TRISes
            bcf     LCD_EREG, LCD_EBIT      ; Set E to output
            bcf     LCD_RSREG, LCD_RSBIT    ; Set RS to output
            bcf     LCD_RWREG, LCD_RWBIT    ; Set RW to output
        if ((LCD_BITS) == 8)
            clrf    LCD_DREG        ; Set port to all output
        else
          if ((LCD_DBIT) == 0)
            movlw   0f0h
          else
            movlw   0fh
          endif
            andwf   LCD_DREG, F     ; Set proper half of port to output
        endif
            movlb	0		; Point back to ports
    
    	movf	R3 + 1, W	; Get back char
    Every PBP command that automatically sets the TRIS bit has this problem.
    A great deal of work is required to fix all of them.
    PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
    Never download a PIC datasheet from anywhere but microchip.com

  • #2
    This problem applies to the 16F946 too, which uses the standard 14-bit library.

    So both the 14 and 14E libraries must be re-written.
    PBP3 Manual : Microchip Datasheets - 10F, 12F, 16F, 18F
    Never download a PIC datasheet from anywhere but microchip.com

    Comment


    • #3
      As of this writing, I've added warning messages for the 16F946, 16F1946/7, and 16f1526/7 in the database prior to 3.0.8. Will consult with Jeff on the size and risk of the proper rewrite.
      Charles Leo
      ME Labs, Inc.
      http://melabs.com

      Comment

      Working...
      X