PDA

View Full Version : IC12F508 with Internal Oscillator and Software Reset



karan123
- 2nd August 2009, 17:32
Hi


1)
Can any body send me example code for Glow LED By using Internal Osc.?

2)
How I reset PIC12F508 Controller?

I want to know how i reset that.?

Further I want to also use GP3/MCLR/VPP as General Purpose IO Pin


-------------------------
SO SOFTWARE RESET


In my previous experience on MCLR direclty connected to Reset switch for PIC18F4520.


what i do in this (PIC12F508)case?

Archangel
- 2nd August 2009, 17:58
Hi Karan123,
What is a " Glow LED"? Please define what you mean by " reset" pic. Do you mean make it wake from sleep, or shut off and restart from scratch as in a
"Hot Boot" like hitting the reset button on a PC, or just reinitialize all the registers to the way you set them at start up ?

karan123
- 3rd August 2009, 05:38
Thanks for Reply...

1)
What is a " Glow LED"?

Means ON LED with PIC12F508 uC.

2)
Please define what you mean by " reset" pic


Restart from Scratch when power is ON


Karan

Archangel
- 3rd August 2009, 06:39
Thanks for Reply...

1)
What is a " Glow LED"?

Means ON LED with PIC12F508 uC.

2)
Please define what you mean by " reset" pic


Restart from Scratch when power is ON


Karan
To restart"from scratch" would require a power off or MCLR reset, maybe a brownout recovery, but I doubt it. So to reset you can use the mclr pin with a 5k resistor pulling it high and tie one of the other pins set as input to it, to reset just say LOW for that pin and PIC will reset. Other way would involve opening the VDD with a transistor or relay. Glow_LED var GPIO.0
HIGH Glow_LED

Lastly you could put a label at the very beginning of you code and execute a goto label, that will not however reset every register unless you have set every register in code.

Bruce
- 5th August 2009, 20:38
@ device pic12F508, intrc_osc, wdt_on, mclr_off, protect_off

X VAR BYTE

OPTION_REG = %10001111 ' pull-ups disabled, 1:128 prescaler assigned to WDT
GPIO = 0 ' pins clear on POR
TRISIO = 0 ' all outputs (except for GPIO.3, which is input only)

Main:
FOR X = 0 TO 9 ' toggle LED on GPIO.0 10 times
GPIO.0 = 1
PAUSE 500
GPIO.0 = 0
PAUSE 500
NEXT X

' sleep until WDT causes a device reset (around 2.3 seconds)
@ SLEEP
The watchdog timer will timeout in around 2.3 seconds and cause a device reset. If you
just want to start over from 0, just replace @ SLEEP with @ GOTO 0.

Michael Wakileh
- 1st October 2009, 12:50
Hi Bruce, I'm reading reading about WDT and was wondering if you (or anyone else) could explain how you arrived at 2.3s...(if possible using Mr.E's multicalc...as thats what I normally use)...

Acetronics2
- 1st October 2009, 13:44
Hi, Michael


just use:




NAP 7


2.60 Manual, page 116 ... range x = 0 ... 7 and duration is 18 ms * 2^x


No calculations needed ...


for calculations ...




Parameter : 31 WDT Watchdog Timer Time-out Period
(no prescaler)
min: 9* ; Typ : 18 ; Max 30 ms @ VDD = 5.0V (Industrial)



soooo ...

128 * 18 ms = 2304 ms ... ...

CQFD !

BTW ... I do not think those calculators are really useful here ... nor handy !!!

Michael Wakileh
- 2nd October 2009, 16:13
Thanks!...makes sense now...
nice way to say RTFM...