Menu

Problem w/ReadAD now added a problem compiler

Help
lhatch
2012-09-06
2013-05-30
  • lhatch

    lhatch - 2012-09-06

    I have a program with ReadAD, I get back, or think I get back a 0, not sure why ReadAD is not working, but wrote a small routing to blink an LED with the count from it (maybe it will not load in a byte. 

    Now I get a compiler error   :23     I believe.  23 is a Loop, but I moved it and still get the :23 on the end.  Here is the code that will not compile. I  only changed if then's TO do until loop and that broke it.

    #chip 12F675, 4
    #config osc = int

    #define LIGHT AN0                   'ADC input from AC lit LED
    #define LED GPIO.2                  'LED to blink for AD value
    Dir LIGHT In
    Dir LED Out
    Dim i as byte

    Do

        blink
        blink
        blink
        wait 1500 msec

        i = ReadAD(LIGHT)

    '100s
        do until i < 100
           blink
           i=i-100
        loop

        wait 1500 msec
        blink
        blink
        blink
        wait 1500 msec

    '10s

        do until i < 10
           blink
           i-i=10
        loop

        wait 1500 msec
        blink
        blink
        blink
        wait 1500 msec

        for i = 1 to i
            blink
        next

        wait 1500 msec
    loop

    end

    sub blink
            set LED on
            wait 250 msec
            set LED off
            wait 250 msec
    end sub

     
  • lhatch

    lhatch - 2012-09-07

    Just realized the error was in the ASM line 23 not the source.  Offending translation from the above program to ASM

    Will this function maybe not read AD to a variable?

    ADREADPORT EQU 36
    ADTEMP EQU 38
    I EQU 39
    I-I EQU 40                       <----------- this is :23
    READAD EQU 41

     
  • Hugh Considine

    Hugh Considine - 2012-09-07

    I think the "I-I" is coming from here:

    '10s

        do until i < 10
           blink
           i-i=10
        loop

    The compiler probably should be a bit more helpful there, I will see if I can add a new error message.

     
  • lhatch

    lhatch - 2012-09-07

    Found the typo/error..

    '10s
    do until i < 10
         blink i-i=10               <---  Duhh.
    loop

    Anyone see any problem with the ReadAD into a byte?  Change the define from AN0 to GPIO.0 as well but have not tested it.

     
  • lhatch

    lhatch - 2012-09-07

    The

    i = ReadAD(LIGHT)   

    byte I seems to be zero assuming my code is working.  I dropped a scope on the pin and it is floating from 4-5volts.

     
  • lhatch

    lhatch - 2012-09-08

    Does the ReadAD to all the A/C setup aotumatically?  Maybe I have a bad chip, will try another with a pot from VDD/VSS/the_pin today…

    Anyone else using the 675 and GPIO.0 and it works?

    Thanks

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.