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

PIC24HJXXXGPX06 Error Assignment invalid:value is read only

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



Joined: 11 Feb 2020
Posts: 3

View user's profile Send private message

PIC24HJXXXGPX06 Error Assignment invalid:value is read only
PostPosted: Tue Feb 11, 2020 9:06 am     Reply with quote

Hello,
I am resuming an project people worked on a few years ago and I'm having some difficulties. I won't add the whole code in here as it is 1000+ lines but I'll try to add what is necessary.
In case this could be useful, I am trying to make a joulemeter.

One of the errors I'm getting when compiling is an "assignment value is READ ONLY".

Code:
         voltageString = atof(voltage);
         currentString = atof(current);


From what I've seen it could be because it was defined as a constant but I looked and it doesn't seems to be the case :

Code:
char currentString[5];


I am also getting an error from this line saying previous identifier (I'm assuming Position_mesure) must be a pointer

Code:
Instantaneaous_Voltage[Position_Mesure] = Electric_Drop(Vs, Default_Resistance*Relative_Resistance,Instantaneous_Current[Position_Mesure])*Relative_Resistance;


Position_Mesure being an int -
For those wondering, it ajusts the resistance as the temperature changes.

I'm having a few more errors but I won't bother you with all of them.

Last thing that is hurting my head and I'm bothering you with, is when setting up timers. It is 32768 (2^15) Hz and I would want to set an interrupt every hundredth of second and that would mean interrupting every 327.68 clock signals, which isn't a round number.


Thanks for your time, if you need more info just tell me.
I am quite new on microcontrollers and this forum.
Wosiru



Joined: 11 Feb 2020
Posts: 3

View user's profile Send private message

PostPosted: Tue Feb 11, 2020 9:16 am     Reply with quote

For the second error I found this : https://www.ccsinfo.com/forum/viewtopic.php?t=40395
But there is no mention of #case or #nocase in the code
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Feb 11, 2020 10:12 am     Reply with quote

re: But there is no mention of #case or #nocase in the code

the CCS C default is #NOCASE

You should tell us which PIC and clock speed, so we could help 'setup' the timer for you...
Wosiru



Joined: 11 Feb 2020
Posts: 3

View user's profile Send private message

PostPosted: Tue Feb 11, 2020 10:29 am     Reply with quote

Thank you for your reply.

I've tried to add #case in my code in the definition of constants, unfortunately it didn't fixed the bug and added 7 new errors.

The pic is the PIC24HJ128GP206 which has a frequency of 32.768 kHz.
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Tue Feb 11, 2020 11:25 am     Reply with quote

Er.
I think you are using the wrong function.....

atof, expects to be passed a string, and return a floating point number.

You are trying to put the resulting fp value into a string!....

The reason for the actual error is that you are trying to write the
value 'into' the actual fixed pointer that is the address of the strings.

If you want to put the voltage into a string, then use sprintf.

sprintf(voltageString,"%d", voltage);

On your timer, consider another approach. Just have the RTCC tick
merrily 1/second. Just program another timer to give your approx
100Hz interrupt.

Also beware of your string length. If the number gets larger than
9999, you run out of space in the strings....
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