As the title implies, I've been programming PICs long enough that I should know this, but I really don't.
Let's suppose that I have both the SPI peripheral pins and the LCD data lines (using four wire) on one port.
Say the connections are like this:
PORTB.0 = LCD D4
PORTB.1 = LCD D5
PORTB.2 = LCD D6
PORTB.3 = LCD D7
PORTB.4 = SPI MOSI
PORTB.5 = SPI MISO
PORTB.6 = SPI CLOCK
PORTB.7 = No Connection
LCD control pins are on a different port.
Let's say I'm doing this
If I did that, am I going to mess up what I'm trying to do with the SPI whenever I move 0x04 onto PORTB. I know the MISO (PORTB.5 in my example) is an input, so writes to the the port won't effect that pin, but what about the MOSI (PORTB.4) and SCK (PORTB.6) pins? 0x04 on PORTB technically clears those, but are the SPI pins even altered if I've enabled the SPI and it's writing? I want to make sure the above code wouldn't start the SPI clock and MOSI lines to working and then cut them off with the 0x04 write to PORTB.
Also, I'm still not clear if I should be using PORTB or LATB on the PIC18F (which I'm still trying to learn) for writes. Is it truly as basic as "PORT" is for reading the port pins and "LAT" is for writing the port pins?
Thanks!
Let's suppose that I have both the SPI peripheral pins and the LCD data lines (using four wire) on one port.
Say the connections are like this:
PORTB.0 = LCD D4
PORTB.1 = LCD D5
PORTB.2 = LCD D6
PORTB.3 = LCD D7
PORTB.4 = SPI MOSI
PORTB.5 = SPI MISO
PORTB.6 = SPI CLOCK
PORTB.7 = No Connection
LCD control pins are on a different port.
Let's say I'm doing this
Rich (BB code):
MOVLW 0xAA
MOVWF SSPBUF ;notice I'm not checking to see if the SSPBUF is finished below
MOVLW 0x04 ;clock in high nibble of character "A"
MOVWF PORTB ;put on portb, this is where I'm curious
<<<SUBROUTINE TO CLOCK INTO LCD GOES HERE>>
MOVLW 0x01 ;clock in low nibble of character "A"
MOVWF PORTB ;put on portb, this is where I'm curious
<<SUBROUTINE TO CLOCK INTO LCD GOES HERE>>
Also, I'm still not clear if I should be using PORTB or LATB on the PIC18F (which I'm still trying to learn) for writes. Is it truly as basic as "PORT" is for reading the port pins and "LAT" is for writing the port pins?
Thanks!