![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
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.
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 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?
__________________
<-- Feel free to IM me for random chit-chat and PIC assembly talk Adobe After Effects lets you save your work before it crashes, now THAT'S user-friendly. |
|
|
|
|
|
|
(permalink) |
|
Don't you have to send something before you can get a buffer full condition and once you get BF then you need to read it to prevent a collision.
Mike. |
|
|
|
|
|
|
(permalink) |
|
If I'm looking at it and it's 0 because the buffer is empty, it should work fine with the condition.
__________________
<-- Feel free to IM me for random chit-chat and PIC assembly talk Adobe After Effects lets you save your work before it crashes, now THAT'S user-friendly. |
|
|
|
|
|
|
(permalink) |
|
|
|
|
|
|
|
|
(permalink) |
|
Hahah, now that you mention it, I maybe should've used BTFSC. I also noticed that I was trying to read from SSPSTAT in the wrong bank. I'll fix these and see what happens.
__________________
<-- Feel free to IM me for random chit-chat and PIC assembly talk Adobe After Effects lets you save your work before it crashes, now THAT'S user-friendly. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Mike. |
||
|
|
|
|
|
(permalink) |
|
Code:
list p=16f876A #include <p16f876a.inc> main: BSF STATUS,RP0 ;Initializing stuff in Bank 1 MOVLW 0x07 MOVWF ADCON1 BCF TRISC,5 BCF TRISC,3 BSF TRISC,4 BSF SSPCON,5 ;Set the SSP Enable bit BCF STATUS,RP0 ;Back to Bank 0 ser: CALL cond BTFSC 0x20,0 GOTO ser MOVLW 0x66 MOVWF SSPBUF GOTO ser cond: BSF STATUS,RP0 MOVF SSPSTAT,W BCF STATUS,RP0 MOVWF 0x20 RETURN END
__________________
<-- Feel free to IM me for random chit-chat and PIC assembly talk Adobe After Effects lets you save your work before it crashes, now THAT'S user-friendly. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| stepper motor with 16f876a | jay543_uk | Micro Controllers | 10 | 8th February 2008 08:05 PM |
| Pic 16f876a Prog. Problem | JEFFxxx | Micro Controllers | 9 | 5th October 2006 09:45 PM |
| 16F876A | YAN-1 | Micro Controllers | 1 | 14th December 2005 08:56 AM |
| PWM module in the 16F876A | YAN-1 | Micro Controllers | 3 | 23rd May 2005 12:08 AM |
| Need help programming the MSSP on the PIC16F877 | avinsinanan | Micro Controllers | 1 | 20th August 2003 10:04 AM |