16f690 interupt


Closed Thread
Results 1 to 5 of 5

Thread: 16f690 interupt

  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.

  2. #2
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: 16f690 interupt

    Not sure which version of PBP you are using... but "Loop" is a reserved word that should NOT be used as a variable name or program label.

    You should change that to something else like "MainLoop", etc.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

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


    Did you find this post helpful? Yes | No

    Default Re: 16f690 interupt

    I use PBP 2.50C and both program sample compiled without problems. "loop variables" by first program working very good. I was trying with "loop1" and was no changed.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: 16f690 interupt

    Seems like you forgot to set TRIS registers in the second code unless I am snowblind.
    Ver 2.6 makes LOOP a reserved word.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: 16f690 interupt

    Try INTCON = $88

Members who have read this thread : 1

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