Archive for category PIC News
MPLAB X and 18F26K22
The MPLABC18 compiler that is available for download for Linux under MPLAB X is based on 3.36 … I need 3.37 which includes more complete support for the PIC 18F26K22 … the 3.36 has a define for it inside the p18cxxx.h but NO define for it in the pconfig.h .. when I copied the “h” and “lib” folder from a working 3.37 install on my legacy MPLAB 8 (under Windows) .. the compiler actually finds the prototype for things like putrs1USART (first serial port on the 26K22).
**BUT** all is not swell! It gets further, but no cigar!
Just need to get onto the forums for the MPLAB X folks and mention.. AHEM … 18F26K22 ?!? 3.37 (or newer) please?!
–Doug
OSCTUNE
I was wondering why my code was 4% faster on the new MCU (4% is within the tolerances for LTTO/LTX, but not within what I was expecting).. come to fine out… 5 bits was the old tuning resolution on the 18F2685 and they increased that to 6 bits on the 26K22.. and I was forcing the MSB to zero when it should have been one causing it to be wrong (and significantly, hence the MSB being wrong).
Mind you all modern PICs are internally calibrated to within 1% tolerances (internal clock) at the factory before shipping to customer and have some temperature compensation as well built in. This calibration is not able to be re-done, except for fine tuning via OSCTUNE. I’ve made the following changes as well during the port:
tune&=31; // mask off upper bits OSCTUNE = tune;
to:
tune&=63; // mask off upper bits OSCTUNE = tune;
I store minor calibrations in EE and read into memory and set the fine tuner (something I do when programming). Usually only -1 or -2 as these devices (2685 and now 26K22) like to run about 1/2% faster than they should… (mind you an error of 4% and you’ll STILL have taggers joining and debriefing fine — just me being picky).
–Doug
Lazer Tag HQ CPU port done
Posted by admin in Lazer Tag HQ, PIC News on March 6, 2011
with a lazy two hours involved in porting between the two MCU (including download and installing the latest MPLAB IDE and C compiler) … and about 10 lines of code changed.
Analog disable is a little different on the K22 series, instead of:
// no analog ADCON1=255; // all analog input disabled // Vref internal only ADCON1bits.VCFG0=0; ADCON1bits.VCFG1=0;
changed to:
// no analog ANSELA=0; ANSELB=0; ANSELC=0; ADCON1=0; ADCON0bits.ADON=0;
and then every place where I has xxxxUSART (like OpenUSART) I simple changed to xxxx1USART !!
Also the clock required slight changing, from:
OSCCONbits.IRCF0=1;
to:
OSCCONbits.IRCF0=0; // this was 1 on 8Mhz device.. now 0 on 16Mhz device
18F2685 -> 18F26K22
Conversion of the code went fast (less than an hour total) but hasn’t been tested (at all).
Core differences between the two models
- 2685 has more memory 96KB / 26K22 has 64KB (but using about 7.5KB)
- 2685 has CAN (high speed network often found in newer cars) 26K22 doesn’t — development MCUs tend to have more extras than final production MCUs
- 2685 has one UART and one MSSP / 26K22 has two UARTS (serial ports) and two MSSP (for SPI or I2C) — a bonus but not used in THIS project (future ones will use two SPI devices)
- 2685 MAX clock is 40MHZ / 26K22 MAX clock is 64MHZ — don’t need the speed, actually turn down the clock to match same speed in dev MCU
- 2685 has ADC functions / 26K22 has more ADC functions (including DAC output) — not usable any ADC/DAC
- 2685 is a bit more costly / 26K22 is about 1/2 the cost per unit
Had to update the MPLAB IDE and C compiler and also discovered a new development platform from Microchip called MPLAB X which is written entirely in Java and Microchip will support this NEW development IDE on OSX and Linux (as well as Windows).
Talk about putting a smile on my face — supposedly converting projects is fairly easy from an MPLAB IDE 8.x project (which is the major version I am using)… Needless to say, I hope I can kiss my Windows(tm) VM goodbye soon! Not that I don’t like the IDE, it’s pretty good and step debugging is nice. I hope all that plus MORE is available under MPLAB X.
I am hoping it is more like Eclipse (which has seriously awesome context awareness when writing code, I like Eclipse — which is what I wrote my Linux GUI code in).
PCBs ordered… MCU code porting underway
Posted by admin in Lazer Tag HQ, PIC News on March 4, 2011
If I am to get the first round done within the next few months, I need boards made. I need to port the code from one MCU to a newer (lower cost) one now, it should take one day as the newer CPU isn’t that much different that my reference MCU.