18F25K22 Help


Closed Thread
Results 1 to 18 of 18

Thread: 18F25K22 Help

Hybrid View

  1. #1
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: 18F25K22 Help

    Hi

    Aside from the analog port issues..... If you want the LED's to sequence, you need to put them low at some point otherwise they all going to be mostly high all the time ?

    Maybe as others far wiser than me will suggest (Robert)..... get the code to turn one LED on and off (Flash)
    Move this simple code around the ports.. Then once you know this is working OK... Progress on further.

    flash: ledx high
    pause 500
    ledx low
    pause 500
    goto flash

    BR
    Andy

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,170


    Did you find this post helpful? Yes | No

    Default Re: 18F25K22 Help

    What Andy proposed (1 LED) and Richard (RMW).

    Also, put AllDigital back in and doublecheck the code generated.

    Robert

  3. #3
    Join Date
    Jan 2010
    Posts
    88


    Did you find this post helpful? Yes | No

    Default Re: 18F25K22 Help

    I would like to thank all those who helped looking over the code. The commands I chose were those that I found on this forum, but did not work. So, with that said, I would like to post what I did that got my program working again.

    First off, ADCON1 = whatever. Don't use it. It'll just screw things up. Second, I did not have any success with Darrel's AllDigital include. Not saying it doesn't work, it just didn't work for me.

    What did get it working again was using ANSELA = 0, ANSELB = 0 and ANSELC = 0. I used ANSEL for setting each register to digital, TRIS for selecting input/output and then PORT for setting the outputs to high or low. This was the first step in setting up my code. Then, you have to change your output variables from port to lat. For instance, my LED variable of LED1 var porta.1 needed to be changed to LED1 var lata.1. You can Google it like it was suggested above, but I found I understood it better when viewing a youtube video of the explanation along with circuit and oscilloscope examples. Just remember, only the outputs get changed from port to lat. Leave the inputs as portx, but change the outputs to latx.

    Thanks again to all those that helped and I hope my explanation will help those in the future.

    Tony

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


    Did you find this post helpful? Yes | No

    Default Re: 18F25K22 Help

    ANSELx = ANALOG SELECT or inversely Digital Select . . .
    ADCON0 is where you choose which Analog Channel to use
    ADCON1 is where you CHOOSE what your voltage references are & Trigger Select

    ANSELA configures portA Analog or Digital
    ANSELB configures portB Analog or Digital
    ANSELC " " " " " portC Analog or Digital
    ANSELD " " " " " portD Analog or Digital
    ANSELE " " " " " portE Analog or Digital

    All about COMPARATORS Below from Data Sheet
    Code:
    TABLE 18-2: REGISTERS ASSOCIATED WITH COMPARATOR MODULE
    Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Register on Page
    ANSELA — — ANSA5 — ANSA3 ANSA2 ANSA1 ANSA0              154
    ANSELB — — ANSB5 ANSB4 ANSB3 ANSB2 ANSB1 ANSB0        155
    CM2CON1 MC1OUT MC2OUT C1RSEL C2RSEL C1HYS C2HYS C1SYNC C2SYNC 318
    CM1CON0 C1ON C1OUT C1OE C1POL C1SP C1R C1CH<1:0>    317
    CM2CON0 C2ON C2OUT C2OE C2POL C2SP C2R C2CH<1:0>    317
    VREFCON1 DACEN DACLPS DACOE — DACPSS<1:0> — DACNSS 347
    VREFCON2 — — — DACR<4:0>                                             348
    VREFCON0 FVREN FVRST FVRS<1:0> — — — —                      344
    INTCON GIE/GIEH PEIE/GIEL TMR0IE INT0IE RBIE TMR0IF INT0IF RBIF 116
    IPR2 OSCFIP C1IP C2IP EEIP BCL1IP HLVDIP TMR3IP CCP2IP   129
    PIE2 OSCFIE C1IE C2IE EEIE BCL1IE HLVDIE TMR3IE CCP2IE    125
    PIR2 OSCFIF C1IF C2IF EEIF BCL1IF HLVDIF TMR3IF CCP2IF     120
    PMD2 — — — — CTMUMD CMP2MD CMP1MD ADCMD                 57
    TRISA TRISA7 TRISA6 TRISA5 TRISA4 TRISA3 TRISA2 TRISA1 TRISA0 156
    TRISB TRISB7 TRISB6 TRISB5 TRISB4 TRISB3 TRISB2 TRISB1 TRISB0 156
    Comparators are really good at causing you to tear out your hair while trying to get the PIC to do digital too.
    Sorry this post comes too late to help you, I bet you won't forget though. Keep up the good work Tony.
    JS
    Last edited by Archangel; - 25th November 2014 at 06:59.
    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
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

    Default Re: 18F25K22 Help

    just for the record what version of alldigital.pbp did you try ? there are a number of versions

    First off, ADCON1 = whatever. Don't use it. It'll just screw things up.
    is not right ,it just does not do what you erroneously thought it did as archangel says
    ADCON1 is where you CHOOSE what your voltage references are & Trigger Select
    and needs to set appropriately " rtfm "

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


    Did you find this post helpful? Yes | No

    Default Re: 18F25K22 Help

    Richard,
    Problem is; None of this is in the manual, it's in the data sheet, and it takes some of us a while before we understand how to read it, and when we get frustrated, it's just harder. That's why I explained it the way I did, because Acronyms are always obvious . . . to the person who makes them. The rest of us, maybe not so much.
    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.

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

    Default Re: 18F25K22 Help

    as tony discovered the wrong info in a thread can lead you astray , I don't think perpetuating error helps anyone but the right info is priceless

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: 18F25K22 Help

    Hi,
    Here's my view on this....
    This sort of info can't be in the manual because then the manual would be the size of all the 8bit PIC datasheets combined.

    [rant]
    It's up to the user to set the registers correctly for the application at hand, HOW to set them IS described in the manual, WHAT to set the TO is described in the datasheet for the particular PIC. Yes, it does take some time to learn what to look for in a datasheet but you're going to have to learn it.

    The commands I chose were those that I found on this forum, but did not work.
    Just because you find a piece of code where you see some_register = some_value ' Enable this, do that doesn't mean it'll work for you and your PIC. Take CMCOM for example, it's not uncommon that someone finds a piece of code, on this forum, where it says CMCON=7 ' Turn off comparators, uses that on a completely different PIC than the one for which the code was written and ultimately ends up in trouble. All because the comment said Turn off comparators - which it of course does on the PIC for which it was written. On some chips the registers are named differently, on others you need CMCON=15, on others you don't need to anything.

    Where exactly did you find the reference to ADCON1=15?

    Finally, just because you find pieces of code an a forum doesn't mean it's correct, working, debugged code ready to go. Most of the code posted here contains errors and problems - which is usually the reason for it being posted in the first place even though you're sometimes asked to troubleshoot code without even seeing it.

    [/rant]

    /Henrik.

Similar Threads

  1. migration from 16F876a to 18F25k22
    By MOUNTAIN747 in forum General
    Replies: 26
    Last Post: - 19th March 2012, 21:33
  2. Config 18F25K22
    By mpardinho in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th April 2011, 19:08

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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