ArtemisGoldfish
Member
I feel completely retarded not being able to figure out what went wrong. Here's the code, it's just meant to send a repeating pulse out of SDO by using the MSSP module in Master mode.
The first few lines make sure that all the ports on the device are digital (Lest I want to expand the code to somehow use PortA). I use the bit setting to set up the direction of the serial pins to what the datasheet says to use (Clear bit 5 and 3, set 4), and I set the SPI enable bit in SSPCON. (Switch back to Bank 0)
I check the SSPSTAT<BF> bit to check if the serial shift register is done outputting, goes back to wait for it if it's not ready, or puts 0x66 in to send if it is done. As far as the datasheet says, as soon as there is data in the SSPBUF, it's supposed to shift it out, but it just sits there with the pins high. I must've made an obvious mistake that someone can point out, right?
Code:
list p=16f876A
#include <p16f876a.inc>
main: BSF STATUS,RP0
MOVLW 0x07
MOVWF ADCON1
BCF TRISC,5
BCF TRISC,3
BSF TRISC,4
BSF SSPCON,5
BCF STATUS,RP0
ser: BTFSS SSPSTAT,BF
GOTO ser
MOVLW 0x66
MOVWF SSPBUF
GOTO ser
END
The first few lines make sure that all the ports on the device are digital (Lest I want to expand the code to somehow use PortA). I use the bit setting to set up the direction of the serial pins to what the datasheet says to use (Clear bit 5 and 3, set 4), and I set the SPI enable bit in SSPCON. (Switch back to Bank 0)
I check the SSPSTAT<BF> bit to check if the serial shift register is done outputting, goes back to wait for it if it's not ready, or puts 0x66 in to send if it is done. As far as the datasheet says, as soon as there is data in the SSPBUF, it's supposed to shift it out, but it just sits there with the pins high. I must've made an obvious mistake that someone can point out, right?