Help Needed for C programming

Discussion in 'Programmer's Corner' started by Ralf, Apr 9, 2009.

  1. Ralf

    Thread Starter Active Member

    Mar 16, 2009
    31
    0
    guy if u all read my previous thread knowing that i using MPLAB IDE v8.20a C compiler to write C programming for my microchip 18f24k20 but now i have a problem.. i doing the same project but due to the microchip problem. i have change the chip to 18f252.

    i wanted to know that if i using the below code will i display anything? or is setting it as a input/output?

    PORTA = 0x00
    or
    TRISA = 0x00
    or
    LATA = 0x00

    which one is to send information of 0x00 ???
     
  2. Ralf

    Thread Starter Active Member

    Mar 16, 2009
    31
    0
    i also need help in how to write a code for blinking LED
     
  3. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    Are you using CCS compiler?
     
  4. maxpower097

    Well-Known Member

    Feb 20, 2009
    795
    388
    Not sure about the pic18 but for the pic24 it should be

    PORTA = 0x00 - Sets all pins off or 0 for portA
    or
    TRISA = 0x00 - Sets all pins in portA as Outputs

    To make them inputs and turn them on you should use 0xFF.
    0x00 = 00000000
    0xFF = 11111111
     
    Last edited: Apr 11, 2009
  5. dsp_redux

    Active Member

    Apr 11, 2009
    182
    5
    The inverse is true for some pic... For the dsPIC4013, you use TRISA = 0x0000 for outputs and TRISA = 0xFFFF for inputs. Just read about that register in the manual. But it is supposed to be something like that.
     
  6. maxpower097

    Well-Known Member

    Feb 20, 2009
    795
    388
    Your right. I looked it up TRISA = 0x00 = all outputs. I was just trying to tell him what was going on from memory. :)
     
  7. dsp_redux

    Active Member

    Apr 11, 2009
    182
    5
    The trick I use for remembering this is: 0 for Outputs, 1 for 1nputs.
     
Loading...