B4R Question Guru Mediation Error: Core 0 panic'ed (Load access fault). Exception ws unhandled

daveinhull

Active Member
Licensed User
Longtime User
Hi,

Now that I've got the ESP32 GC9A01A code working in the Arduino, I'm trying to move it into B4R, so trying to keep it as same as possible, espeially the sematics/strucutre before looking to alter it.

I'm getting the above error when calling a routine [edit: should have mentioned that it gets about half way through processing the initial command and repeatedly fails at the same point, but can't see anything unusual at that point]
B4X:
SendCommand(Cmd,Convertor.subString(InitCmd,CmdPointer),Bit.And(InitCmd (CmdPointer),0x7f))

The routine defintion is:
B4X:
Private Sub SendCommand (CommandByte As Byte, DataBytes() As Byte, NumberDataBytes As Byte)

The InitCmd array is (completely as is in the C code version):
B4X:
    InitCmd = Array As Byte (GC9A01A_INREGEN2, 0, _
    0xEB, 1, 0x14, _
    GC9A01A_INREGEN1, 0, _
    GC9A01A_INREGEN2, 0, _
    0xEB, 1, 0x14, _
    0x84, 1, 0x40, _
    0x85, 1, 0xFF, _
    0x86, 1, 0xFF, _
    0x87, 1, 0xFF, _
    0x88, 1, 0x0A, _
    0x89, 1, 0x21, _
    0x8A, 1, 0x00, _
    0x8B, 1, 0x80, _
    0x8C, 1, 0x01, _
    0x8D, 1, 0x01, _
    0x8E, 1, 0xFF, _
    0x8F, 1, 0xFF, _
    0xB6, 2, 0x00, 0x00, _
    GC9A01A_MADCTL, 1, MADCTL_MXorBGR, _
    GC9A01A_PIXFMT, 1, 0x05, _
    0x90, 4, 0x08, 0x08, 0x08, 0x08, _
    0xBD, 1, 0x06, _
    0xBC, 1, 0x00, _
    0xFF, 3, 0x60, 0x01, 0x04, _
    GC9A01A1_VREG1A, 1, 0x13, _
    GC9A01A1_VREG1B, 1, 0x13, _
    GC9A01A1_VREG2A, 1, 0x22, _
    0xBE, 1, 0x11, _
    ILI9341_GMCTRN1, 2, 0x10, 0x0E, _
    0xDF, 3, 0x21, 0x0c, 0x02, _
    GC9A01A_GAMMA1, 6, 0x45, 0x09, 0x08, 0x08, 0x26, 0x2A, _
    GC9A01A_GAMMA2, 6, 0x43, 0x70, 0x72, 0x36, 0x37, 0x6F, _
    GC9A01A_GAMMA3, 6, 0x45, 0x09, 0x08, 0x08, 0x26, 0x2A, _
    GC9A01A_GAMMA4, 6, 0x43, 0x70, 0x72, 0x36, 0x37, 0x6F, _
    0xED, 2, 0x1B, 0x0B, _
    0xAE, 1, 0x77, _
    0xCD, 1, 0x63, _
    0x70, 9, 0x07, 0x07, 0x04, 0x0E, 0x0F, 0x09, 0x07, 0x08, 0x03, _
    ILI9341_FRAMERATE, 1, 0x34, _
    0x62, 12, 0x18, 0x0D, 0x71, 0xED, 0x70, 0x70, 0x18, 0x0F, 0x71, 0xEF, 0x70, 0x70, _
    0x63, 12, 0x18, 0x11, 0x71, 0xF1, 0x70, 0x70, 0x18, 0x13, 0x71, 0xF3, 0x70, 0x70, _
    0x64, 7, 0x28, 0x29, 0xF1, 0x01, 0xF1, 0x00, 0x07, _
    0x66, 10, 0x3C, 0x00, 0xCD, 0x67, 0x45, 0x45, 0x10, 0x00, 0x00, 0x00, _
    0x67, 10, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x01, 0x54, 0x10, 0x32, 0x98, _
    0x74, 7, 0x10, 0x85, 0x80, 0x00, 0x00, 0x4E, 0x00, _
    0x98, 2, 0x3e, 0x07, _
    GC9A01A_TEON, 0, _
    GC9A01A_INVON, 0, _
    GC9A01A_SLPOUT, 0x80, _
    GC9A01A_DISPON, 0x80, _
    0x00) ' End of list

Anyone any thoughts please - is it a problem with the ESP?
Thanks
Dave
 
Last edited:

daveinhull

Active Member
Licensed User
Longtime User
Some info, according to the ESP32-C3 website covering fatal errors, this error is described as:
My registers were:
MSTATUS : 0x00001881 MTVEC : 0x40380001 MCAUSE : 0x00000005 MTVAL : 0x0000001d
so it looks like it relates to
....If this address is close to zero, it usually means that application attempted to access member of a structure.....
But looking at the vaues and pointers just before it crashes, there are:
Command = 90; Pointer = 59; No = 4

Not sure I'm good enough to work this one out, any ideas anyone?
Thanks
 
Upvote 0

daveinhull

Active Member
Licensed User
Longtime User
Just some further info, the routine loos like this:
B4X:
Private Sub SendCommand (CommandByte As Byte, DataBytes() As Byte, NumberDataBytes As Byte)
    Log ("In send command")
    CSpin.DigitalWrite(False)
    DCpin.DigitalWrite(False)
    Log("Pins set low")
    HSPI.transfer(Array As Byte(CommandByte),1)
    Log ("Transfered command")
    If NumberDataBytes <> 0 Then
        DCpin.DigitalWrite(True)
        HSPI.transfer(DataBytes,NumberDataBytes)
        Log ("Transfered Data")
    End If
    CSpin.DigitalWrite(True)
    Log ("Pins Low")
End Sub
I get the part of the log message "In send comm" and then it crashes
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…