TCS Pune

PIC: GPIO with MPLAB XC8

Practical lesson

PIC: GPIO with MPLAB XC8

Configure PIC data-direction and output registers in embedded C.

◷ 45 min

Parts and tools

  • PIC16F877A or trainer
  • PICkit programmer
  • LED and resistor

Lesson

Learning objective

Configure PIC data-direction and output registers in embedded C.

Procedure

  1. Review the circuit and confirm the board voltage.
  2. Build and inspect the wiring before applying power.
  3. Upload the example, observe the result and record your readings.
  4. Change one parameter, predict the result and test again.

Troubleshooting

Check power, ground, pin selection, polarity, compiler target and serial output. Use a multimeter or logic analyser where appropriate.

Example code

#include <xc.h>
void main(void){ TRISBbits.TRISB0=0; LATBbits.LATB0=1; while(1){} }

Knowledge check

What does a TRIS register configure?

Ready when you are

Need help with your laptop or computer?

Send us the model and fault details. Start your repair request online or contact TCS Pune directly.

WA