Trying to resolving 6 Compiler Errors


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322

    Default Trying to resolving 6 Compiler Errors

    Hi All,
    I am working with code written by another person and being new there are complier errors I am not sure how to resolve. I did post the questions under another title and there have been no answers so I thought maybe I would try here.

    Line 62 has: high presspwr there is no pin defined as presspwr which pin should be used?

    Line 195 has: d[17] = temp2.byte0 There is no array named d and I have never defined an array
    Line 196 has: d[18] = temp2.byte1 '

    Line 133 has: high pgc there is no pin defined as pgc which pin should be used?

    Line 220 has: gosub shutdownmemory there is no sub-routine with this name

    Line 221 has: gosub lowestpower there is no sub-routine with this name either end

    My guess is these 2 lines should be deleted and a new line added that says gosub resetintersema so the program will continue to run without stopping?

    Thanks to any and all who are willing to help and comment.

    Best, Ed

    Device is a 18F4610

    1. '***************** Defines *****************************
    2.
    3. DEFINE OSC 20 'Define crystal frequency
    4. DEFINE DEBUG_REG PORTB 'Debug output pin port
    5. DEFINE DEBUG_BIT 6 'Debug output pin bit
    6. DEFINE DEBUG_BAUD 19200 'Debug baud rate
    7. DEFINE DEBUG_MODE 0 'Debug mode: 0 = True, 1 = Inverted
    8.
    9.
    10. '**************** Intersema Variables ***********************
    11. C1 var word ' 5540 Pressure sensitivity
    12. C2 var word ' 5540 Pressure Offset
    13. C3 var word ' 5540 Temp Coef of pressure sensitivity
    14. C4 var word ' 5540 Temp Coef of Pressure Offset
    15. C5 var word ' 5540 Reference temperature
    16. C6 var word ' 5540 temp coef of Temp reading
    17. ' C1 to C6 are in EEROM as VAL.byte0, VAL.byte1 from 108 to 159
    18. D1 var word ' raw pressure word from Intersema sensor
    19. D2 var word ' raw temperature word
    20. D1Flag var bit
    21. W1 var word ' coefficient from 5540
    22. W2 var word ' coefficient from 5540
    23. W3 var word ' coefficient from 5540
    24. W4 var word ' coefficient from 5540
    25. ' W1 to W4 are NOT stored in EEROM - they are not needed again.
    26. dT var long ' intermediate calc value
    27. dT1 var long ' intermediate calc value
    28. dT2 var long
    29. UT1 var word ' Calibration temperature
    30. II var byte 'used ONLY within Intersema routines
    31. IJ var byte
    32. IK var byte
    33. IL var byte
    34. ILoop var word
    35. CalFlag var bit 'EEROM 99. Used to reduce wear on EEROM
    36.
    37. 'General purpose Intersema and DS1629 RTC/Temperature variables
    38. ClkChk var word '= 8192 if IntRC clock is exactly on frequency
    39. TimeFlag var bit
    40. TempRead var word
    41. CntRem var word
    42. CntPerC var word
    43.
    44. IW var long
    45. IX var long
    46. IY var long
    47. IZ var long
    48.
    49. T2 var long 'Second order Temperature correction
    50. P2 var long 'Second order Pressure correction
    51. Offset var long
    52. Senstvty var long
    53. Pressure var long '
    54. Celsius var long 'a LONG allows negative temperatures
    55.
    56. goto endofsubroutines ' jump subroutines at startup
    57. '******************* Subroutines ***********************
    58.
    59. ResetIntersema:
    60. ' need 32768 @ 50% for Intersema on CCP2.
    61. TRISB = %10000001 : TRISD.7 = 0 'DIn, DOut & SClk
    62. high presspwr : pause 100 : hpwm 2, 127, 32767 : pause 50
    63. shiftout din, sclk, 0, [85, 85, 0\5] ' Sense of Din is IN to 5541
    64. pauseus 100
    65. return
    66.
    67. FetchWord:
    68. shiftin dout, sclk, 2, [ij, ii, ik\1]
    69. 'IJ is hi byte, II is lo byte, IK is a dummy and discarded
    70. return
    71.
    72. CalSensor:
    73. read 99, calflag : if calflag = 1 then calsensordone
    74. debug 13, 10, "Fetch Intersema data", 13, 10
    75. ' This fetches and unpacks the factory calibration coefficients
    76. ' from W1 ~ W4. W values need not be stored.
    77. ' These bitmaps are unpacked into the 6 working coefficients
    78. ' C1 to C6 which must be stored in EEROM for later use.
    79. 'W1
    80. gosub resetintersema
    81. shiftout din, sclk, 0, [87, 1\5] ' Send W1 pattern to all sensors
    82. gosub fetchword ' get reply
    83. W1.byte0 = ii
    84. W1.byte1 = ij
    85.
    86. 'W2
    87. gosub resetintersema
    88. shiftout din, sclk, 0, [215, 0\5] ' Send W2 pattern
    89. gosub fetchword
    90. W2.byte0 = ii
    91. W2.byte1 = ij
    92.
    93. 'W3
    94. gosub resetintersema
    95. shiftout din, sclk, 0, [55, 1\5] ' Send W3 pattern
    96. gosub fetchword
    97. W3.byte0 = ii
    98. W3.byte1 = ij
    99.
    100. 'W4
    101. gosub resetintersema
    102. shiftout din, sclk, 0, [183, 0\5] ' Send W4 pattern
    103. gosub fetchword
    104. W4.byte0 = ii
    105. W4.byte1 = ij
    106.
    107. 'Unpack W1 ~ W4 into C1 ~ C6 coefficients
    108. 'C1
    109. C1 = W1 >> 3
    110. write 108, c1.byte0
    111. write 109, c1.byte1
    112. 'C2
    113. C2 = ((W1 & %0000000000000111) << 10) + (W2 >> 6)
    114. write 110, c2.byte0
    115. write 111, c2.byte1
    116. 'C3
    117. C3 = W3 >> 6
    118. write 112, c3.byte0
    119. write 113, c3.byte1
    120. 'C4
    121. C4 = W4 >> 7
    122. write 114, c4.byte0
    123. write 115, c4.byte1
    124. 'C5
    125. C5 = ((W2 & %0000000000111111) << 6) + (W3 & %0000000000111111)
    126. write 116, c5.byte0
    127. write 117, c5.byte1
    128. 'C6
    129. C6 = W4 & %0000000001111111
    130. write 118, c6.byte0
    131. write 119, c6.byte1
    132.
    133. ' high pgc : pause 1
    134. ' debug "Intersema Factory data ", $0D, $0A, "W1 = ,"_
    135. ' , #w1, ", W2 = ,", #w2, ", W3 = ,", #w3, ", W4 = ,", #w4, $0D, $0A
    136. ' debug "Derived coefficients", $0D, $0A, "C1 = ,", #C1, ", C2 = ,", #C2,_
    137. ' ", C3 = ,", #C3, ", C4 = ,", #c4, ", C5 = ,", #C5, ", C6 = ,", #C6.byte0,_
    138. ' $0D, $0A
    139.
    140. ' read 99, calflag : if calflag = 0 then write 99, 1
    141. CalSensorDone:
    142. return
    143.
    144. ReadIntersema: '
    145. ' D1 is Pressure - D2 is Temperature
    146. ' Uses LONG datatype to handle negative temperatures
    147. ' This routine reads the sensor and returns Pressure word
    148. ' and Celsius long
    149. ' A, II, IJ, W and X are all destroyed
    150.
    151. gosub resetintersema
    152. 'D1
    153. shiftout din, sclk, 0, [47, 0\5] ' Select D1 pattern
    154. While dout = 1 : wend 'Convert5541Delay:
    155. gosub fetchword
    156. ' This returns ii = lobyte, ij = hibyte from the sensor
    157. D1.byte0 = ii
    158. D1.byte1 = ij
    159. 'D2
    160. shiftout din, sclk, 0, [79, 0\5] ' Select D2 pattern
    161. While dout = 1 : wend
    162. gosub fetchword
    163. D2.byte0 = ii
    164. D2.byte1 = ij
    165.
    166. CalcTempPress: '32 bit signed arithmetic version. Handles negatives.
    167. read 108, c1.byte0
    168. read 109, c1.byte1
    169. read 110, c2.byte0
    170. read 111, c2.byte1
    171. read 112, c3.byte0
    172. read 113, c3.byte1
    173. read 114, c4.byte0
    174. read 115, c4.byte1
    175. read 116, c5.byte0
    176. read 117, c5.byte1
    177. read 118, c6.byte0
    178.
    179. 'formulae for DS5541 are NOT the same as for DS5540
    180. ut1 = 8*c5 + 10000
    181. dt = d2 - ut1
    182. Celsius = 200 + dt*(c6 + 100)/2048
    183. offset = c2 + ((c4 - 250)*dt)/4096 +10000
    184. senstvty = c1/2 + ((c3 + 200)*dt)/8192 + 3000
    185. pressure = (senstvty * (d1 - offset))/4096 + 1000
    186.
    187. 'NOT applying second order temperature correction in this
    188. 'version.
    189. 'Note 2nd order correction formula ambiguity in datasheet.
    190.
    191. if celsius < 0 then 'high bit of 32 bit number is set
    192. temp2 = 1000 - celsius
    193. else
    194. temp2 = 1000 + celsius
    195. d[17] = temp2.byte0
    196. d[18] = temp2.byte1
    197. endif
    198. if calflag = 0 then
    199. high pgc : pause 1
    200. debug "MS5541 Celsius = ", sdec Celsius/10, ".", dec1 celsius//10, _
    201. ", Pressure = ", dec pressure, " mBar, recorded as ",_
    202. dec temp2, 13, 10
    203. endif
    204. return
    205.
    206.
    207. EndOfSubRoutines:
    208. '*********************** Initialise *******************
    209.
    210. FetchDepth:
    211. gosub readintersema
    212. 'debug "T2 = ", dec temp2, 13, 10
    213. debug dec (temp2 - 1000)/10, ".", dec1 (temp2 - 1000)//10, _
    214. ", ", #pressure, " mBar", 13, 10
    215.
    216. 'this returns Pressure & Celsius, both words.
    217. hpwm 2, 0,0 'turn off Mclk
    218.
    219. ShutDown:
    220. gosub shutdownmemory
    221. gosub lowestpower
    222. end
    223.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Trying to resolving 6 Compiler Errors

    Hi,

    Your little problem is ... one or two pieces of code are missing

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322


    Did you find this post helpful? Yes | No

    Default Re: Trying to resolving 6 Compiler Errors

    Hi Alain,
    Of this I am certain and just need to know how to solve this as there is much I do not understand yet.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Trying to resolving 6 Compiler Errors

    Quote Originally Posted by Ramius View Post
    Hi All,
    I am working with code written by another person and being new there are complier errors I am not sure how to resolve. I did post the questions under another title and there have been no answers so I thought maybe I would try here.

    Line 62 has: high presspwr there is no pin defined as presspwr which pin should be used?

    Line 195 has: d[17] = temp2.byte0 There is no array named d and I have never defined an array
    Line 196 has: d[18] = temp2.byte1 '

    Line 133 has: high pgc there is no pin defined as pgc which pin should be used?

    Line 220 has: gosub shutdownmemory there is no sub-routine with this name

    Line 221 has: gosub lowestpower there is no sub-routine with this name either end

    My guess is these 2 lines should be deleted and a new line added that says gosub resetintersema so the program will continue to run without stopping?

    Thanks to any and all who are willing to help and comment.

    Best, Ed

    223.
    Hi Ed,
    as Alain stated, you are missing some code.
    pick you pins for the pin errors
    you NEED to Make the array, since you ARE using it
    You need to make the missing sub routines and have them do what they need to do.
    EDIT:
    I retract the above, you need to copy code that works,
    I think if you get this to compile you will see stack overflows due to failure of the original code to return from subroutines, the subs flow into one another and subs calling subs without returns
    Last edited by Archangel; - 9th April 2011 at 20:02.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322


    Did you find this post helpful? Yes | No

    Default Re: Trying to resolving 6 Compiler Errors

    Thanks Joe and you are right I just did not know what to choose. For some reason my cut and paste did not include this part:

    Include "Modedefs.bas"

    '********************* Declaired Pins **************************
    Clk var PortD.2
    Dout VAR PortD.3
    Din var PortD.0
    Sclk var PortC.3
    Mclk var PortC.1

    I do not believe the other subroutines are necessary as the hope is to have this run continuously. I have never done an array so I have no idea exactly how this is written. I will certainly look at the subs and returns and just trying to take this one step at a time.

    Best, Ed

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Trying to resolving 6 Compiler Errors

    Here is a thread I started for array newbies, especially read the posts which ARE NOT mine.
    http://www.picbasic.co.uk/forum/showthread.php?t=8876

    The example in this thread was written prior to PBP ver2.6 and as such the word Loop must be changed to something like MainLoop
    or MyLoop as Loop is now a reserved word associated to DO.
    Last edited by Archangel; - 10th April 2011 at 03:19.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Trying to resolving 6 Compiler Errors

    Hi,

    The funniest thing in this thread ...

    is to try to use READ and WRITE whith a pic that has NO EEPROM ...



    From what I've found to get " success 4304 bytes used " AND perfectly knowing it even can't run in real life ...

    I gently suggest you to check your project from A to Z before coming back here ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Trying to resolving 6 Compiler Errors

    Quote Originally Posted by Acetronics View Post
    Hi,

    The funniest thing in this thread ...

    is to try to use READ and WRITE with a pic that has NO EEPROM ...


    Alain
    Details, Details, Details . . . Joe says with a sheepish grin . . . I wasn't paying such close attention . . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts