12c509A Example Program

Publisher:liliukanLatest update time:2017-12-05 Source: eefocusKeywords:12c509A Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    include        "P12c509a.inc" 
    __CONFIG    h’000E’ ; CP off, WDT on, internal cLOCk 


DCCon    equ    0 
Ovl_in    equ    1     
Relay    equ    2 
Ovl_out    equ    4 
  
    CBLOCK    0x0007 
        state        ;state sequence 
        time0        ;counter0 
        time1        ;counter1 
        time2        ;counter2     
    ENDC 
    org     0 
    MOVwf    OSCCAL        ;set cal 
    bcf    STATUS,PA0 
    MOVlw    B’10001111’ 
    option 
                     
;GP0 DCC ON/OFF (hi is ON);;;;;;GP1 is overload input (active lo) 
;GP2 Reverse output    ;;;;;;;;GP4 overload output (HI is overload) 
;-----------------------------                 
    MOVlw    B’00000010’ 
    tris    GPIO             
    MOVlw    B’00000001’    ;set ports 
    MOVwf    GPIO 
    clrf     state 
;main loop starts here. SCANs for hi on overload.  

test    clrwdt 
    btfss    GPIO,Ovl_in    ;look for overload 
    goto    set1 
     
test1    btfsc    state,0        ;check state 
    goto    caltim        ;reset delay 

    goto    test        ;look again 

;here if true overload  

set1    bcf    GPIO,DCCon    ;turn off 
    btfsc    state,0        ;0 if first time after reset 
    goto    state1 
    bsf    state,0        ;set to state 1 

    MOVf    GPIO,W        ;get port setting 
    xorlw    B’00000100’    ;reverse relay 
    MOVwf    GPIO 

    call    dely25        ;delay 25 millisecs for relay 
    bsf    GPIO,DCCon    ;turn back on 
    goto    test        ;look for overload 

state1    bsf    GPIO,Ovl_out    ;set alarm 
    call    del500 
    bsf    state,7        ;set timeout 
    bcf    GPIO,Ovl_out    ;alarm off 
    bsf    GPIO,DCCon    ;output on 
    goto    test     

caltim    call    timout        ;reset timer 
    goto    test 
     
delay    MOVlw    0xFF        ;short delay 
    MOVwf    time0 
delay1    clrwdt 
    nop 
    nop 
    decfsz    time0,F 
    goto    delay1 
    retlw    0 

dely25    clrwdt 
    MOVlw    .30        ;25 millisecs 
    MOVwf    time1 
del25a    MOVlw    0xFF 
    MOVwf    time2 
del25b    decfsz    time2,F 
    goto    del25b 
    decfsz    time1,F 
    goto    del25a 
    retlw    0 

del500    MOVlw    0xFF        ;500 millisecs 
    MOVwf    time1 
del500a    MOVlw    0xFF 
    MOVwf    time2 
del500b    clrwdt 
    nop 
    nop 
    nop 
    nop 
    decfsz    time2,F 
    goto    del500b 
    decfsz    time1,F 
    goto    del500a 
    retlw    0 

timout    btfss    state,7        ;continue countdown 
    goto    countdn 
    MOVlw    0xFF        ;set counters 
    MOVwf    time1 
timo2    MOVlw    0xFF 
    MOVwf    time2  
    bcf    state,7 
countdn    decfsz    time2,F 
    retlw    0 
    decfsz    time1,F 
    goto    timo3 
    clrf    state        ;reset 
    retlw    0 

timo3    MOVlw    0xFF 
    MOVwf    time2 
    retlw    0 

    end 


Keywords:12c509A Reference address:12c509A Example Program

Previous article:PIC12c508 read and write 93LC46 PICC program
Next article:12F675 Temperature Display Program

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号