PDA

View Full Version : Simple program for 12F629



rele
- 26th July 2008, 18:39
Hello

I need som help with this program.
It should work like this: when power on, GPIO.2 is high. When I apply HI on GPIO.0, after 3 sec GPIO.2 should be low. Config is mclr=off, pwrt=on, wdte=on,boren=on, int OSC I/O.

Here is the code

CMCON=7

ul var GPIO.0 'Define GPIO.0 pin as ul
izl VAR GPIO.2 'Define GPIO.2 pin as izl

High izl
Input ul

loop:
if ul=1 then
pause 3000
low izl
end if
goto loop

skimask
- 26th July 2008, 18:55
Does 'blinky LED' work?

rele
- 27th July 2008, 01:18
Does 'blinky LED' work?

I'm sorry, but I can't find 'blinky LED' example.

ronjodu
- 27th July 2008, 02:12
' Example program from manual to blink an LED connected to PORTB.0 about once a second

loop: High 0 ' Turn on LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds

Low 0 ' Turn off LED connected to PORTB.0
Pause 500 ' Delay for .5 seconds

Goto loop ' Go back to loop and blink LED forever
End


http://www.melabs.com/resources/samples.htm#pro


Hope this helps..

skimask
- 27th July 2008, 06:47
I'm sorry, but I can't find 'blinky LED' example.

WOW!!!!!!!

malc-c
- 27th July 2008, 10:01
WOW!!!!!!!

I know its tough, but count to ten, take deep breaths and read Mels most http://www.picbasic.co.uk/forum/showpost.php?p=25199&postcount=1

If you look at his code, there is some logic in his thinking, he has made an attempt to write a program, which doesn't work, and thus came here seeking assistance...

Acetronics2
- 27th July 2008, 10:32
Hi,

First of all let's leave guns and knives outside ...

Won't you think a little ( real ! ) SCHEME would be compulsory, here ???

just to verify how and what to inputs and outputs are linked ...


"my two cents"

Alain

rele
- 27th July 2008, 11:27
I need to disable writing to external eeprom few secconds after power is applyed. So, GPIO.2 pin is connected to the WP pin of eeprom, and GPIO.0 pin have +5V when eeprom have +5V. Between VCC and MCLR is 4K7.

I know this is very simply for most of you, but this is my first program, and it has practical purpose.

Regards

malc-c
- 27th July 2008, 14:01
I think the point that skimask was trying to get over, is that for a 1st program, the main goal is to get the chip to flash a LED correctly, then go on to develope that.

A golden rule here is to look at the datasheet, and then set the pic up accordingly. Often these small chips don't have their pins set to digital i/o by default, so need the config set accordingly.

Once you have a bit of code that blinks an LED, then introduce inputs and modify the code to get the result you want.

Acetronics2
- 27th July 2008, 14:26
I know this is very simply for most of you, but this is my first program, and it has practical purpose.

Regards

Hi,

NOOOOOO ... nothing is simple !!!

We still do not know what is connected to your Pic I/Os ...

Just remember if hardware is False ... software can't work as expected !!! ... and vice versa.

We must know everything of your project, if you want us to give a serious answer.


Now, for some fun ...

You ask for help...Ok, but you do not tell us even if it works ... How do you verify GPIO.2 works ( or doesn't work ! ) properly ???
How do you drive GPIO.0 ???



For the day,We do not use the crystal ball on this Forum ... so, you must do your "part of the work" of debugging, and tell us what's on your side ...

Alain

rele
- 27th July 2008, 14:55
Hi,

NOOOOOO ... nothing is simple !!!

We still do not know what is connected to your Pic I/Os ...

Just remember if hardware is False ... software can't work as expected !!! ... and vice versa.

We must know everything of your project, if you want us to give a serious answer.

Pin1 - +5V
Pin2 - N/C
Pin3 - N/C
Pin4 - +5V thru 4K7
Pin5 - Output pin
Pin6 - N/C
Pin7 - Input pin
Pin8 - GND

Output pin is connected directly to WP pin of external eeprom. Input pin is connected directly to VCC pin of external eeprom. Purpose of program is to disable writing to external eeprom for 3 secconds after power is applyed to eeprom.

I verify condition of GPIO.2 with logic probe.

Regards

Acetronics2
- 27th July 2008, 17:06
Hi,

Just a little innocent question ...

Does your program compile ???

...

Alain

rele
- 27th July 2008, 21:55
Program is ok, I have one mistake in hardware. I put one resistor 10K between input pin and GND and now it is ok.

Thank you for your help.

Regards

skimask
- 28th July 2008, 02:20
Output pin is connected directly to WP pin of external eeprom. Input pin is connected directly to VCC pin of external eeprom. Purpose of program is to disable writing to external eeprom for 3 secconds after power is applyed to eeprom.
I verify condition of GPIO.2 with logic probe.
Regards
Curious as to why you want to connect WP and disable writing for 3 seconds.
Is it to be extra double super sure that the eeprom doesn't get written to?

Acetronics2
- 28th July 2008, 09:38
Hi,




Just a little innocent question ...

Does your program compile ???






CMCON=7

ul var GPIO.0 'Define GPIO.0 pin as ul
izl VAR GPIO.2 'Define GPIO.2 pin as izl

High izl
Input ul

loop:
if ul=1 then
pause 3000
low izl
end if ... sure about the spelling ???
goto loop



You sure ??? just a Typo, I wonder ...

Now, connecting GPIO.0 to +5v would have been so simpler to find there were NO problem in your code ...
Do not tell us you have two separate 5v supplies ...

Alain

rele
- 28th July 2008, 17:19
Yes I have two separate +5V. It is for coded caraudio. When I reprogram eeprom for immo off and connect +5V to WP pin of eeprom carradio is working but memory station is not working, also settings for audio dont work, all data that are usualy stored to eeprom.
I need to disable writing just for first few secconds when MCU is checking one location in e2prom.



[code]
end if ... sure about the spelling ???


My mistake