Author Topic: PIC18F4550 pin Input/Output code  (Read 904 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
PIC18F4550 pin Input/Output code
« on: April 29, 2016, 08:14:48 am »
I am using PIC18F4550 with MPBALX IDE V2.26, Xc8 V1.32.
Below are codes for making pin as output & input. Are these codes ok.
I have tried on proteus & it is working. But after few seconds, it throw warning that not in real time due to excessive cpu load.

1. Output

/* output low w& make it output */
    LATBbits.LATB0 = 0U;
    TRISBbits.TRISB0 = 0U;

/* make low & the high */
    LATBbits.LATB0 = 0U;
    LATBbits.LATB0 = 0U;

/* keep on inverting */
    while(1)
    {
        LATBbits.LATB0 = !LATBbits.LATB0;
    }
   
   
2. Input

/* output low w& make it output */
    LATBbits.LATB0 = 0U;
    TRISBbits.TRISB0 = 0U;

/* make it input */
    TRISBbits.TRISB1 = 1U;

/* keep on reading */
    while(1)
    {
        LATBbits.LATB0 = PORTBbits.RB1;
    }   
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf