|
|
View previous topic :: View next topic |
Author |
Message |
BlueTower
Joined: 23 Oct 2008 Posts: 29
|
Beginner in CCS - modifying code from MCC18 |
Posted: Thu Nov 20, 2008 7:08 am |
|
|
Hi all. I have the following Test.c source file:
Code: | #include <18f65j90.h>
// PIC config register setup
//#pragma config DEBUG = ON, XINST = OFF, STVREN = ON, WDTEN = OFF
#FUSES DEBUG //Debug mode for use with ICD
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOWDT //No Watch Dog Timer
//#pragma config CP0 = OFF
#FUSES NOPROTECT //Code not protected from reading
//#pragma config IESO = OFF, FCMEN = OFF, FOSC2 = OFF, FOSC = HS
#FUSES NOIESO //Internal External Switch Over mode disabled //Internal External Switch Over mode disabled
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
//#pragma config WDTPS = 1, CCP2MX = DEFAULT
#FUSES WDT1 //Watch Dog Timer uses 1:1 Postscale
#FUSES PRIMARY //Primary clock is system clock when scs=00
#FUSES RESERVED //Used to set the reserved FUSE bits
#use delay(clock=8000000)
void initPIC(void);
//===================
void main()
{
initPIC();
while(1);
}
// ----------------------------------------------------------
// Processor initialisation routine
void initPIC (void)
{
RCON = 0xB3; // Reset control register, enable interrupt priority functions
TRISA = 0x0D; // Port setup, I/O direction
TRISB = 0x41;
TRISC = 0xC3;
TRISD = 0x00;
TRISE = 0x80;
TRISF = 0x90;
TRISG = 0x10;
LATA = 0x00; // Port setup - default values on power up
LATB = 0x00;
LATC = 0x40;
LATD = 0x00;
LATE = 0x00;
LATF = 0x60;
LATG = 0x18;
PORTG = 0x18;
// Enable the used LCD segment pins
LCDSE0 = 0xFF;
LCDSE1 = 0xFF;
LCDSE2 = 0x3F;
LCDSE3 = 0x00;
LCDSE4 = 0x00;
LCDDATA0 = 0x00; // Start by clearing the LCD display and registers
LCDDATA1 = 0x00;
LCDDATA2 = 0x00;
LCDDATA6 = 0x00;
LCDDATA7 = 0x00;
LCDDATA8 = 0x00;
LCDDATA12 = 0x00;
LCDDATA13 = 0x00;
LCDDATA14 = 0x00;
LCDDATA18 = 0x00;
LCDDATA19 = 0x00;
LCDDATA20 = 0x00;
// Now set up timer 1 as the 32KHz oscillator
TMR1L = 0x00; // Used for 2 seond clock for RTC
TMR1H = 0x00; // External 32.768KHz crystal
T1CON = 0x4F;
while(!(TMR1H & 0x10)); // Wait a while for Timer 1 to start
// This is necessary due to bug in processor
// That can cause LCD not to start correctly
// if the timer isnt fully up and running
LCDCON = 0x8F; // Enable the LCD, Using Timer 1 oscillator as source was 87
LCDPS = 0x36;
LCDREG = 0x3C;
// Now set up Timer 3 for a 25ms wake timer for sampling the sensors
TMR3H = TIMER3_H;
TMR3L = TIMER3_L;
T3CON = 0x87;
ADCON0 = 0; // Disable ADC for now
ADCON1 = 0x0C; // But prepare its use for sensor sampling
WDTCON = 0x80; // Disable watchdog and enable regulator shutdown in sleep
CMCON = 0x0F; // Disable Comparitor for now
CVRCON = 0x00;
INTCON = 0x00;
INTCON2 = 0xC0; // Disable Port B pull-ups
INTCON3 = 0x00;
PIE1 = 0x01; // TMR1 interrupt enabled for RTC
PIE2 = 0x02; // TMR3 interrupt enabled for 25ms timer
PIE3 = 0x00;
IPR1 = 0xEF;
IPR2 = 0xFD;
IPR3 = 0xFF;
INTCONbits.GIE = 1; // Enable interrupts
INTCONbits.PEIE = 1; // Enable low priority interrupts
//KDL - Setup RS-232 Interrupt
INTCONbits.INT0IE = 1; // KDL - Enable INT0 (Pin RB0)
} |
Errors:
Quote: | >>> Warning 203 "Test.c" Line 35(1,1): Condition always TRUE C2OUT
*** Error 12 "Test.c" Line 45(6,10): Undefined identifier RCON
*** Error 12 "Test.c" Line 47(7,12): Undefined identifier TRISA
*** Error 12 "Test.c" Line 48(7,12): Undefined identifier TRISB
*** Error 12 "Test.c" Line 49(7,12): Undefined identifier TRISC
*** Error 12 "Test.c" Line 50(7,12): Undefined identifier TRISD
*** Error 12 "Test.c" Line 51(7,12): Undefined identifier TRISE
*** Error 12 "Test.c" Line 52(7,12): Undefined identifier TRISF
*** Error 12 "Test.c" Line 53(7,12): Undefined identifier TRISG
*** Error 12 "Test.c" Line 55(6,10): Undefined identifier LATA
*** Error 12 "Test.c" Line 56(6,10): Undefined identifier LATB
*** Error 12 "Test.c" Line 57(6,10): Undefined identifier LATC
*** Error 12 "Test.c" Line 58(6,10): Undefined identifier LATD
*** Error 12 "Test.c" Line 59(6,10): Undefined identifier LATE
*** Error 12 "Test.c" Line 60(6,10): Undefined identifier LATF
*** Error 12 "Test.c" Line 61(6,10): Undefined identifier LATG
*** Error 12 "Test.c" Line 62(7,12): Undefined identifier PORTG
*** Error 12 "Test.c" Line 65(8,14): Undefined identifier LCDSE0
*** Error 12 "Test.c" Line 66(8,14): Undefined identifier LCDSE1
*** Error 12 "Test.c" Line 67(8,14): Undefined identifier LCDSE2
*** Error 12 "Test.c" Line 68(8,14): Undefined identifier LCDSE3
*** Error 12 "Test.c" Line 69(8,14): Undefined identifier LCDSE4
*** Error 12 "Test.c" Line 72(10,18): Undefined identifier LCDDATA0
*** Error 12 "Test.c" Line 73(10,18): Undefined identifier LCDDATA1
*** Error 12 "Test.c" Line 74(10,18): Undefined identifier LCDDATA2
*** Error 12 "Test.c" Line 75(10,18): Undefined identifier LCDDATA6
*** Error 12 "Test.c" Line 76(10,18): Undefined identifier LCDDATA7
*** Error 12 "Test.c" Line 77(10,18): Undefined identifier LCDDATA8
*** Error 12 "Test.c" Line 78(11,20): Undefined identifier LCDDATA12
*** Error 12 "Test.c" Line 79(11,20): Undefined identifier LCDDATA13
*** Error 12 "Test.c" Line 80(11,20): Undefined identifier LCDDATA14
*** Error 12 "Test.c" Line 81(11,20): Undefined identifier LCDDATA18
*** Error 12 "Test.c" Line 82(11,20): Undefined identifier LCDDATA19
*** Error 12 "Test.c" Line 83(11,20): Undefined identifier LCDDATA20
*** Error 12 "Test.c" Line 86(7,12): Undefined identifier TMR1L
*** Error 12 "Test.c" Line 87(7,12): Undefined identifier TMR1H
*** Error 12 "Test.c" Line 88(7,12): Undefined identifier T1CON
*** Error 12 "Test.c" Line 90(15,20): Undefined identifier TMR1H
*** Error 12 "Test.c" Line 95(8,14): Undefined identifier LCDCON
*** Error 12 "Test.c" Line 96(7,12): Undefined identifier LCDPS
*** Error 12 "Test.c" Line 97(8,14): Undefined identifier LCDREG
*** Error 12 "Test.c" Line 100(7,12): Undefined identifier TMR3H
*** Error 12 "Test.c" Line 101(7,12): Undefined identifier TMR3L
*** Error 12 "Test.c" Line 102(7,12): Undefined identifier T3CON
*** Error 12 "Test.c" Line 103(8,14): Undefined identifier ADCON0
*** Error 12 "Test.c" Line 104(8,14): Undefined identifier ADCON1
*** Error 12 "Test.c" Line 106(9,15): Undefined identifier WDTCON
*** Error 12 "Test.c" Line 107(7,12): Undefined identifier CMCON
*** Error 12 "Test.c" Line 108(8,14): Undefined identifier CVRCON
*** Error 12 "Test.c" Line 110(8,14): Undefined identifier INTCON
*** Error 12 "Test.c" Line 111(9,16): Undefined identifier INTCON2
*** Error 12 "Test.c" Line 112(9,16): Undefined identifier INTCON3
*** Error 12 "Test.c" Line 113(6,10): Undefined identifier PIE1
*** Error 12 "Test.c" Line 114(6,10): Undefined identifier PIE2
*** Error 12 "Test.c" Line 115(6,10): Undefined identifier PIE3
*** Error 12 "Test.c" Line 116(6,10): Undefined identifier IPR1
*** Error 12 "Test.c" Line 117(6,10): Undefined identifier IPR2
*** Error 12 "Test.c" Line 118(6,10): Undefined identifier IPR3
*** Error 12 "Test.c" Line 120(1,11): Undefined identifier INTCONbits
*** Error 12 "Test.c" Line 121(1,11): Undefined identifier INTCONbits
*** Error 12 "Test.c" Line 124(1,11): Undefined identifier INTCONbits
60 Errors, 1 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Thu Nov 20 13:19:19 2008 |
At the beginning of Test.c I include the 18f65j90.h file but doesn't mention anything about periphals and that's why I get this error. Does this mean I have to include the p18f65j90.h or what?
Regards |
|
|
Ttelmah Guest
|
|
Posted: Thu Nov 20, 2008 8:18 am |
|
|
The CCS compiler, is closer to a 'big C', in the way it handles I/O, than MCC, which behaves more like assembler in this regard. So (for instance), you would normally setup timer1, with a line like:
setup_timer1(T1_EXTERNAL|T1_CLK_OUT|T_DIV_BY_1);
as a complete single symbolic instruction, to setup the I/O, and divisors for this peripheral, rather than directly writing to the registers. the same applies for the other peripherals.
The include file, does 'know about the peripherals', but only as used with the CCS symbolic commands, not the individual names for every port.
You _can_ work directly like with MCC, but to do so, you need to load a register 'map', to give the symbolic names for the registers. Ones have been posted here in the past for the 16, and standard 18 chips, but I don't remember seeing one for the newer chips like yours. You would probably have to load the standard 18 one, and then define the extra registers yourself.
Best Wishes |
|
|
BlueTower
Joined: 23 Oct 2008 Posts: 29
|
|
Posted: Thu Nov 20, 2008 8:42 am |
|
|
Thanks, I think you mean something like the following example that I found :
#byte PIE3 = 0xFA3
#bit TXB0IE = PIE3.2
#bit TXB1IE = PIE3.3
#bit TXB2IE = PIE3.4
but from where do I get the standard 18 register 'map' file ? |
|
|
Ttelmah Guest
|
|
Posted: Thu Nov 20, 2008 10:53 am |
|
|
Do a search for "register_list.h". This should find one that was posted for the early PIC18 chips. There may be other latter ones on the forum.
Best Wishes |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Nov 20, 2008 6:07 pm |
|
|
An include file for the PIC18F452 and 458 can be found in: http://www.ccsinfo.com/forum/viewtopic.php?t=14755
These files are easy to adapt/extend for your processor.
Another option is to use Chipedit.exe in the v4 compiler for generating a register include file. In Chipedit select your processor and then 'Registers / Make Include file'.
Chipedit.exe is downloadable from the CCS website in the IDEUTILS package (possibly the Command Line versions of the CCS compilers don't have download rights for this toolset?). |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Thu Nov 20, 2008 8:08 pm |
|
|
Wow ckielstra, I had not discovered the ability of Chipedit to create the discreet register files, it works great...... I had been making these as needed all this time.
Looks like I learned another something new today!
Thank You! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|