PDA

View Full Version : Getting started with Chuck Hellebuyck



quester
- 4th March 2008, 22:56
I have programmed a pic to flash one Led from the book by Chuck. I have used copy and paste so it must be ok. I have programmed the chip having set the fuses to __CONFIG _CP_OFF & _WDT_off & _BODEN_ON &_PWRTE_ON & _HS_OSC & _LVP_OFF &_DEBUG_OFF
I have built the circuit which is perfect but when it is switched on the led lights and stays on. I have changed the 4mhz resonator but it made no diference it still stays on. I have grounded both the legs of 4mhz with 68p capacitors I presume this is correct. This is what I have programmed in. I cant see where I could have gone wrong. Thanks to anybody who can help.


symbol LED = 0 'Rename pin 0 of portb (PIC 16F876 pin 21) to LED

TRISB = %11111110 'Setup port b as RB7-RB1 inputs, RB0 as output
main: 'Label for beginning of main loop
High LED 'Set pin 0 of portb high (5 volts) which turns the LED on
pause 1000 'Pause 1000 milliseconds (1 second) with LED on
Low LED 'Set pin 0 of portb low (0 volts) which turns the LED off
pause 1000 'Pause for 1 second with LED off
goto main 'Jump to the main label and do it all again and again

END 'This line is not needed but its safe to put it here just in case
' the program gets lost.


Thanks Ged.

b1arrk5
- 4th March 2008, 23:33
I'm going to guess that the problem is with the Symbol statement. Please try
LED var portb.0 and see if that works. Symbol is a Basic Stamp 1 command, and personally I have never used it. You could also try adding another pause 1000, I've had it where the led was turning on and off so fast that I thought it was on all the time.

Good Luck,

Jerry.

DaveC3
- 7th March 2008, 16:23
If you are using a 4Mhz crystal or resonator you need to set the config to
XT_OSC not "HS_OSC"

Give that a try

Dave

Archangel
- 7th March 2008, 17:48
Hi quester,
double check the connections of your breadboard, especially if it is an old one. Pay particular attention to the pins associated with the oscillator pins and resonator.

quester
- 9th March 2008, 20:10
I have changed Chucks first line project 1 from Symbol LED = 0 to LED var portb.0 and it now works I have just tried his second project using a for next loop and it does not work as it should. Do you think the problem could be my programmer or is there more than one version of Picbasic Pro.
Has anybody bought Chucks book and worked through the projects with success.
I tried the other mode and it works just the same thanks XT_OSC not "HS_OSC"
Thanks to everybody.

Quester