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 http://www.fernando-heitor.de/pic/projekte/max7219/programm.htm
(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<chip>
and #include <header.h>).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 ****/
/******* http://www.fernando-heitor.de ****/
/******* 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 ****/
/******* http://www.fernando-heitor.de ****/
/******* 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;x<4;x++)
{
output_low(DATA);
output_high(CLK);
output_low(CLK);
}
// The data bits D11-D8 contain the register address of the MAX7219
for (x=4;x>0;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