Beginner programmer, simple goal. Help please!

Discussion in 'Embedded Systems and Microcontrollers' started by milesguidon, Dec 17, 2010.

  1. milesguidon

    Thread Starter New Member

    Dec 4, 2010
    11
    0
    I'm programming a PIC24f using MPLAB with the C30 C compiler. My first goal is to light up some LEDs before I move on to anything more advanced. I'm a day or two into learning about MCUs, and I have some code written, but I think I may be missing a lot at the beginning (housekeeping/setup stuff) that is keeping my MCU from starting the program. Anyway, here's my code. I'd really appreciate any advice on how to "set up" an MCU before giving it specific instructions like enabling/disabling ports as input/output.

    Code ( (Unknown Language)):
    1.  
    2.  
    3. //include header file
    4. #include <p24f04ka200.h>
    5.  
    6. //configuration --I got the following by looking at options for config in the
    7. //header file above
    8. _FGS(GCP_OFF & GWRP_OFF)
    9. _FOSCSEL(FNOSC_FRC)
    10. _FOSC(POSCFREQ_LS)
    11. _FWDT(FWDTEN_OFF)
    12. _FPOR(MCLRE_ON)
    13. _FDS(DSWDTEN_OFF)
    14.  
    15. //main function
    16. int main()
    17. {    
    18.  
    19.     TRISB = 0x0000;
    20.     LATB = 0x0000; //Not sure if I need this
    21.     PORTB = 0x0000;    
    22.     ODCB = 0x0000; //Not sure if I need this
    23.    
    24. return 1;
    25. }
    26.  
    27.  
    I just want all of the portB pins on my MCU to be at VIH...
    be gentle! (thanks)
     
    Last edited by a moderator: Dec 17, 2010
  2. milesguidon

    Thread Starter New Member

    Dec 4, 2010
    11
    0
    Got it. I didn't have my test circuit connected properly...DUH
     
  3. maxpower097

    Well-Known Member

    Feb 20, 2009
    795
    388
    .......................................................
     
    Last edited: Jan 16, 2011
Loading...