Cannot get Multi_RAM_Byte_Array to work with 18F27Kk42

Started by JohnB, Jul 31, 2022, 10:31 AM

Previous topic - Next topic

JohnB

I am trying to set up a log file in RAM using Les's Multi Byte Array to hold the data.
Below is the code for my DataLog.
 
From my Main Program I a call InitLogFile in my initialisation section and in the main loop I call AddLogEntry when changes occur.

Goto _OverDataLog

Dim NextEntry As byte

 Sub InitLogFile:
  Create_MByteArray(LogArray, 64, 8)
  ClearLog()
 EndSub


 proc AddLogEntry()
 'Hours, Mins, PumpRelay, Heatdemand, PoolTemperature, TargetPoolTemp
    Write_MultiByteArray LogArray, [NextEntry,0], RTC_Hour
    Write_MultiByteArray LogArray, [NextEntry,1], RTC_Minute
    Write_MultiByteArray LogArray, [NextEntry,2], PumpRelay
    Write_MultiByteArray LogArray, [NextEntry,3], HeatDemand)
    Write_MultiByteArray LogArray, [NextEntry,4], PoolTemperature.HighByte)
    Write_MultiByteArray LogArray, [NextEntry,5], PoolTemperature.LowByte)
    Write_MultiByteArray LogArray, [NextEntry,6], TargetPoolTemp.Highbyte)
    Write_MultiByteArray LogArray, [NextEntry,7], TargetPoolTemp.LowByte)
'Debug Code
    HRSOut "Hour ", Dec RTC_Hour, " Minute " , Dec RTC_MINUTe , $D
    HRSOut Dec GetItem(NextEntry,0), ":",Dec GetItem(NextEntry,1), $D
    HRSOUt Dec GetItem(NextEntry,2), $D
    HRsout Dec GetItem(NextEntry,3), $D
    HRSOUt Dec GetItem(NextEntry,4), $D
    HRSOut Dec GetItem(NextEntry,5), $D
    HRSout Dec GetItem(NextEntry,6), $D
    HRSOUt Dec GetItem(NextEntry,7), $D
'End Debug Code
    Inc NextEntry
    NextEntry = NextEntry & $3F
 EndProc

 Proc GetItem(pRow As byte, pCol As Byte), byte
   Result = Read_MultibyteArray LogArray, [pRow, pCol]
 EndProc

 proc Clearlog()
   dim IndexX As TmpB1
   Dim IndexY AS TmpB2

   NextEntry=0
   for IndexY = 0 to 63  'MyArray#SizeY-1
     for IndexX = 0 to 7 'MyArray#SizeX -1
        Write_MultiByteArray LogArray, [IndexY,IndexX], 0
     Next
   Next
 EndProc

 _OverDataLog:

The results I am getting are not what I am expecting
This is what emerges from adding an entry in the log file

Hour 11 Minute 9   (Correct actual time - All the other parameters are real values too)
14:14
14
14
14
14
14
14

All cells in the array are holding the value 14.

Can anyone put forward some suggestions as to why its not loading the array.
 
JohnB

tumbleweed

One thing that'll cause problems with the K42 is the use of the 'MOVFF' asm instruction in the "Multi_RAM_Byte_Array.inc" file

Since the SFR registers are at the top of memory outside the reach of MOVFF you have to use MOVFFL on the K42 (and K83).

The attached version should detect if the uC supports movffl and use it instead (remove .txt).
I didn't really test it to see if there are other issues...

JohnB

Thankyou tumbleweed, that fixed it completely.
I guessed it might be something like that which is why I specifically mentioned the device
some of these samples and libraries need updating and organised into a more easily accessible form.
JohnB