RoveyDoveyGrovey
New Member
Hello,
Looking at the titles of some of the other posts here I feel a little out of my depth, but what the hell. Here's an easy problem for you to solve for once.
Right, im doing a project at Uni, we've been told we need to program a PIC as part of this project, which sounds a bit harsh to me as we haven't had any lectures on it and aren't due to before the hand in date.
So im trying to learn how they work along with getting my head around BASIC. I bought a PIC programmer VM111/K8048. It came with PIC16F627 I can get the basic demos to work, but as soon as I try anything of my own it all fails. I found a basic flashing LED program that was written for the 16F627, so I thought i'd give it a go, but can't for the life of me get the thing to work, here's the code,
LIST P=PIC16F627
INCLUDE C:\PicProg2009\Include\P16F627.inc
LOOP EQU 0x20
init BSF STATUS, RP0
BCF PCON, OSCF
MOVLW 0x00
MOVWF TRISB
BCF STATUS, RP0
LED_on BSF PORTB, 0
delay_1 DECFSZ LOOP, 1
GOTO delay_1
LED_off BCF PORTB, 0
delay_2 DECFSZ LOOP, 1
GOTO delay_2
GOTO LED_on
END
Sorry about the format, I assure you the spaces are in the correct place in my notepad file. From the datasheet the oscillator is at 37Khz, I did try adding some additional loops to keep the led on and off for longer but all I ever get is permanent ON LED. So I added this in place of LED_on and delay_1
LED_on BSF PORTB,0
MOVLW 0xFF
MOVWF LOOP
delay_1 DECFSZ LOOP,1
GOTO delay_1
MOVLW 0xFF
MOVWF LOOP
A1 DECFSZ LOOP,1
GOTO A1
MOVLW 0xFF
MOVWF LOOP
A2 DECFSZ LOOP,1
GOTO A2
I also added this to delay_2 but this made no difference, no matter how many times I add the loop the LED remains on. I just need some kind of foothold so I know what the hell is going on then I can build from there but at the moment nothing makes any sense.
Thanks for any help you can give me, even if it's just a slap round the head.
Looking at the titles of some of the other posts here I feel a little out of my depth, but what the hell. Here's an easy problem for you to solve for once.
Right, im doing a project at Uni, we've been told we need to program a PIC as part of this project, which sounds a bit harsh to me as we haven't had any lectures on it and aren't due to before the hand in date.
So im trying to learn how they work along with getting my head around BASIC. I bought a PIC programmer VM111/K8048. It came with PIC16F627 I can get the basic demos to work, but as soon as I try anything of my own it all fails. I found a basic flashing LED program that was written for the 16F627, so I thought i'd give it a go, but can't for the life of me get the thing to work, here's the code,
LIST P=PIC16F627
INCLUDE C:\PicProg2009\Include\P16F627.inc
LOOP EQU 0x20
init BSF STATUS, RP0
BCF PCON, OSCF
MOVLW 0x00
MOVWF TRISB
BCF STATUS, RP0
LED_on BSF PORTB, 0
delay_1 DECFSZ LOOP, 1
GOTO delay_1
LED_off BCF PORTB, 0
delay_2 DECFSZ LOOP, 1
GOTO delay_2
GOTO LED_on
END
Sorry about the format, I assure you the spaces are in the correct place in my notepad file. From the datasheet the oscillator is at 37Khz, I did try adding some additional loops to keep the led on and off for longer but all I ever get is permanent ON LED. So I added this in place of LED_on and delay_1
LED_on BSF PORTB,0
MOVLW 0xFF
MOVWF LOOP
delay_1 DECFSZ LOOP,1
GOTO delay_1
MOVLW 0xFF
MOVWF LOOP
A1 DECFSZ LOOP,1
GOTO A1
MOVLW 0xFF
MOVWF LOOP
A2 DECFSZ LOOP,1
GOTO A2
I also added this to delay_2 but this made no difference, no matter how many times I add the loop the LED remains on. I just need some kind of foothold so I know what the hell is going on then I can build from there but at the moment nothing makes any sense.
Thanks for any help you can give me, even if it's just a slap round the head.
Last edited: