#2849

Bitahwa Bindu
Keymaster

Here are your error:

  1. In the header file: newxc8_header.h you define the frequency as 160MHz (#define _XTAL_FREQ 160000000) if you are intending to use 16MHz, delete one zero.
  2. In your main C file: newmain.C you are defining again the configuration bits. Why? other you delete the header file and configure everything in the main C file or you delete #pragma config in main C because you have done already in header file.
  3. In your main C file: newmain.C why you are defining again the frequency? because you hav edone so already in header file. And you are defining it again wrong: #define _XTAL_FREQ 1600000008 is 1.6GHz not 16MHz. You must be careful with your zeros.
  4. You must include the header file in your main C file. write this code on top of your main file: #include “newxc8_header.h”
  5. The delays you used are for 8MHz like in our example, you must calculate for 16MHZ. Write these delays in your code:void DelayFor18TCY( void ) //18 cycles delay
    {
    Delay10TCYx(20);
    // Nop( ); Nop( ); Nop( ); Nop( ); // 18 cycle delay
    //Nop( ); Nop( ); Nop( ); Nop( );
    //Nop( ); Nop( ); Nop( ); Nop( );
    //Nop( ); Nop( );
    //return;
    }

    void DelayPORXLCD (void) // Delay of 15ms
    {
    Delay1KTCYx(60);
    // __delay_ms(15);
    }

    void DelayXLCD (void) // Delay of 5ms
    {
    Delay1KTCYx(20);
    // __delay_ms(5);
    }