I'm running a Hello World that toggles RB7:
#include <p16f1509.inc> __config _CONFIG1, _FOSC_INTOSC udata delay0 res 1 delay1 res 1 delay2 res 1 delay3 res 1 ledState res 1 delay32 macro delay goto $+1 goto $+1 banksel delay3 movlw (delay - 1) & 0xFF movwf delay0 movlw (delay - 1) >> 0x08 & 0xFF movwf delay1 movlw (delay - 1) >> 0x10 & 0xFF movwf delay2 movlw (delay - 1) >> 0x18 & 0xFF movwf delay3 call doDelay32 endm rst code 0x00 start: clrf PORTB banksel TRISB clrf TRISB banksel ANSELB clrf ANSELB movlw 0x80 movwf PORTB banksel ledState movlw 0x00 movwf ledState loop: banksel ledState movf ledState, 0 xorlw 0x80 movwf ledState movwf PORTB delay32 d'2500' goto loop doDelay32 movlw 0xFF addwf delay0, F btfsc STATUS, C clrw addwf delay1, F btfsc STATUS, C clrw addwf delay2, F btfsc STATUS, C clrw addwf delay3, F btfsc STATUS, C clrw iorwf delay0, W iorwf delay1, W iorwf delay2, W iorwf delay3, W btfss STATUS, Z goto doDelay32 retlw 0 end
This runs perfectly on the MPLABX debugger using a PicKit3, but does not run otherwise.
This appears to be a common problem, but a day of Googling has turned up nothing useful. Here's what I've learned:
Most people fail to pull MCLR high. I have a 10k between MCLR and VDD.
The clock config bit defaults to an exteral clock. Setting it to INTOSC didn't help.
Some people suggest setting the !DEBUG bit, but the data sheet claims that this is totally taken care of by the debugger. I tried it anyway; it didn't help.
Any suggestions would be appreciated. Thanks
Also: Does anybody know if it's possible to program a PIC using a Beaglebone's by connecting I2C to ICSPDAT and ICSPCLK?