Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18F4431 Compile Errors

Status
Not open for further replies.

cobra1

New Member
Hi guys,
Im working on a project and was origionally using a PIC16F877A chip. However when i compiled it i ran out of space on the chip (it compiled with no errors).

So i changed to a chip with more memory, the PIC18F4431. however now if it try to compile it using the exact same code as i did with the 16f877 (apart from chip definitions etc) im getting errors and it will not compile.

here are the errors.

C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h:1252:Error [1105] symbol 'MX_CLEAR_WATCHDOG' has not been defined
C:\Program Files\Matrix Multimedia\Flowcode V4\FCD\internals.h:1253:Warning [2058] call of function without prototype
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:283:Error [1105] symbol 'portb' has not been defined
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:283:Warning [2058] call of function without prototype
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:284:Error [1105] symbol 'portb' has not been defined
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:284:Warning [2058] call of function without prototype
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:285:Error [1105] symbol 'portb' has not been defined
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:285:Warning [2058] call of function without prototype
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:286:Error [1105] symbol 'portb' has not been defined
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:286:Warning [2058] call of function without prototype
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:287:Error [1105] symbol 'portb' has not been defined
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:287:Warning [2058] call of function without prototype
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:288:Error [1105] symbol 'portb' has not been defined
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:288:Warning [2058] call of function without prototype
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:291:Error [1105] symbol 'portb' has not been defined
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:291:Warning [2058] call of function without prototype
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:293:Error [1105] symbol 'portb' has not been defined
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:293:Warning [2058] call of function without prototype
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:295:Error [1105] symbol 'portb' has not been defined
C:\Documents and Settings\Administrator\Desktop\STAT 18F4431.c:295:Warning [2058] call of function without prototype
Halting build on first failure as requested.


First error regarding the WATCHDOG i havnt a clue what it means there as im not even using the watchdog.
the "error 1105 symbol 'portb' has not been defined" appears to me to be the same error as the watchdog as its on the same line.

The "Warning [2058] call of function without prototype" i dont know what this means but from google searching it would appear that i can still compile with this as its just a warning but i would like to get rid of it.

now heres the problem.
when looking at my .C file in mplab and going to either line 1105 or 2058 there is nothing written in them.

here is whats there (line 1105)

//store old tris value, and set the i/o pin as an input
old_tris = MX_ADC_TRIS_REG;
MX_ADC_TRIS_REG = MX_ADC_TRIS_REG | MX_ADC_TRIS_MSK;

//turn ADC on
adcon0 = adcon0 | 0x01;
This is line 1105>>
//wait the acquisition time
cnt = 0;
while (cnt < MX_ADC_SAMP_TIME) cnt++;

//begin conversion and wait until it has finished
adcon0 = adcon0 | 0x02;
while (adcon0 & 0x02);

//restore old tris value, and reset adc registers
MX_ADC_TRIS_REG = old_tris;
adcon0 = 0x00;
ansel0 = 0x00;

this is whats there for line 2058

//Input
//Input: D1 -> OK
trisd = trisd | 0x02;
FCV_OK = ((portd & 0x02) == 0x02);


//Input
//Input: C3 -> ADJUST
trisc = trisc | 0x08;
FCV_ADJUST = ((portc & 0x08) == 0x08);
This is line 2058>>

//PLACE CURSER
//Call Component Macro: LCDDisplay(0)::Cursor(0, 0)
FCD_LCDDisplay0_Cursor(0, 0);


//PRINT SET AMBIENT TEMP
//Call Component Macro: LCDDisplay(0)::printASCII("*SET NIGHTTIME DROP*")
FCD_LCDDisplay0_PrintASCII('*');
FCD_LCDDisplay0_PrintASCII('S');
FCD_LCDDisplay0_PrintASCII('E');
FCD_LCDDisplay0_PrintASCII('T');


Can anyone help me out here???
 
Not familiar with flowcode, but the 18f4431 has a completely different register setup for the ADC module from the 16f877a. So the short answer would be; to ask your software provider to fix the ADC library to support the 18f4431. The long answer would be; to dig into the data sheet and set it up manually, if you can, or allowed to do so.
 
looking at the chips there the more or less the same pin to pin, and the adc ports are on PORTA this error is saying PORTB, which is where my lcd is connected to
 
Last edited:
Errors are not always on the line where the compiler reports them. For example lack of prototype is usually because a header file is missing. Lack of definition of portb because the header file for the chip has not been included, possibly because you have not targeted the compiler to the correct chip. There really seem to be only 3 errors here, you should be able to work thru them.
 
looking at the chips there the more or less the same pin to pin, and the adc ports are on PORTA this error is saying PORTB, which is where my lcd is connected to
Yes same pinout, but the 18f4431 has way more pin functions (i.e. registers) to deal with. The stab at the ADC module was because it doesn't seem to compile per your comment here:
Code:
//turn ADC on
adcon0 = adcon0 | 0x01;
[COLOR="Red"]This is line 1105>>[/COLOR]
//wait the acquisition time
cnt = 0;
while (cnt < MX_ADC_SAMP_TIME) cnt++;

I can only speculate that the LCD setup isn't quite right in terms of defining the data port, rs, rw, and enable lines, in the main program. Maybe a Flowcoder will step in to help out:).
 
Errors are not always on the line where the compiler reports them. For example lack of prototype is usually because a header file is missing. Lack of definition of portb because the header file for the chip has not been included, possibly because you have not targeted the compiler to the correct chip. There really seem to be only 3 errors here, you should be able to work thru them.

this i have read on pages found on google, but after trying about every different way to include the header file and it doesnt work then i am stumped.


here is what i have.

#define MX_PIC

//Defines for microcontroller
#define P18F4431
#define MX_EE
#define MX_EE_TYPE3
#define MX_EE_SIZE 256
#define MX_SPI
#define MX_SPI_D
#define MX_SPI_SDI 2
#define MX_SPI_SDO 1
#define MX_SPI_SCK 3
#define MX_UART
#define MX_UART_C
#define MX_UART_TX 6
#define MX_UART_RX 7
#define MX_I2C
#define MX_I2C_D
#define MX_I2C_SDA 2
#define MX_I2C_SCL 3
#define MX_PWM
#define MX_PWM_CNT 2
#define MX_PWM_TRIS1 trisc
#define MX_PWM_1 2
#define MX_PWM_TRIS2 trisc
#define MX_PWM_2 1

//Functions
#define MX_CLK_SPEED 19660800
#ifdef _BOOSTC
#include <system.h>
#endif
#ifdef HI_TECH_C
#include <BoostCPic18.h>
#endif


i have also tried

#define MX_PIC

//Defines for microcontroller
#define P18F4431
#define MX_EE
#define MX_EE_TYPE3
#define MX_EE_SIZE 256
#define MX_SPI
#define MX_SPI_D
#define MX_SPI_SDI 2
#define MX_SPI_SDO 1
#define MX_SPI_SCK 3
#define MX_UART
#define MX_UART_C
#define MX_UART_TX 6
#define MX_UART_RX 7
#define MX_I2C
#define MX_I2C_D
#define MX_I2C_SDA 2
#define MX_I2C_SCL 3
#define MX_PWM
#define MX_PWM_CNT 2
#define MX_PWM_TRIS1 trisc
#define MX_PWM_1 2
#define MX_PWM_TRIS2 trisc
#define MX_PWM_2 1

//Functions
#define MX_CLK_SPEED 19660800
#ifdef _BOOSTC
#include <system.h>
#endif
#ifdef HI_TECH_C
#include <p18f4431.h>
#endif
 
also tried this

#define MX_PIC

//Defines for microcontroller
#define P18F4431
#define MX_EE
#define MX_EE_TYPE3
#define MX_EE_SIZE 256
#define MX_SPI
#define MX_SPI_D
#define MX_SPI_SDI 2
#define MX_SPI_SDO 1
#define MX_SPI_SCK 3
#define MX_UART
#define MX_UART_C
#define MX_UART_TX 6
#define MX_UART_RX 7
#define MX_I2C
#define MX_I2C_D
#define MX_I2C_SDA 2
#define MX_I2C_SCL 3
#define MX_PWM
#define MX_PWM_CNT 2
#define MX_PWM_TRIS1 trisc
#define MX_PWM_1 2
#define MX_PWM_TRIS2 trisc
#define MX_PWM_2 1

//Functions
#define MX_CLK_SPEED 19660800
#ifdef _BOOSTC
#include <system.h>
#endif
#ifdef HI_TECH_C
#include <pic18.h>
#endif
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top