Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Convert Code 12F675 to 12F508

Status
Not open for further replies.

Sheeraz Khan

Member level 3
Joined
Dec 29, 2002
Messages
62
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
440
12f508

This Code is for PIC12F675 & this chip is not available in my City so can anybody convert this code for PIC12F508

; pulse_60.asm
;
; 22nd Oct 2004
;
; Output 1 pulse/min from 50Hz mains or 0.5Hz clock circuit


list P = 12F675
include "P12F675.inc"

errorlevel -305, -302, -306 ;MPLAB error suppression

__CONFIG _CP_OFF & _INTRC_OSC_NOCLKOUT & _BODEN_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF & _MCLRE_ON

bank0 macro
bcf status,rp0
bcf status,rp1
bcf status,irp
endm

bank1 macro
bsf status,rp0
bcf status,rp1
bcf status,irp
endm

mov macro litval,file
movlw litval
movwf file
endm

cblock 0x20

ticks
secs
temp1
temp2
t0_cnt

endc

#define led gpio,0 ;1 ppm LED
#define power gpio,1 ;mains on
#define mains50 gpio,2 ;50Hz in, INT
#define b0int gpio,4 ;out to 452
#define clock gpio,5 ;0.5Hz from clock module

org 0x00

goto start

org 0x04

goto isr

org 0x05

start bank1

call 0x3ff
movwf osccal

clrf ansel ;digital inputs

movlw b'00101110'
; 1 0.5Hz in
; 0 output to 452
; 1 /mclr
; 1 50Hz in
; 1 mains on/off
; 0 green LED, output
movwf trisio

movlw b'10000110'
; 1 pullups off
; 110 /128 TMR0 pre-scaler
movwf option_reg ;= ~32.768ms rollover 4MHz int RC osc


bank0

clrf gpio
movlw b'00000111' ;GPIO 0,1,2 as digital
movwf cmcon

clrf tmr0

clrf intcon
bsf intcon,inte

clrf t1con

mov 0xff,tmr1l ;load TMR1 with -1
mov 0xff,tmr1h

mov .100,ticks ;2 second resolution
mov .30,secs ;1 minute

;================================================
; Main loop, wait for input
;================================================

main btfss power
goto battery

bcf intcon,intf
clrf tmr0

wt_lh btfsc mains50
goto chk_m1
wt_hl btfss mains50
goto chk_m2

bcf led
decfsz ticks
goto main

mov .100,ticks ;reload ticks
bsf led ;LED on 1/50th second
decfsz secs
goto main

mov .30,secs ;reload secs
call pulse
goto main

battery btfss clock
goto sec2 ;process if power off
btfsc power
goto main ;exit if power comes on
goto battery

sec2 bsf led
call ms5 ;LED on for 5ms
btfss clock ;wait for return high
goto $-1
bcf led

decfsz secs
goto battery
mov .30,secs
call pulse
goto battery

pulse bsf b0int ;50us pulse to 452
mov .252,temp1
incfsz temp1
goto $-1
bcf b0int
return

chk_m1 btfss power
goto battery
goto wt_lh

chk_m2 btfss power
goto battery
goto wt_hl

ms5 mov .249,temp1 ;5ms delay
mov 0x84,temp2
inct1 incfsz temp2
goto $-1
incfsz temp1
goto inct1
return

;================================================
; Fault - TMR0 time-out
;================================================

isr nop

;================================================

t_loop bcf intcon,t0if ;approx 500us delay
btfss intcon,t0if
goto $-1
bcf intcon,t0if
return

end
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top