View previous topic :: View next topic |
Author |
Message |
gfbankston
Joined: 21 Jul 2014 Posts: 35
|
PIC18F25K50 does not run correctly |
Posted: Mon Jul 21, 2014 7:37 am |
|
|
Hello,
I have been using the XC8 Microchip compiler for a short while and have gotten my board to run properly with it and the ICD3.
The exact same code, with subtle differences in syntax, compiles and 'runs' with the CCS system, except that the board does not run correctly.
It seems, first of all, that the chip runs very slowly. The oscillator is internal, running at 6Mhz, verified when using the XC8 object code.
I have examined all the config registers, and most of the SFR registers between the code versions running the ICD3, and so no differences.
Has anyone else ever seen this, or have a suggestion as to what might be wrong, seeing that XC8 code works and CCS code does not???
I have wasted over a week so far trying to resolve this issue...
Take care,
GlenB |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Jul 21, 2014 8:04 am |
|
|
You need to show us your code !!
Please post your program so we can cut/past/compile/run/test.
You also need to tell us which compiler version you're using( could be a bug)
Also if you're using MPLAB, you need to set the build configuration to 'release' NOT 'debug'.
hth
jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jul 21, 2014 2:43 pm |
|
|
At a minimum, you need to:
1. Post your #fuses statement, and your #use delay() statement.
2. Post the list of Configuration Fuses implemented during compilation.
Look at end of the .LST file to find this list.
3. Since you're using the internal oscillator, use the INTRC fuse (instead
of INTRC_IO), and look at the CLKO pin. This pin will have Fosc/4 on it.
Post the frequency that you see. (With XC8 and with CCS).
4. If everything was running correctly, what are your desired frequencies
for Fosc and USB ? (Only post the USB freq if you are using USB).
5. If you have a setup_oscillator() statement in your CCS program, post it.
6. Post your __CONFIG and #define CLOCK_FREQ statements for XC8.
7. Post the Vdd voltage for your PIC.
8. Post if you're using an "F" or an "LF" version of the PIC.
9. Post your CCS compiler version.
That's a lot of information requested, but all of it can affect the Fosc
frequency of your PIC, and why you're getting different results between
the two compilers. |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Jul 21, 2014 9:05 pm |
|
|
Hi,
My prediction is that this dude is not a CCS user at all, he's just making a stealth attempt to get help with an XC8 compiler issue over here. When pressed for details, he just disappears...... I hope he proves me wrong, but I doubt it. Too many 'red flags' on the initial post.......
John |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue Jul 22, 2014 12:54 am |
|
|
I suspect I agree with ezflyr....
However the obvious thing is clock.
CCS requires it's clock setup. If you are just porting across the configuration from XC, this will not tell CCS what clock rate to use.
This is the core of PCM_programmers questions. |
|
|
gfbankston
Joined: 21 Jul 2014 Posts: 35
|
Sample code |
Posted: Tue Jul 22, 2014 7:14 am |
|
|
Hello,
Thanks for all that responded! The last reply was very interesting, and NO I had not told CCS what clock I was using.
I am using the latest compiler, since I just started using it. The version is up to 18F chips.
How does one put a bunch of lines here? I have prepared a file with relevant setup code including fuses and sfr setup. I will attempt to cut and paste here...
Code: | #device PIC18F25K50
#include <18f25k50.h>
#device const=rom
#include <stdio.h>
#byte MCU_WPUB = 0xF85
#byte MCU_PORTE = 0xF84
#byte MCU_PORTD = 0xF83
#byte MCU_PORTC = 0xF82
#bit MCU_RC0 = MCU_PORTC.0
#bit MCU_RC1 = MCU_PORTC.1
#bit MCU_RC2 = MCU_PORTC.2
#bit MCU_RC4 = MCU_PORTC.4
#bit MCU_RC5 = MCU_PORTC.5
#bit MCU_RC6 = MCU_PORTC.6
#bit MCU_RC7 = MCU_PORTC.7
#byte MCU_PORTB = 0xF81
#bit MCU_RB0 = MCU_PORTB.0
#bit MCU_RB1 = MCU_PORTB.1
#bit MCU_RB2 = MCU_PORTB.2
#bit MCU_RB4 = MCU_PORTB.4
#bit MCU_RB5 = MCU_PORTB.5
#bit MCU_RB6 = MCU_PORTB.6
#bit MCU_RB7 = MCU_PORTB.7
#byte MCU_PORTA = 0xF80
#bit MCU_RA0 = MCU_PORTA.0
#bit MCU_RA1 = MCU_PORTA.1
#bit MCU_RA2 = MCU_PORTA.2
#bit MCU_RA4 = MCU_PORTA.4
#bit MCU_RA5 = MCU_PORTA.5
#bit MCU_RA6 = MCU_PORTA.6
#bit MCU_RA7 = MCU_PORTA.7
#word MCU_TMR0 = 0xFD7
#byte MCU_T0CON = 0xFD5
#bit MCU_T0PS0 = MCU_T0CON.0
#bit MCU_T0PS1 = MCU_T0CON.1
#bit MCU_T0PS2 = MCU_T0CON.2
#bit MCU_PSA = MCU_T0CON.3
#bit MCU_T0SE = MCU_T0CON.4
#bit MCU_T0CS = MCU_T0CON.5
#bit MCU_T08BIT = MCU_T0CON.6
#bit MCU_TMR0ON = MCU_T0CON.7
#byte MCU_LATE = 0xF8D
#byte MCU_LATD = 0xF8C
#byte MCU_LATC = 0xF8B
#bit MCU_LATC0 = MCU_LATC.0
#bit MCU_LATC1 = MCU_LATC.1
#bit MCU_LATC2 = MCU_LATC.2
#bit MCU_LATC4 = MCU_LATC.4
#bit MCU_LATC5 = MCU_LATC.5
#bit MCU_LATC6 = MCU_LATC.6
#bit MCU_LATC7 = MCU_LATC.7
#byte MCU_LATB = 0xF8A
#bit MCU_LATB0 = MCU_LATB.0
#bit MCU_LATB1 = MCU_LATB.1
#bit MCU_LATB2 = MCU_LATB.2
#bit MCU_LATB4 = MCU_LATB.4
#bit MCU_LATB5 = MCU_LATB.5
#bit MCU_LATB6 = MCU_LATB.6
#bit MCU_LATB7 = MCU_LATB.7
#byte MCU_LATA = 0xF89
#bit MCU_LATA0 = MCU_LATA.0
#bit MCU_LATA1 = MCU_LATA.1
#bit MCU_LATA2 = MCU_LATA.2
#bit MCU_LATA3 = MCU_LATA.3
#bit MCU_LATA4 = MCU_LATA.4
#bit MCU_LATA5 = MCU_LATA.5
#bit MCU_LATA6 = MCU_LATA.6
#bit MCU_LATA7 = MCU_LATA.7
#byte MCU_PIR1 = 0xF9E
#bit MCU_SSP1IF = MCU_PIR1.3
#bit MCU_TX1IF = MCU_PIR1.4
#bit MCU_RC1IF = MCU_PIR1.5
#bit MCU_STIF = MCU_PIR1.7
#byte MCU_PIR1 = 0xF9E
#bit MCU_TMR1IF = MCU_PIR1.0
#bit MCU_TMR2IF = MCU_PIR1.1
#bit MCU_CCP1IF = MCU_PIR1.2
#bit MCU_SSPIF = MCU_PIR1.3
#bit MCU_TXIF = MCU_PIR1.4
#bit MCU_RCIF = MCU_PIR1.5
#bit MCU_ADIF = MCU_PIR1.6
#bit MCU_ACTIF = MCU_PIR1.7
#byte MCU_PIR2 = 0xFA1
#bit MCU_CCP2IF = MCU_PIR2.0
#bit MCU_TMR3IF = MCU_PIR2.1
#bit MCU_HLVDIF = MCU_PIR2.2
#bit MCU_BCLIF = MCU_PIR2.3
#bit MCU_EEIF = MCU_PIR2.4
#bit MCU_C2IF = MCU_PIR2.5
#bit MCU_C1IF = MCU_PIR2.6
#bit MCU_OSCFIF = MCU_PIR2.7
#byte MCU_PIE1 = 0xF9D
#bit MCU_TMR1IE = MCU_PIE1.0
#bit MCU_TMR2IE = MCU_PIE1.1
#bit MCU_CCP1IE = MCU_PIE1.2
#bit MCU_SSPIE = MCU_PIE1.3
#bit MCU_TXIE = MCU_PIE1.4
#bit MCU_RCIE = MCU_PIE1.5
#bit MCU_ADIE = MCU_PIE1.6
#bit MCU_ACTIE = MCU_PIE1.7
#byte MCU_PIE1 = 0xF9D
#bit MCU_SSP1IE = MCU_PIE1.3
#bit MCU_TX1IE = MCU_PIE1.4
#bit MCU_RC1IE = MCU_PIE1.5
#bit MCU_STIE = MCU_PIE1.7
#word MCU_ADRES = 0xFC4
#byte MCU_ADCON0 = 0xFC2
#bit MCU_DONE = MCU_ADCON0.1
#byte MCU_ADCON0 = 0xFC2
#bit MCU_ADON = MCU_ADCON0.0
#bit MCU_GO = MCU_ADCON0.1
#bit MCU_CHS0 = MCU_ADCON0.2
#bit MCU_CHS1 = MCU_ADCON0.3
#bit MCU_CHS2 = MCU_ADCON0.4
#bit MCU_CHS3 = MCU_ADCON0.5
#bit MCU_CHS4 = MCU_ADCON0.6
#byte MCU_ADCON0 = 0xFC2
#bit MCU_GO_DONE = MCU_ADCON0.1
#byte MCU_ADCON1 = 0xFC1
#bit MCU_NVCFG0 = MCU_ADCON1.0
#bit MCU_NVCFG1 = MCU_ADCON1.1
#bit MCU_PVCFG0 = MCU_ADCON1.2
#bit MCU_PVCFG1 = MCU_ADCON1.3
#bit MCU_TRIGSEL = MCU_ADCON1.7
#byte MCU_ADCON2 = 0xFC0
#bit MCU_ADCS0 = MCU_ADCON2.0
#bit MCU_ADCS1 = MCU_ADCON2.1
#bit MCU_ADCS2 = MCU_ADCON2.2
#bit MCU_ACQT0 = MCU_ADCON2.3
#bit MCU_ACQT1 = MCU_ADCON2.4
#bit MCU_ACQT2 = MCU_ADCON2.5
#bit MCU_ADFM = MCU_ADCON2.7
#word MCU_TMR1 = 0xFCF
#byte MCU_T1CON = 0xFCD
#bit MCU_TMR1ON = MCU_T1CON.0
#bit MCU_RD16 = MCU_T1CON.1
#bit MCU_T1SYNC = MCU_T1CON.2
#bit MCU_SOSCEN = MCU_T1CON.3
#bit MCU_T1CKPS0 = MCU_T1CON.4
#bit MCU_T1CKPS1 = MCU_T1CON.5
#bit MCU_TMR1CS0 = MCU_T1CON.6
#bit MCU_TMR1CS1 = MCU_T1CON.7
#byte MCU_INTCON = 0xFF2
#bit MCU_INT0F = MCU_INTCON.1
#bit MCU_T0IF = MCU_INTCON.2
#bit MCU_INT0E = MCU_INTCON.4
#bit MCU_T0IE = MCU_INTCON.5
#bit MCU_PEIE = MCU_INTCON.6
#bit MCU_GIE = MCU_INTCON.7
#byte MCU_RCREG1 = 0xFAE
#byte MCU_TXREG1 = 0xFAD
#byte MCU_TXSTA1 = 0xFAC
#bit MCU_TX9D = MCU_TXSTA1.0
#bit MCU_TRMT = MCU_TXSTA1.1
#bit MCU_BRGH = MCU_TXSTA1.2
#bit MCU_SENDB = MCU_TXSTA1.3
#bit MCU_SYNC = MCU_TXSTA1.4
#bit MCU_TXEN = MCU_TXSTA1.5
#bit MCU_TX9 = MCU_TXSTA1.6
#bit MCU_CSRC = MCU_TXSTA1.7
#byte MCU_OSCTUNE = 0xF9B
#bit MCU_TUN0 = MCU_OSCTUNE.0
#bit MCU_TUN1 = MCU_OSCTUNE.1
#bit MCU_TUN2 = MCU_OSCTUNE.2
#bit MCU_TUN3 = MCU_OSCTUNE.3
#bit MCU_TUN4 = MCU_OSCTUNE.4
#bit MCU_TUN5 = MCU_OSCTUNE.5
#bit MCU_TUN6 = MCU_OSCTUNE.6
#bit MCU_SPLLMULT = MCU_OSCTUNE.7
#byte MCU_TRISE = 0xF96
#byte MCU_TRISD = 0xF95
#byte MCU_TRISC = 0xF94
#byte MCU_TRISB = 0xF93
#byte MCU_TRISA = 0xF92
#byte MCU_SSP1MSK = 0xFCA
#byte MCU_SSP1BUF = 0xFC9
#byte MCU_SSP1ADD = 0xFC8
#byte MCU_SSP1STAT = 0xFC7
#bit MCU_BF = MCU_SSP1STAT.0
#bit MCU_UA = MCU_SSP1STAT.1
#bit MCU_R = MCU_SSP1STAT.2
#bit MCU_S = MCU_SSP1STAT.3
#bit MCU_P = MCU_SSP1STAT.4
#bit MCU_D = MCU_SSP1STAT.5
#bit MCU_CKE = MCU_SSP1STAT.6
#bit MCU_SMP = MCU_SSP1STAT.7
#byte MCU_SSP1CON1 = 0xFC6
#bit MCU_SSPM0 = MCU_SSP1CON1.0
#bit MCU_SSPM1 = MCU_SSP1CON1.1
#bit MCU_SSPM2 = MCU_SSP1CON1.2
#bit MCU_SSPM3 = MCU_SSP1CON1.3
#bit MCU_CKP = MCU_SSP1CON1.4
#bit MCU_SSPEN = MCU_SSP1CON1.5
#bit MCU_SSPOV = MCU_SSP1CON1.6
#bit MCU_WCOL = MCU_SSP1CON1.7
#byte MCU_SSP1CON2 = 0xFC5
#bit MCU_SEN = MCU_SSP1CON2.0
#bit MCU_RSEN = MCU_SSP1CON2.1
#bit MCU_PEN = MCU_SSP1CON2.2
#bit MCU_RCEN = MCU_SSP1CON2.3
#bit MCU_ACKEN = MCU_SSP1CON2.4
#bit MCU_ACKDT = MCU_SSP1CON2.5
#bit MCU_ACKSTAT = MCU_SSP1CON2.6
#bit MCU_GCEN = MCU_SSP1CON2.7
#byte MCU_INTCON2 = 0xFF1
#bit MCU_RBPU = MCU_INTCON2.7
#byte MCU_OSCCON = 0xFD3
#byte MCU_OSCCON2 = 0xFD2
#bit MCU_LFIOFS = MCU_OSCCON2.0
#bit MCU_HFIOFR = MCU_OSCCON2.1
#bit MCU_PRISD = MCU_OSCCON2.2
#bit MCU_SOSCGO = MCU_OSCCON2.3
#bit MCU_PLLEN = MCU_OSCCON2.4
#bit MCU_INTSRC = MCU_OSCCON2.5
#bit MCU_SOSCRUN = MCU_OSCCON2.6
#bit MCU_PLLRDY = MCU_OSCCON2.7
#byte MCU_ANSELB = 0xF5C
#byte MCU_ANSELA = 0xF5B
#byte MCU_IPR1 = 0xF9F
#bit MCU_TMR1IP = MCU_IPR1.0
#bit MCU_TMR2IP = MCU_IPR1.1
#bit MCU_CCP1IP = MCU_IPR1.2
#bit MCU_SSPIP = MCU_IPR1.3
#bit MCU_TXIP = MCU_IPR1.4
#bit MCU_RCIP = MCU_IPR1.5
#bit MCU_ADIP = MCU_IPR1.6
#bit MCU_ACTIP = MCU_IPR1.7
#byte MCU_EEADR = 0xFA9
#byte MCU_EEDATA = 0xFA8
#byte MCU_EECON2 = 0xFA7
#byte MCU_EECON1 = 0xFA6
#bit MCU_RD = MCU_EECON1.0
#bit MCU_WR = MCU_EECON1.1
#bit MCU_WREN = MCU_EECON1.2
#bit MCU_WRERR = MCU_EECON1.3
#bit MCU_FREE = MCU_EECON1.4
#bit MCU_CFGS = MCU_EECON1.6
#bit MCU_EEPGD = MCU_EECON1.7
#fuses INTRC_IO // Oscillator Selection (Internal oscillator)
#fuses PLL3X // PLL Selection (3x clock multiplier)
#fuses NOPLLEN // PLL Enable Configuration bit (PLL Enabled)
#fuses CPUDIV2 // CPU System Clock Postscaler (CPU uses system clock divided by 2)
#fuses LS24MHZ // Low Speed USB mode with 48 MHz system clock (System clock at 24 MHz, USB clock divider is set to 4)
#fuses PRIMARY // Primary Oscillator Shutdown (Primary oscillator enabled)
#fuses NOFCMEN // Fail-Safe Clock Monitor (Fail-Safe Clock Monitor disabled)
#fuses NOIESO // Internal/External Oscillator Switchover (Oscillator Switchover mode disabled)
#fuses NOPUT // Power-up Timer Enable (Power up timer disabled)
#fuses BROWNOUT
#fuses BORV19 // Brown-out Reset Voltage (BOR set to 2.8V nominal)
#fuses NOLPBOR // Low-Power Brown-out Reset (Low-Power Brown-out Reset disabled)
#fuses NOWDT // Watchdog Timer Enable bits (WDT disabled in hardware (SWDTEN ignored))
#fuses WDT32768 // Watchdog Timer Postscaler (1:32768)
#fuses CCP2C1 // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
#fuses NOPBADEN // PORTB A/D Enable bit (PORTB<5:0> pins are configured as digital I/O on Reset)
#fuses T3CKC0 // Timer3 Clock Input MUX bit (T3CKI function is on RC0)
#fuses SDOB3 // SDO Output MUX bit (SDO function is on RB3)
#fuses NOMCLR // Master Clear Reset Pin Enable (MCLR pin enabled; RE3 input disabled)
#fuses STVREN // Stack Full/Underflow Reset (Stack full/underflow will cause Reset)
#fuses NOLVP // Single-Supply ICSP Enable bit (Single-Supply ICSP disabled)
#fuses NODEBUG // Dedicated In-Circuit Debug/Programming Port Enable (ICPORT enabled)
#fuses NOXINST // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode enabled)
#fuses NOCPB // Boot Block Code Protect (Boot block is not code-protected)
#fuses NOCPD // Data EEPROM Code Protect (Data EEPROM is not code-protected)
#fuses NOWRTC // Configuration Registers Write Protect (Configuration registers (300000-3000FFh) are not write-protected)
#fuses NOWRTB // Boot Block Write Protect (Boot block (0000-7FFh) is not write-protected)
#fuses NOWRTD // Data EEPROM Write Protect (Data EEPROM is not write-protected)
#fuses NOEBTRB // Boot Block Table Read Protect (Boot block is not protected from table reads executed in other blocks)
typedef unsigned int16 uint;
typedef unsigned int8 uchar;
typedef unsigned int32 ulong;
uchar wtd,mstick,tenths;
void do_seconds(void);
void do_tenths(void);
void delay(uchar);
#INT_TIMER0
void TIMER0_isr(void)
{
MCU_TMR0 = 0xffff - 312; //for 10ms interrupts
MCU_T0IF =0;
if(--mstick == 0) //do this section 10 times per second
{
mstick = 10;
wtd |= 8;
if(--tenths == 0)
{
tenths = 10;
seconds++;
wtd |= 2;
}
}
}
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port B initialization
// Func7=In Func6=In Func5=Out Func4=In Func3=Out Func2=Out Func1=Out Func0=Out
// State7=P State6=P State5=0 State4=T State3=0 State2=0 State1=0 State0=0
MCU_WPUB=0xff; //internal pullups on push button
MCU_TRISB=0b11111111;
MCU_TRISC=0b00000000; //all outputs
MCU_TRISA=0b00000000; //all outputs
MCU_RBPU = 0; //enable weak pull ups
MCU_SPLLMULT =1;
MCU_RBPU=0; //enable weak pullups on 7 push buttons, goto pb needs a pullup resistor on the board
//Timer 0
MCU_OSCCON = 0x70;
MCU_TMR0 = 0xffff - 312; //for 10ms interrupts
MCU_T0CON = 0x07; // 16-bit mode, FOSC/1024
MCU_T0IE = 1;
MCU_PEIE =1; //enable the interrupt
MCU_TMR0ON = 1; //enable timer,
MCU_PLLEN = 1;
// Global enable interrupts
MCU_GIE = 1; //global interrupt enable
while (1)
{
if(wtd)
{
if( wtd & 0x02)
{
do_seconds();
wtd &= ~2;
}
if(wtd & 0x08)
{
do_tenths();
wtd &= ~8;
}
}
};
}
void delay(uchar milliseconds)
{
uchar i;
uint count, millisec;
millisec = (uchar)(milliseconds * 2); //let us actually do 1/2 millisecond at a time
for(i=0; i<millisec; i++)
{
count = 374; //to be determined for our clock freq.
while(--count);
count = 375;
while(--count);
}
}
void do_seconds(void)
{
}
void do_tenths(void)
{
} |
|
|
|
gfbankston
Joined: 21 Jul 2014 Posts: 35
|
running code |
Posted: Tue Jul 22, 2014 7:17 am |
|
|
The paste of the code worked...
Remember, this same code with syntax changes only, works on XC8.
Take care,
GlenB |
|
|
gfbankston
Joined: 21 Jul 2014 Posts: 35
|
more info |
Posted: Tue Jul 22, 2014 8:02 am |
|
|
Oh well, it is not the oscillator as I thought! clock out shows 6Mhz
The routine is hanging up in the delay() routine...seems to be counting but
never finishes. This does NOT happen in XC8 version.
I am wondering if interrupt routine is not saving registers or something, never allowing a decrement to zero??? I "assumed" all non-global variables are saved during interrupts.
GlenB |
|
|
gfbankston
Joined: 21 Jul 2014 Posts: 35
|
initial problem found!!! |
Posted: Tue Jul 22, 2014 8:25 am |
|
|
OK, I am not too smart. You would think after programming for 30 years I would know better.
In my delay routine, I had a unsigned char being compared to an unsigned int16 in the FOR loop in my delay routine. In XC8 it did not mind the comparison, but CCS hated it, and would never leave!
My fear is this could be just one of many screw ups...the code I really need to get working is 5000 lines :-(
GlenB
NOTE to CCS folks: can you catch this as an error in your compiler??? |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1354
|
|
Posted: Tue Jul 22, 2014 11:56 am |
|
|
A few things:
No need to make your own delay statement.
#use delay(clock=6MHz)
and then you can use delay_ms(x) and delay_us(x) as needed. The manual has some examples.
the #use delay() is going to be needed for other things like uart, etc.
You are doing a lot of stuff by hand that CCS can do for you. you should spend some time looking at the compiler manual. There are built in functions for setting up most all of the peripherals, etc. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jul 22, 2014 2:48 pm |
|
|
What's the point of translating the XC8 code verbatim to CCS ? What
does it gain you ? You still have a program full of register-level minutiae.
The whole point of using CCS is to write code at a higher level,
concentrating on the design of the program instead of the ASM level
details. There are CCS functions to do just about everything you're
doing in your program.
In truth, most experienced people on this board, especially the pro's
will take one look at your code and then do a face-palm. It's a great
example of why we program in CCS. |
|
|
gfbankston
Joined: 21 Jul 2014 Posts: 35
|
programming |
Posted: Tue Jul 22, 2014 5:25 pm |
|
|
I am glad there are folks who enjoy using the higher level routines.
I have programmed in assembly most of my life, and do my C the same way. Low level code, and never use a vendor's library. I am able to keep my code very tight, and I do not have to wonder 'what is this routine from the vendor actually doing?'
The reason for purchasing the compiler:
1. I had to purchase some compiler, because the XC8 free version makes code that is 50% larger.
2. They had 'drop in' USB code, and I had no desire to reinvent the wheel for USB.
I rewrote code for a vendor of thermal printers once. The same printer they were marketing, was more than twice as fast when I got done with it, and they never changed one piece of hardware. There is SOMETHING to be said for reusing the same code over and over for 20 years ;-)
GlenB |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Jul 22, 2014 6:08 pm |
|
|
Glen I've used CCS C on and off for almost 20 years and though I prefer assembler, I've found that most of the CCS functions are pretty 'tight'. Nothing is 'hidden', simply dump the listing and you can see how their code works.
Once you get 'your head into it', CCS C is easy enough to learn even for a near senior like myself!
Every compiler has it's 'plusses and minuses', though CCS seems to offer the best value for the money.Well that's my 2 cents worth!
cheers
Jay |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1354
|
|
Posted: Tue Jul 22, 2014 6:14 pm |
|
|
if you take a simple function like:
Code: |
void main(){
while(TRUE);
}
|
Then compile it and look at the assembly. What you will see at this point is that the compiler does a lot of stuff "for you" on its own. If you are going to manually set everything, then you need to get a better understanding of what the compiler sets up for you and how it does it. Not using some the high level functions means that "by default", the compiler will probably generate some code you don't want ... code that is designed to work in tandem with those high level functions. That's not to say you can't do stuff manually, but you need to make sure you understand what the compiler is going to do on its own.
Also note that the compiler expects certain things in a specific order. Namely:
<pic include>
<fuses>
<#use delay() statement>
then <your includes>, types, etc.
Doing things out of order can lead to odd problems. |
|
|
|