;clockgen with 12f510
list p=12F510
#include <P12F510.inc>
__CONFIG 0FD9h
errorlevel -302
clk0 equ 10h
clk1 equ 11h
clk2 equ 12h
CounterA equ 15h
CounterB equ 16h
CounterC equ 17h
CounterD equ 18h
org 0x00
goto begin
begin CLRF ADCON0
movlw 0x28
TRIS 06H
rpt clrf GPIO
movlw d'4'
movwf GPIO
movlw D'1' ;1
movwf CounterD
movlw D'1' ;1
movwf CounterC
movlw D'11' ;11
movwf CounterB
movlw D'206' ;206
movwf CounterA
loop1 decfsz CounterA,1
goto loop1
decfsz CounterB,1
goto loop1
decfsz CounterC,1
goto loop1
decfsz CounterD,1
goto loop1
movlw d'3'
movwf GPIO
movlw D'1' ;1
movwf CounterD
movlw D'1' ;1
movwf CounterC
movlw D'11' ;11
movwf CounterB
movlw D'206' ;206
movwf CounterA
loop2 decfsz CounterA,1
goto loop2
decfsz CounterB,1
goto loop2
decfsz CounterC,1
goto loop2
decfsz CounterD,1
goto loop2
goto rpt
END
In fact I tied it high. it would help me not to run after VPP before Vdd issues while further programming.As you have simulated it OK in mplab I think it could be your config word bit 4 is set, requiring GP3/MCLR pin (pin4) to be tied high or you could instead clear config bit 4 so that it does not need the MCLR pin at all.
(change config to 0FC9h)
hi Sarma,
Just run your code in the Oshonsoft sim, it runs OK.
How are you measuring the waveforms on the GP0 , 1 pins..?
With your configuration settings, you're supposed to use a crystal. Is that ok for you? or are you willing to use the internal oscillator?
Have you tried configuring the CM1CON0 register for digital operation (bit C1ON = 0)?
;60Hz clockgen with 12f510
list p=12F510
#include <P12F510.inc>
__CONFIG 0FC9
errorlevel -302
clk0 equ 10h
clk1 equ 11h
clk2 equ 12h
CounterA equ 15h
CounterB equ 16h
CounterC equ 17h
CounterD equ 18h
org 0x00
goto begin
begin
; OPTION 0x00
movlw 0xC0
movwf CM1CON0
CLRF ADCON0
movlw 0x28
tris 06h
rpt
movlw d'5'
movwf GPIO
movlw D'1' ;1
movwf CounterD
movlw D'1' ;1
movwf CounterC
movlw D'11' ;11
movwf CounterB
movlw D'206' ;206
movwf CounterA
loop1 decfsz CounterA,1
goto loop1
decfsz CounterB,1
goto loop1
decfsz CounterC,1
goto loop1
decfsz CounterD,1
goto loop1
movlw d'6'
movwf GPIO
movlw D'1' ;1
movwf CounterD
movlw D'1' ;1
movwf CounterC
movlw D'11' ;11
movwf CounterB
movlw D'206' ;206
movwf CounterA
loop2 decfsz CounterA,1
goto loop2
decfsz CounterB,1
goto loop2
decfsz CounterC,1
goto loop2
decfsz CounterD,1
goto loop2
goto rpt
END
Nope. it didn't respond. the other pins continue to output.Try doing,
Code:movlw 0xC0 option
Mike.
You need to write zero to CM1CON0.
Mike.
I had measured the output on my frequency counter and it reads 60 or 61Hz (0.000060 MHz to be precise.)If you use the simulator and the stop watch you should be able to get the time exact. You're delay is currently 80 cycles per second too long.
Mike.
;PIC Time Delay = 0.00833400 s with Osc = 4000000 Hz
movlw D'1'
movwf CounterD
movlw D'1'
movwf CounterC
movlw D'11'
movwf CounterB
movlw D'207'
movwf CounterA
loop decfsz CounterA,1
goto loop
decfsz CounterB,1
goto loop
decfsz CounterC,1
goto loop
decfsz CounterD,1
goto loop
I could not understand how you have computed 80 sec timing, Pommie. let me wire it up into the clock, and I shall give further feed back. i do agree , that some fine tuning of cycles by NOP and/or 4MHz trimming needs to be done.
If you run your code in the simulator and set a break point on the rpt line then you can use the stop watch to time how long it takes. If you zero the stop watch first time it hits the break point and then hit F9 60 times you will see the time if 1,000,080 cycles.
Mike.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?