Something to share.

Status
Not open for further replies.

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
Just in case someone else falls foul of this..

I have just spent three evenings battling with XC8 v2.05... C99.. I have a pic18f87k22 and couldn't get simulation going let alone for real..
Stupid mistake... XINST was on by default.. WHY!!!! XC8 does not support extended instruction set.. Surely the mad hatters at Microchip could mask that piggin bit out if they don't support it.. I know its there for assembly and asm can be used with XC8, but any C code will not work...

Make my blood boil... I thought it was a C99 thing, but you can change the standard... Didn't help..

Rant over!!
 
Thanks, nice to know, i sometime work on 16f stuff, not still on 18f

Looking the xc8 guide seems 18f code samples do

#pragma config XINST = OFF

Btw, catching this as mandatory seems quite hard. Masking it OFF by c compiler seems a good idea
 
Remember to avoid the all time top blunders:
1) Never get involved with a land war in Asia.
2) Never go up against a Sicilian with death on the line.
3) Never forget to define all the bits in all the configuration words.
 
Whoops.... Another hiccup... This time it was me... But shows compiling isn't always straight forward.
Look at the variable definition...
C:
void interrupt isr(void)
 {
 int x ,t,s,dir1;
 char str[4];
 if(OERR1)
  {
   …………………..
Now later in the function I had this...
C:
  for(x=0;x<5;x++)
   {str[x] = 0; press.Rx[x] = 0;  height.Rx[x] = 0;}
My mistake is the size of str[], should have been 5… But the char array is placed first by the compiler so the overrun over writes x every loop, thus never completing the loop.... I was convinced it was a serial issue as the interrupt was only firing once...

Thing is... This code has been used "as is" extensively without issue, so the newer V2.05 compiles differently to the older versions...

Pitfalls.....
 
We all fall foul of the "count from zero" tripup every now and then.

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…