CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Can not change device this far into code

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bolpac



Joined: 29 Aug 2012
Posts: 2

View user's profile Send private message

Can not change device this far into code
PostPosted: Wed Aug 29, 2012 6:46 am     Reply with quote

I am using PCW for a PIC24FJ128GA106 project. Everything was working fine and then yesteday I suddenly started getting the error message in the subject line. I have tried commenting out all changes and even starting a brand no project with no application code, no includes, and I still get this message. The error always points to the #device PIC24FJ128GA106 line at the top of the device .h file, but there are no other #device statements anywhere in the old or new projects.

Main.c


Code:
#include <ST Rev4.h>
  #include <math.h>
  #include <stdio.h>
  #include <stddef.h>
  #include <stdlib.h>
  #include <string.h>
 
#int_RDA
void  RDA_isr(void)
{

}



#use rs232(UART1,baud=9600,parity=N,bits=8,stream=wifi)


void main()
{
   setup_spi( FALSE );
   setup_spi2( FALSE );

   setup_adc_ports(sAN3);
   setup_adc(ADC_CLOCK_DIV_8 | ADC_TAD_MUL_8);



   setup_timer1(TMR_EXTERNAL|TMR_DIV_BY_64);


   enable_interrupts(INT_RDA);

   // TODO: USER CODE!!

}

main.h
Code:

#include <24FJ128GA106.h>
#device ICD=TRUE

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOWINDIS                 //Watch Dog Timer in Window mode
#FUSES DEBUG                    //Debug mode for use with ICD
#FUSES NOJTAG                   //JTAG disabled
#FUSES XT                       //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES NOCKSFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES PR_PLL                   //Primary Oscillator with PLL

#use delay(clock=8000000)
#use fixed_IO(E_outputs = PIN_E0,PIN_E0,PIN_E1,PIN_E1,PIN_E2,PIN_E2)


The device header file is the std file included with the compiler.
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Wed Aug 29, 2012 8:37 am     Reply with quote

What you have posted does not correspond to what you are trying to run (there is no 'main'h' being loaded in main.c...)..

However layout rules are being broken:
Layout should be:

1) Processor include
2) Fuses
3) delay
4) RS232

These can either be in the main program, or in an include.

Only then:
5) Other includes
6) code....

If your 'main.h', is the file being loaded as ST_Rev4.h, then it should work, with just the one error (#use RS232, must be before RS232 is used - before stdio.h, and your interrupt definition).

Also as it stands, if it did compile, it'd potentially hang (though wouldn't because INT_RDA will never be called - INT_GLOBAL.....). INT_RDA, _must_ read the waiting character. Then it'll fall off the end before actually doing anything.

Best Wishes
bolpac



Joined: 29 Aug 2012
Posts: 2

View user's profile Send private message

PostPosted: Wed Aug 29, 2012 11:02 am     Reply with quote

First, thank you for the reply. Second you correctly point out that I mislabeled the code sections; should have been ST Rev4.c and ST Rev4.h respectively, rather than main.c and main.h.

Lastly, your comment regarding layout got me to thinking that one of my include files might have gotten corrupted. So i commented out all of the include lines in ST Rev4.c and everything compiled fine. I started putting them back in one by one and wouldn't you know it, it croaked as soon as I put string.h back in. Upon opening that up I found that somehow I had managed to insert #include <ST Rev4.h> in there, which was ultimately including the device file again ... after I had set fuses, etc. ... and that's when it was returning the error.

Thanks for your help. -BR, Bolpac
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Sat Sep 01, 2012 1:35 am     Reply with quote

This is why I always 'encapsulate' a project.
Put your source files, the compiler you are using, and it's includes in it's own 'project' directory. Then you can come back in five years time, and no other project will have affected a file used by this one, and you'll have available the compiler used as well.. Given how small this all is (in modern storage standards), it avoids this sort of problem of 'cross contamination' between projects....

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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