CC51 compile error with MPLAB

Hey everybody,

I am trying to resolve a compile-time error using CC5x through MPLab. I have a code project (SOURCE CODE AT BOTTOM) where I'm trying to drive some LEDs out of a MAX7219 driver IC. I have taken the code outlined below from

formatting link
(bless them, there is so little information relating to the combination of the MAX7219 and the PIC16f84). On this site the guy states (I had to translate the web page with World Lingo - great translator!) that the project was tested with CCC5x, but damned if I can figure out what the problem is.

CC5X version is 3.2A MPLAB version is 6.61

The compile error I get is as follows:

------------------------------------------------------------------------------- Executing: "C:\cc5x\CC5X.EXE" MAX7219.c -CC -fINHX8M -p16F84A

-IC:\cc5x -a -L -Q -V -FM CC5X Version 3.2A, Copyright (c) B Knudsen Data, Norway 1992-2004 --> FREE edition, 8-16 bit int, 24 bit float, 1k code, reduced optim. MAX7219.c: // HEADER FILE #pragma chip PIC16F84A, core 14, code 1024, ram 12 : 0x4F mapped_into_bank_1 ^------ Error[1] C:\scott.hooper\Personal\MPLab\MAX7219\16F84A.H 2 : Duplicate chip definition (Multiple chip definitions detected (option -p and #include ).The #include statement should be removed) Error options: -ew: no warning details -ed: no error details -eL: list details BUILD FAILED: Mon Sep 27 17:47:53 2004

-------------------------------------------------------------------------------

Under Project->Build Options I have the CC5x directory INCLUDEd. There is no -p option specified for either CC5x or MPASM and indeed I have tried using the CC5x /p- (disable processor type setting) parameter, but no success.

Source code is as follows...

/MAX7219.C /*************************************************************/ /******* Ansteuerung eines MAX7219 LED-Treiber ****/ /******* von Fernando Heitor ****/ /*******

formatting link
****/ /******* 07.10.2003 ****/ /******* für den PIC16F84a ****/ /******* DATA am MAX7219 = PIN RB1 ****/ /******* LOAD am MAX7219 = PIN RB2 ****/ /******* CLK am MAX7219 = PIN RB3 ****/ /******* Die Routine AUSGABE() überträgt die Daten ****/ /******* an den MAX7219 LED-Treiber ****/ /*************************************************************/ #include "max7219.h" char digit,daten; void main() { set_tris_a(0); // Pins von Port A are defined as exit set_tris_b(0); // Pins von Port B are defined as exit setup_counters(RTCC_INTERNAL,RTCC_DIV_2); output_high(LOAD); // The pin LOAD at the MAX7219 is set as the first on HIGH output_low(CLK); // The pin CLK at the MAX7219 is set as the first on HIGH ausgabe_init(); // The routine initialize the MAX7219 digit=1; // Variable digit goes through all digits and on first is set daten=0; // Variable data are the data of 0-9 for the individual digits while (1) { ausgabe(digit,data); // That is the output routine for the MAX7219 delay_ms(500); // Break of 500ms daten++; digit++; if (digit==6) digit=1; // The number of digits (here only 5 digits) is reached the variable again on first is set. if (daten==10) daten=0; // The data for the digits 0-9 } }

-------------------------------------------------------------------------------

/MAX7219.H /*************************************************************/ /******* Ansteuerung eines MAX7219 LED-Treiber ****/ /******* von Fernando Heitor ****/ /*******

formatting link
****/ /******* 07.10.2003 ****/ /******* für den PIC16F84a ****/ /******* DATA am MAX7219 = PIN RB1 ****/ /******* LOAD am MAX7219 = PIN RB2 ****/ /******* CLK am MAX7219 = PIN RB3 ****/ /******* Die Routine AUSGABE() überträgt die Daten ****/ /******* an den MAX7219 LED-Treiber ****/ /*************************************************************/

#include "16F84A.H" #use delay(clock=4000000) #fuses XT,NOWDT

#define DATA PIN_B1 // PIN RB1 = DATA am MAX7219 #define LOAD PIN_B2 // PIN RB2 = LOAD am MAX7219 #define CLK PIN_B3 // PIN RB3 = CLK am MAX7219

// Here the individual digits are headed for // The variable ADDRESS indicates the register address (bit D8-D11) of the MAX7219 // The variable VALUE contains the data (D0-D7) for the MAX7219 void AUSGABE(char adresse,char wert) { char x; // Before the data will transfer, first the pin LOAD is set on LOW. // The data begin with the bit D15, thus MSB output_low(LOAD); // The data bits D15-D12 are transferred // Since these are not important, 0 one conveys for (x=0;x0;x--) { if (bit_test(adresse,x-1)) output_high(DATA); else output_low(DATA); output_high(CLK); output_low(CLK); } // The data bits D7-D0 are the data to the MAX7219 for (x=8;x>0;x--) { if (bit_test(wert,x-1)) output_high(DATA); else output_low(DATA); output_high(CLK); output_low(CLK); } // In the end the pin LOAD is set on HIGH, thus is those // Data communication to end output_high(LOAD); }

void ausgabe_init() { ausgabe(0x0b, 0x04); // Here the number of digits is indicated (5 digits) ausgabe(0x0c, 0x01); // Displays are set on normal operation (no shutdown) ausgabe(0x09,0xff); // Displays are set on normal operation (no display test) ausgabe(0x0a, 0x00); // The brightness of the digits is stopped here }

-------------------------------------------------------------------------------

// 16F84A.H (included with distro of CC5x) // HEADER FILE #pragma chip PIC16F84A, core 14, code 1024, ram 12 : 0x4F mapped_into_bank_1

#define INT_min_style

#pragma config_def 0x0111

/* Predefined: char W; char INDF, TMR0, PCL, STATUS, FSR, PORTA, PORTB; char OPTION, TRISA, TRISB; char PCLATH, INTCON; bit PS0, PS1, PS2, PSA, T0SE, T0CS, INTEDG, RBPU_; bit Carry, DC, Zero_, PD, TO, RP0, RP1, IRP; bit RBIF, INTF, T0IF, RBIE, INTE, T0IE, GIE; bit PA0, PA1; // PCLATH

*/

#pragma char EEDATA @ 8 #pragma char EEADR @ 9

#pragma char EECON1 @ 0x88 #pragma char EECON2 @ 0x89

#pragma bit RA0 @ 5.0 #pragma bit RA1 @ 5.1 #pragma bit RA2 @ 5.2 #pragma bit RA3 @ 5.3 #pragma bit RA4 @ 5.4

#pragma bit RB0 @ 6.0 #pragma bit RB1 @ 6.1 #pragma bit RB2 @ 6.2 #pragma bit RB3 @ 6.3 #pragma bit RB4 @ 6.4 #pragma bit RB5 @ 6.5 #pragma bit RB6 @ 6.6 #pragma bit RB7 @ 6.7

#pragma bit EEIE @ 11.6 mapped_into_bank_1

#pragma bit RD @ 0x88.0 #pragma bit WR @ 0x88.1 #pragma bit WREN @ 0x88.2 #pragma bit WRERR @ 0x88.3 #pragma bit EEIF @ 0x88.4

Many thanks to anybody that can suggest where I'm going wrong, Scott Hooper

Reply to
Scott Hooper
Loading thread data ...

Looks like your MAX7219.h file starts with "#pragma chip PIC16F84A etc" but MPLAB automatically takes care of chip selection in the menu bar under configure | select device and passes this info to the compiler. So try commenting out the pragma in your header file.

Incidentally, are you sure your compiler is compatible with MPLAB?

Reply to
Ppelectron

Thanks very much for your reply. I commented out the #pragma line, but now get a "constant out of range" error in 16F84A.H on lines 22 and 23 (#pragma char EECON1/2 @ 0x88/89).

I have to admit I've never used the CC5x/MPLab combination before, but from what I've read on the net they are compatible. There is a detailled project setup INSTALL.TXT that discusses how to do it. Mostly it's just about include paths and configuration bits . I'm new to microcontrollers and am just looking for any software combination that will allow me to get the 16F84A talking with a MAX7219.

Reply to
Scott Hooper

Hmmm, I would try restoring the header file, then eliminate the -p option. MPLAB is basically an IDE that will invoke your compiler. Make it generate the command line options that you want.

Thad

Reply to
Thad Smith

MPLAB is basically an IDE that will invoke

Hi Thad, I think you've hit the nail on the head. The -p option is being invoked. Here's the command line being generated, copied from the MPLab output window:

Executing: "C:\cc5x\CC5X.EXE" max7219.c -CC -fINHX8M -p16F84A

-IC:\cc5x -a -L -Q -V -FM

Thing is, I've been through every single screen in MPLab and I can't find where that processor spec is being set. In the project build options the parameters for the CC5X Compiler are "-CC -fINHX8M -a -L

-Q -V -FM" with no Additional Command-Line Options. The MPASM parameters read "/e+ /l+ /x- /c+", again with no additional options set. Any idea how to turn off the -p part?

Kind regards and great thanks for your help so far, Scott Hooper

Reply to
Scott Hooper

MPLAB is basically an IDE that will invoke

CC5x is compatible with MPLAB. You need not to include the header file of your chip. At the time of start new project, it will ask whats your target device. then onemore thing , you have to give path for cc5x and linker information.

Reply to
tamilmaran s

I think I've found the problem. The source was created using CCS PCM compiler and I've got my MPLab configured for CC5x. I've tried to interpret the source to be code compatible with CC5x but I'm out of my depth. If anyone has a copy of CCS PCM they're willing to sell I'd be interested in buying.

Reply to
Scott Hooper

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.