16f690 interupt


Results 1 to 5 of 5

Thread: 16f690 interupt

Threaded View

  1. #1
    Join Date
    Jan 2006
    Location
    Slovenia EU
    Posts
    32

    Default 16f690 interupt

    hello,

    I have program which working perfect on PIC18F242. I wish to changed this program and build to 16F690. I was changed some pins between PIC and now don't working properly. Now couldn't test A/D input but Synchro pulse not triggering interrupt routine to my program. I am not convinced if have ADC channel and other configuration set properly.
    down is attached both program. Please help me and check configuration.

    Thanks,
    Samo

    '@ DEVICE PIC18F252, HS_OSC

    define osc 20
    DEFINE ADC_BITS 10 ' ADCIN resolution (Bits)
    DEFINE ADC_CLOCK 3 ' ADC clock source (Fosc/32)
    DEFINE ADC_SAMPLEUS 50 ' ADC sampling time (uSec)
    TRISA=%11111111
    ADCON1=%10000010
    ADCON0=%10000111

    sinh var portb.0
    led var portb.1
    out VAR PORTC.0
    b0 var byte
    b1 var byte
    b2 var byte
    W0 var word
    W1 var word
    maxlim var word
    maxlim1 var word
    maxlim2 var word
    minstart var word
    minstart1 var word
    regulacija var word
    reg1 var word
    reg2 var word
    reg3 var word
    reg4 var word
    eeprom 0,[43]
    eeprom 2,[23]
    eeprom 4,[18]
    clear
    high led
    pause 1000
    toggle led
    pause 1000
    toggle led
    pause 1000
    toggle led
    read 0,b0
    read 2,b1
    read 4,b2




    On Interrupt Goto myint
    INTCON = $90
    loop:
    Goto loop
    Disable

    myint:


    adcin 1,maxlim
    adcin 0,minstart
    adcin 2,regulacija
    reg1= (maxlim2 -minstart1)
    reg2= (reg1*regulacija)
    reg3= div32 1024
    reg4= reg3+minstart1
    minstart1=(minstart*10)/B1
    maxlim1=(maxlim*10)/B2
    maxlim2=1024-maxlim1
    if w0=40 then
    toggle led
    w0=0
    endif
    if regulacija>=1022 or regulacija=0 then
    high led
    endif
    pauseus (1023-reg4)*b0

    high out
    pause 5
    low out
    w0=w0+1



    INTCON.1 = 0
    Resume

    Enable
    END

    program which not working:

    '@ DEVICE PIC16F690, HS_OSC

    define osc 20
    DEFINE ADC_BITS 10 ' ADCIN resolution (Bits)
    DEFINE ADC_CLOCK 3 ' ADC clock source (Fosc/32)
    DEFINE ADC_SAMPLEUS 50 ' ADC sampling time (uSec)
    CM1CON0 = 0
    CM2CON0 = 0
    ANSEL = %00001011
    ANSELH=0
    IOCA.2=1
    ADCON1=%00000000
    ADCON0=%10000001

    sinh var portc.2
    led var porta.2
    out VAR portc.1
    b0 var byte
    b1 var byte
    b2 var byte
    W0 var word
    W1 var word
    maxlim var word
    maxlim1 var word
    maxlim2 var word
    minstart var word
    minstart1 var word
    regulacija var word
    reg1 var word
    reg2 var word
    reg3 var word
    reg4 var word
    eeprom 0,[43]
    eeprom 2,[23]
    eeprom 4,[18]
    clear
    high led
    pause 1000
    toggle led
    pause 1000
    toggle led
    pause 1000
    toggle led
    read 0,b0
    read 2,b1
    read 4,b2



    On Interrupt Goto myint
    INTCON = $90
    loop:
    Goto loop
    Disable

    myint:


    adcin 1,maxlim
    adcin 0,minstart
    adcin 2,regulacija
    reg1= (maxlim2 -minstart1)
    reg2= (reg1*regulacija)
    reg3= div32 1024
    reg4= reg3+minstart1
    minstart1=(minstart*10)/b1
    maxlim1=(maxlim*10)/b2
    maxlim2=1024-maxlim1
    if w0=40 then 'and regulacija>minstart then
    toggle led
    w0=0
    endif
    if regulacija>=1022 or regulacija=0 then
    high led
    endif
    pauseus (1023-reg4)*b0
    high out
    pause 5
    low out
    w0=w0+1



    INTCON.1 = 0
    Resume

    Enable
    END
    Last edited by Samoele; - 17th June 2011 at 17:27.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts