Trying to use the PID controller
Posted: Fri Dec 27, 2019 7:13 am
I want to use the PID controller/MMU in a project and I'm at my wits end trying to understand the damn thing. I realize that the PID system isn't officially supported [?] but if someone smarter than me wants to debug my train of thought I would much appreciate.
To my understanding, the MMU maps processes 0 and 1 identically, so I figured I'd try switching from process 0 to 1. I wrote some assembly that sets up the PID registers (section 27.3.3) and called it from a C function:
The chip seems to do something when I switch processes - if I try switching to process 0 it continues running fine - but when I switch to process 1 it throws up illegal instruction exceptions which eventually devolve into gibberish, and the chip hangs. Occasionally it gets restarted by the watchdog.
I don't know where to go from here honestly. I've tried playing with the delay values, the PID I'm switching to (this results in a hang without any exceptions), where I call the process switching code from, setting the levels register, etc. Nothing works. What am I missing?
To my understanding, the MMU maps processes 0 and 1 identically, so I figured I'd try switching from process 0 to 1. I wrote some assembly that sets up the PID registers (section 27.3.3) and called it from a C function:
Code: Select all
// Step 1 - set NMI_MASK_ENABLE_REG to 1
movi a6, 0x3FF1F000
movi a7, 0x1
s32i a7, a6, 0x54
// Step 2 - set PID_DELAY_REG et al to some values
movi a7, 0x44
s32i a7, a6, 0x20
movi a7, 0x55
s32i a7, a6, 0x24
// Step 3 - Set PID_NEW_REG
movi a7, 0x1
s32i a7, a6, 0x48
// Step 4 - Set LEVEL_REG - not sure how or why
//movi a7, 0xF
//s32i a7, a6, 0x28
// Step 5 - Set PID_CONFIRM_REG and NMI_MASK_DISABLE to 1
movi a7, 0x1
s32i a7, a6, 0x4C
s32i a7, a6, 0x58
Code: Select all
Triggering syscall "pid_switch"...
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4000bfd8: 00000000 00000000 00000000
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4000cff4: 00000000 00000000 00000000
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4000cff4: 00000000 00000000 00000000
...