Forums MikroC Pro for PIC Project Discussions is there any changes on the code if i change it to pic16f877a Reply To: is there any changes on the code if i change it to pic16f877a

#3044

Bitahwa Bindu
Keymaster

We have commented out what should be changed in the code and replaced with correct code.

Here is the summary:

  • Change LAT with PORT: Use PORT register to read and input or write an output when using the old models of PIC16F series, they don’t have the LAT register.
  • Delete these lines of codes:

// ANSEL = 0; // Configure Analog pins as digital Input/Output pins
// ANSELH = 0;
//ADCON1
// OSCCON = 0x66; // configure OSCCON to use 8MHz internal Oscillator

  • Because there is no need to disable the analog function as pins with analog features are on PORTA and PORTE, no analog pin on PORTB. If you want to disable analog features on PORTA/PORTE, use the ADCON1 register.
  • This PIC does not have internal oscillator, so remove OSCCON =0x66, you must use an external crystal connected to pins 13 and 14.

Here is the complete code: