PDA

View Full Version : Simple Blink program doesnt work.



sccoupe
- 28th February 2009, 00:11
I just got the whole programming kit today making the jump from the basic stamp and picaxe chips, so im not a total noob. :) I have a few 12f675's and a 12f629 and cannot get the simple Blink sample program to work. If I even program a HIGH 0 command, I only get 2.5 volts from pin 0 with a multimeter. Im using a 7805 (5 volts) to power it. If I HIGH 1 then I get 2.5v on pin 1, so the commands are hitting the right pin, they just arent 5 volts. Also, the blink program makes the selected pin stay at 2.5v and doesnt blink. I hope this is a simple common problem?

Thanks all.

Jason

mackrackit
- 28th February 2009, 02:35
Why not post your code, config settings and tell us if you are trying internal or external OSC?

sccoupe
- 28th February 2009, 03:52
The complete code....



loop:
High 0
Pause 500

Low 0
Pause 500

Goto loop
End


The circuit is +5vdc on pin 1 and ground to pin 8. Measuring voltage with a voltmeter from pin 8 to pin 7. I have tried several 12f675's and one 12f629. Not sure where to get the config, whatever was the default for the picbasic pro install.

Thanks

mackrackit
- 28th February 2009, 04:35
Lets start with the configs.
In the PBP directory there is a *.inc file for every chip, this is where the chip is configured. It can also be done in code space.
http://www.picbasic.co.uk/forum/showthread.php?t=543
For now look at the *.inc file


;************************************************* ***************

;* 12F675.INC *
;* *

;* By : Leonard Zerman, Jeff Schmoyer *

;* Notice : Copyright (c) 2005 microEngineering Labs, Inc. *

;* All Rights Reserved *

;* Date : 08/31/05 *

;* Version : 2.46a *

;* Notes : *

;************************************************* ***************

NOLIST

ifdef PM_USED

LIST

include 'M12F675.INC' ; PM header

device pic12F675, intrc_osc_noclkout, wdt_on, mclr_on, protect_off

XALL

NOLIST

else

LIST

LIST p = 12F675, r = dec, w = -302

INCLUDE "P12F675.INC" ; MPASM Header

__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF

NOLIST

endif

LIST

The above shows internal OSC, watch dog timer is on, MCLRE is on and code protect is off.
For now change MCLRE_ON to MCLRE_OFF. do the lower case one if you are using PM for the assembler and the upper case one if you are using MPASM for the assembler.

The chip you are using has built in ADCs, something new from the Basic Stamp. If the pin is to be used as a digital then the ADC needs to be turned off.
This thread is labeled PORTA... but the same applies for GPIO.
http://www.picbasic.co.uk/forum/showthread.php?t=561

In my opinion is will be a bad habit to stick with the Basic Stamp idea of a pin being 0 or 1 or 2. Better to get in the habit of calling the pins by the name or assigning on to it.


LED VAR GPIO.1


PBP defaults to 4MHz but it is good practice to define the speed in code space.
So make the change to the *.inc file and give this a try.


'16F675
DEFINE OSC 4
ANSEL=%00000000
CMCON=7
LOOP:
HIGH GPIO.0
PAUSE 250
LOW GPIO.0
PAUSE 250
GOTO LOOP
END

sccoupe
- 28th February 2009, 13:48
Ok, thats worked. Disecting it found that it was the MCLRE that made the difference. I'll read up on that as it is the only part of your explanation that I didnt understand. It seems that there are a lot of things that I need to learn in this area that were not needed with other chips. The frustration in the past with these pics may have been what pushed me to Basic Stamps, but their cost eventually pushed me to the Picaxe's. However, their inability to accomplish certain things and much lower availability to US customers has brought me back to this. :) I guess I need to fight my way though it this time.


Thanks for your help mackrackit.

idtat
- 28th February 2009, 23:36
I had similar frustrations when I ported from the Basic Stamps to the PICs. I found the most important thing was getting the PIC setup correctly for your application A/D, digital I/O and config bits. I printed up the data sheet for the 12F675 and left it in my library (bathroom) and read it through and through. This realy helped as I moved to other PICs as I knew what to look for (A/D, PWM, digital I/O etc) Its intresting that the masters sometimes dont show the config and setup info when they post there help code. Get a "Hello World" (blinking LED) working on a new PIC before you proceed any further on a new project. Best of luck, and keep on nearding (what my wife calls my obsession)

Aaron

Archangel
- 1st March 2009, 20:30
Ok, thats worked. Disecting it found that it was the MCLRE that made the difference. I'll read up on that as it is the only part of your explanation that I didnt understand.

Look at the chips Data Sheet for which pin is used with MCLRE. That pin must have a pullup resistor if MCLRE is enabled in the config statement.
<br> Rather than changing the config statement in the .inc file each time I would insert a semicolon just before the first letter in the statement and insert the statement at the beginning of my code, every time.