This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Luminary Class-d library + RTX = Hard Fault

I'm wondering if anyone can help me out with this issue? I'm using a Luminary LM3S3748 Cortex-M3 with the provided Luminary Class-d amp library to play PCM audio data. Every thing works great as long as I start playback (using their ClassDPlayPCM function) before entering RTX.

If I Start play back once the RTOS is running, I receive a hard fault on the line

    ROM_IntEnable(INT_PWM1);


which enables the PWM irq. It is also worth noting that I can begin playback then immediately call os_sys_init and both the RTOS and audio playback run concurrently as expected.

On inspection of the fault registers the Forced bit of the Hard Fault Register is set and the Bfarvalid and Preciserr bits are set in the Bus Fault Status Register.

I'll admit that I'm not that familiar with PWM's which is why I've opted to try and use the Luminary provided Libraries. Did I miss anything obvious? What would cause a fault when enabling an irq while RTX is running? Any help is appreciated.

Parents
  • Is the Luminary code expected to work with RTX - or any other OS, for that matter?

    If not, it's not reasonable to expect that any arbitrary piece of software that is designed to have direct, full and unfettered access to the "bare metal" hardware will "just work" under an RTOS...

Reply
  • Is the Luminary code expected to work with RTX - or any other OS, for that matter?

    If not, it's not reasonable to expect that any arbitrary piece of software that is designed to have direct, full and unfettered access to the "bare metal" hardware will "just work" under an RTOS...

Children
  • Andy, I understand your point and I don't just expect it to work. The reason I came to this forum is because I don't understand what exactly is going wrong and am looking for help. Once I can understand why it isn't working I can take the necessary steps to get it working.

    To answer your question, the Luminary code does not seem to have been made with an RTOS in mind; however I am failing to see what would cause issue with the RTOS. The code seems to set up the PWM peripheral and then enable the PWM irq. The irq itself is never reached as the code hard faults as soon as the irq is enabled. If I remove the line that enables the PWM irq, no hard fault occurs.

  • Do you have an option Run in privileged mode enabled in your RTX_Config.c? Accessing peripherals from unpriviliged mode causes Hard Fault.

  • Franc, thanks that worked. I converted that function to a SVC function so that I don't have to run the entire RTOS in priv mode.

    I went back to the Luminary audio example, and it turns out that they are making the function call from an irq i.e. privileged mode. I failed to see that connection, or any documentation that stated that it would need to run in privileged mode.

    One thing still didn't make sense to me though, I was able to call the function successfully from main, which I thought was executed in User mode. Reverting back to the code where I called the function from main, the debugger shows that main is executing in privileged mode. I opened up a STM32 example provided with Keil and I get the same thing. Is this normal?