View previous topic :: View next topic |
Author |
Message |
Wosiru
Joined: 11 Feb 2020 Posts: 3
|
PIC24HJXXXGPX06 Error Assignment invalid:value is read only |
Posted: Tue Feb 11, 2020 9:06 am |
|
|
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
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Tue Feb 11, 2020 10:12 am |
|
|
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
|
|
Posted: Tue Feb 11, 2020 10:29 am |
|
|
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: 19504
|
|
Posted: Tue Feb 11, 2020 11:25 am |
|
|
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.... |
|
|
|