Microchip forum

Discussion in 'Embedded Systems and Microcontrollers' started by PRS, Nov 29, 2010.

  1. PRS

    Thread Starter Well-Known Member

    Aug 24, 2008
    989
    35
    Does anyone here have experience with the Microchip forum? I signed up and posted one post and that is all it let me post. Also, it won't let me reply to the fellow who replied to my post. What's up with this?
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    I suggest you contact the administrator of the forum. You should be able to post freely once you have joined the site.

    hgmjr
     
  3. PRS

    Thread Starter Well-Known Member

    Aug 24, 2008
    989
    35
    Thanks, I'll give it a try. Could be I'm on trial for the first week or so.
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I'm pretty sure I made more than one post the day I signed up.
     
  5. PRS

    Thread Starter Well-Known Member

    Aug 24, 2008
    989
    35
    Thanks for the tip. I guess I'll get hold of the supervisor as suggested. But maybe you could answer my question:

    I'm using a PIC18f452 with PicKit3, and I'm using C18. The latter is the kicker. I can read the documentation for PORTA such that I could configure it for digital IO on PORTA using ASM, but I see no documentation for C. Do you know the answer?
     
  6. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Frayed knot. I don't know much about C.
     
  7. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    My C18 is rusty as anything (I use Swordfish BASIC) but I think it's something like.

    TRISA = 0x00;
     
  8. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
  9. PRS

    Thread Starter Well-Known Member

    Aug 24, 2008
    989
    35
    Mik3, thanks! I'll look into this in the morning. :)
     
  10. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,884
    1,002

    Look for the document called PICkit™ 3 Debug Express PIC18F45K20 – MPLAB® C Lessons on the Microchip website.

    Go through the lessons. If you have a question, post back.
     
  11. PRS

    Thread Starter Well-Known Member

    Aug 24, 2008
    989
    35
    I wish that were true, spinnaker, but I am using a PIC18f452 and they are different.
     
  12. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    The PORTx and TRISx instructions would be the same.
     
  13. PRS

    Thread Starter Well-Known Member

    Aug 24, 2008
    989
    35
    So what happens, blueroom? I configured my PortA for output and it worked just fine, then I configured it for input and it was zero, not what I told it to be.. What is happening? I just presumed it was a configuration problem. Am I wrong? My thought is that PortA is analog to digital and I have to figure out how to turn it into digital IO using C18.
     
  14. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    1,758
    98
    Did you turn off analog on those ports.
     
  15. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,884
    1,002



    You read ports you write to latches. Also check to see if the port is an analog port. Look at ANSEL in your datasheet.

    Do you have a pull up resistor?

    Look at the samples as I recommended.
     
    Last edited: Nov 29, 2010
  16. PRS

    Thread Starter Well-Known Member

    Aug 24, 2008
    989
    35
    I am sure you are right. I am just wondering how to do it.
     
  17. PRS

    Thread Starter Well-Known Member

    Aug 24, 2008
    989
    35
    How do I do that with C, specifically?
     
  18. cheezewizz

    Active Member

    Apr 16, 2009
    82
    10
    The datasheet says ...
    Code ( (Unknown Language)):
    1. Note: On a Power-on Reset, RA5 and RA3:RA0
    2. are configured as analog inputs and read
    3. as ‘0’. RA6 and RA4 are configured as
    4. digital inputs.
    5. The operation of each pin is selected by clearing/setting the
    6. control bits in the ADCON1 register (A/D Control
    7. Register1).
    so it should be simply a case of setting
    Code ( (Unknown Language)):
    1. ADCON1 = 0x07;
     
  19. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,884
    1,002
    Have you looked at the sample code?
     
  20. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    on 18 devices, you write to LATx, but read PORTx

    In most cases PORTA, you can think "PORTAnalog", and remember to disable the analog hardware for digital I/O on PORTA/LATA.

    Once disabling comparators, etc, I've not had a problem working with PortA.

    Can you paste the source code you are using?
     
Loading...