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.

Let's learn MPLAB X

Status
Not open for further replies.
Yes, the free version of the C compilers aren't just 'poorly optimised', they also deliberately insert lot's of extra spurious code to make them look bad.

I tried my IR tutorial, which Ian had converted to C - and it didn't work at all. I looked into why, and the loops take too long to read the IR pulses.

Have a read of:
Thats pretty bad, in the C handbook it states that XC 8 dosnt use any of the extended code set, I wonder if thats just the free (lite) version. Bit of a dirty trick though, dosnt bode well for Atmel does it.
 
I've just checked a disassembly of xc8 and there is no padding that I can see. Maybe Microchip removed it as the code looks pretty efficient to me.

Mike.
Example,
Code:
!            buffer[buflen-1]=GetRXFifo();
0x186: CALL 0x1DF
0x187: MOVLB 0x0
0x188: MOVWF 0x5C
0x189: MOVF 0x5C, W
0x18A: MOVWF 0x2D
!            if(buffer[buflen-1]=='E'){
0x18B: MOVLW 0x45
0x18C: XORWF 0x2D, W
0x18D: BTFSS STATUS, 0x2
0x18E: GOTO 0x192
!                //we have colour info
!                parse();
0x18F: CALL 0x36
//I'm particularly impressed with the next 3 lines. Very efficient.
!                buffer[buflen-1]=0;
0x190: MOVLB 0x0
0x191: CLRF 0x2D
!            }
!        }
!        if(CCP1IF!=0){
0x192: MOVLB 0x0
0x193: BTFSS PIR4, 0x0
0x194: GOTO 0x167
!            CCP1IF=0;
0x195: BCF PIR4, 0x0
!            Count++;
0x196: MOVLW 0x1
0x197: ADDWF Count, F
0x198: MOVLW 0x0
0x199: ADDWFC 0x2F, F
!            if(Count==500){
0x19A: MOVLW 0xF4
0x19B: XORWF Count, W
0x19C: BTFSS STATUS, 0x2
0x19D: GOTO 0x167
0x19E: DECF 0x2F, W
0x19F: BTFSS STATUS, 0x2
0x1A0: GOTO 0x167
!                Count=0;
0x1A1: CLRF Count
0x1A2: CLRF 0x2F
0x1A3: GOTO 0x167
 
Are you on the 60 day trial version though? (well that code example). The article nigel linked to does say, the guy think MC will remove the padding at some point. I didnt look when it was written though, the conclusion was MC was holding off as a favour to companies that had supplied compilers when they didnt have any. I find it hard to believe MC would give a rats about anyone else's business though, but I might just be cynical seeing as I hang out with you lot :D.
 
I tried my IR tutorial, which Ian had converted to C - and it didn't work at all. I looked into why, and the loops take too long to read the IR pulses.
Thanks for testing.... I'll re-write to use the CCP module.... Then it will work... I'm sure I compiled it in "free" mode... Perhaps not!!
 
Looks like I may have spoke too soon. It looks like some padding has been removed but I just tried the example linked above with the following result. :mad:
Code:
!    maxDev=CCPR1L>>4;
0x167: MOVLB 0x5
0x168: MOVF CCPR1, W
0x169: MOVLB 0x0
0x16A: MOVWF 0x5D
0x16B: MOVLW 0x4
0x16C: LSRF 0x5D, F
0x16D: DECFSZ WREG, F
0x16E: GOTO 0x16C
0x16F: MOVF 0x5D, W
0x170: MOVWF 0x5E         // superfluous code
0x171: MOVF 0x5E, W
0x172: MOVWF maxDev

Mike.
 
Perhaps MC are just giving you more bang for ya buck.............:sorry::stop:
 
Actually scrub that, the price with the compiler and debugger isnt that bad, way cheaper than MC.....
 
What a lot of people don't know is that you can install and use the compiler in free mode and once your project is complete you can reinstall (just xc8) and activate the 60 day free trial.

Mike.
 
What a lot of people don't know is that you can install and use the compiler in free mode and once your project is complete you can reinstall (just xc8) and activate the 60 day free trial.

Mike.
:cool:
 
This really doesn't look that bad figure I post it here too $29 when you need the full xc8
Part Number: SW006021-SUB - MPLAB XC8 PRO Compiler Subscription License

The MPLAB® XC8 PRO Compiler (Subscription License) enables PRO-level features and optimizations on a Monthly basis for the MPLAB XC8 Compiler. These features and optimizations include highly-optimized ANSI C for all of Microchip’s 8-bit microcontroller families. This license also allows unlimited compiler updates without the need for HPA (High Priority Access).
The compiler itself integrates into MPLAB X IDE, Microchip’s feature-rich integrated development environment, and is compatible with all Microchip debuggers, programmers and emulators. As with all of Microchip’s design tools, the MPLAB XC8 Compiler works with Windows, Linux and Mac operating systems.
 
Hi Burt...

That is a monthly subscription... When I tried to buy it, it wouldn't allow me to.. It was £24.00, but I had to pay at least 12 of them...
LOL I have seen shared server hosting packages like that. ONLY £12 a month (but you pay 24 months upfront).
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top