C code now doesnt seem right on MPALB X IDE V3.61

Status
Not open for further replies.
T

treez

Guest
Hello,
Please advise why this code is now full of "unable to reslove identifier LATA0" etc etc , error messages.
This code was fine before.
It was running fine on the micro
I am sure i did not get such errors before.
Its XC8 C for PIC16F18856

Code:
//pwm dimming

//PIC16F18856
//XC8 compiler
//MPLAB X V3.61
//date 10 oct 2017

// PIC16F18856 Configuration Bit Settings
//
// 'C' source line config statements

// CONFIG1
#pragma config FEXTOSC = OFF    // External Oscillator mode selection bits (Oscillator not enabled)
#pragma config RSTOSC = HFINT1  // Power-up default value for COSC bits (HFINTOSC (1MHz))
#pragma config CLKOUTEN = OFF   // Clock Out Enable bit (CLKOUT function is disabled; i/o or oscillator function on OSC2)
#pragma config CSWEN = OFF      // Clock Switch Enable bit (The NOSC and NDIV bits cannot be changed by user software)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (FSCM timer disabled)

// CONFIG2
#pragma config MCLRE = OFF      // Master Clear Enable bit (MCLR pin function is port defined function)
#pragma config PWRTE = ON       // Power-up Timer Enable bit (PWRT enabled)
#pragma config LPBOREN = OFF    // Low-Power BOR enable bit (ULPBOR disabled)
#pragma config BOREN = ON       // Brown-out reset enable bits (Brown-out Reset Enabled, SBOREN bit is ignored)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (VBOR) set to 1.9V on LF, and 2.45V on F Devices)
#pragma config ZCD = OFF        // Zero-cross detect disable (Zero-cross detect circuit is disabled at POR.)
#pragma config PPS1WAY = OFF    // Peripheral Pin Select one-way control (The PPSLOCK bit can be set and cleared repeatedly by software)
#pragma config STVREN = OFF     // Stack Overflow/Underflow Reset Enable bit (Stack Overflow or Underflow will not cause a reset)

// CONFIG3
#pragma config WDTCPS = WDTCPS_31// WDT Period Select bits (Divider ratio 1:65536; software control of WDTPS)
#pragma config WDTE = OFF       // WDT operating mode (WDT Disabled, SWDTEN is ignored)
#pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
#pragma config WDTCCS = SC      // WDT input clock selector (Software Control)

// CONFIG4
#pragma config WRT = OFF        // UserNVM self-write protection bits (Write protection off)
#pragma config SCANE = not_available// Scanner Enable bit (Scanner module is not available for use)
#pragma config LVP = OFF        // Low Voltage Programming Enable bit (High Voltage on MCLR/Vpp must be used for programming)

// CONFIG5
#pragma config CP = OFF         // UserNVM Program memory code protection bit (Program Memory code protection disabled)
#pragma config CPD = OFF        // DataNVM code protection bit (Data EEPROM code protection disabled)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include [I]<[/I]xc.h[I]>[/I]
#include [I]<[/I]stdint.h[I]>[/I]

#define  _XTAL_FREQ 4000000

    uint8_t   count;
    uint8_t   count1;
    uint8_t   count2;

void main(void) {
    
    //Setup ports
        TRISA = 0x30;   //ADC INS
        TRISB = 0x08;    //ZCD & DALIRX..really 0x09
        TRISC = 0x00;   //SELECT
        
        ANSELA = 0x00;   //ADC INs
        ANSELB = 0x00;
        ANSELC = 0x00;
        
        WPUA = 0x00;
        ODCONA = 0x00;
        SLRCONA = 0x00;
        INLVLA = 0x00;      //ST?
        CCDPA = 0x00;
        CCDNA = 0x00;
        
        WPUB = 0x00;
        ODCONB = 0x00;
        SLRCONB = 0x00;
        INLVLB = 0x00;      //ST?
        CCDPB = 0x00;
        CCDNB = 0x00;
        
        WPUC = 0x00;
        ODCONC = 0x00;
        SLRCONC = 0x00;
        INLVLC = 0x00;      //ST?
        CCDPC = 0x00;
        CCDNC = 0x00; 
        
        INTCON = 0x00;
       
        CM1CON0 = 0x00;
        CM1CON1 = 0x00;
        CM2CON0 = 0x00;
        CM2CON1 = 0x00;

        PWM6CON = 0x00;
        PWM7CON = 0x00;
        
        ZCDCON = 0x00;
        
        //Initialize ports
        LATAbits.LATA0 = 0;
        LATAbits.LATA1 = 0;
        LATAbits.LATA2 = 0;
        LATAbits.LATA3 = 0;
        //LATAbits.LATA4 = 0;     temp sensor input
        //LATAbits.LATA5 = 0;     light sensor input
        LATAbits.LATA6 = 1;     //vmf pin FET
        LATAbits.LATA7 = 0;
                  
        //LATBbits.LATB0 = 0;      zero crossing input
        LATBbits.LATB1 = 0;
        LATBbits.LATB2 = 0;         //dali TX pin
        //LATBbits.LATB3 = 0;       dali RX pin
        LATBbits.LATB4 = 0;
        LATBbits.LATB5 = 0;           
        LATBbits.LATB6 = 0;
        LATBbits.LATB7 = 0;
                
        LATCbits.LATC0 = 0;
        LATCbits.LATC1 = 0;       //pwm dim
        LATCbits.LATC2 = 0;     //pulldown resistor not fitted
        LATCbits.LATC3 = 0;     //pulldown resistor not fitted 
        LATCbits.LATC4 = 0;
        LATCbits.LATC5 = 0;           
        LATCbits.LATC6 = 0;
        LATCbits.LATC7 = 0;
                
    //5 second delay
    for (count=1;count<=10;count++)   {
    __delay_ms(10);
    }
    LATCbits.LATC1 = 0;
    __delay_ms(30);
    LATAbits.LATA6 = 0;
    __delay_ms(30);
    
while(1){
        LATCbits.LATC1 = 0;
        __delay_us(10);
        LATCbits.LATC1 = 1;
        __delay_us(20); 
}
    
  

    return;
}
 
Last edited by a moderator:

Because

Code:
#include <xc.h>

is missing.

<xc.h> is not coming in the code window. Mods please check it.
 
Reactions: treez

    T

    Points: 2
    Helpful Answer Positive Rating
Hi,

I´ve edited post#1. Now it shows the #include filenames.

Klaus
 
Reactions: treez

    T

    Points: 2
    Helpful Answer Positive Rating
Seems like it is missing the specific processor reference, something like:
Code:
#include "PIC16F18856.h"

Moreover, I would add all includes at first lines, once there is no garantee that all #pragma directive argumets are avaliable for all processors.
 
Reactions: treez

    T

    Points: 2
    Helpful Answer Positive Rating
@andre_teprom - the XC8 compiler should select the correct processor-specific include in the 'xc.h" include using the IDE provided processor directive.
However if the LATA0 and similar symbols are not recognised it is a sign that the OP has selected the wrong processor in the IDE.
@OP - what changed between when you thought it worked and now when it doesn't? That will give a clue as to where to start looking for the problem.
Susan
 
Reactions: treez

    T

    Points: 2
    Helpful Answer Positive Rating
Thanks, microchip finally answered us, i had to go into the project window and click on re-parse the code.
no idea what it does, but now the code works.
Thankyou all
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…