PIC puzzle

Okay, new PIC issue causing premature forcible hair removal. The code below is supposed to put 1's on the PORTB pins (PIC16F690). It's not happening; what am I missing?

BANKSEL 0x01 clrf TRISB ; PORTB all output clrf TRISC ; PORTC all output BANKSEL 0x00 bcf SSPCON, 5 movlw 0xFF movwf PORTB goto $

Reply to
randy.day
Loading thread data ...

Randy,

From the MPASM Help file: This directive is an instruction to the assembler and linker to generate bank selecting code to set the bank to the bank containing the designated label.

So, unless 0x01 is a label that somehow defines TRISB, it looks like you are never setting PORTB or PORTC as outputs. You may want to try setting the individual STATUS register bits to perform bank selection (see Example 4-3 in the datasheet). If not, use a valid label for banksel (for example, TRISB, or any other Bank1 register). Same for coming back to Bank0. Check out the examples in the MPASM help file.

You only provided a snippet of code, but you may also want to look at whether your ports default to analog or digital on startup.

I hope this helps.

Richard

Reply to
Richard Seriani

banksel TRISB clrf TRISB movlw 0xFF banksel PORTB movwf PORTB

See your Microchip documentation for how to use 'banksel' properly.

-Mike

Reply to
Mike Wahler

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.