Search found 17 matches

by gp7
Mon Mar 06, 2023 4:20 pm
Forum: ChibiOS/RT
Topic: Calling ADC conversion from PWM interrupt
Replies: 1
Views: 23295

Calling ADC conversion from PWM interrupt

Hi,

I've been debugging code for a motor control thread which is calling an ADC conversion from within a PWM interrupt service routine.
Although the code appeared to run on previous Chibios/RT versions it fails on 21.11.x
When I run the application in debug mode I notice the device gets stuck and ...
by gp7
Wed Nov 23, 2022 12:43 pm
Forum: STM32 Support
Topic: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option
Replies: 25
Views: 18265

Re: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option

Apologies for reviving this thread.
Just a note for anyone that might be seeing similar issues. I managed to trace my problems with I2C bus to the setup of the I2CConfig:

const I2CConfig m_i2cfg2 = {0x30A0A7FB, 0, 0};

this was declared in a function however so a location was allocated on the ...
by gp7
Wed Nov 16, 2022 5:15 pm
Forum: STM32 Support
Topic: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option
Replies: 25
Views: 18265

Re: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option

Thanks steved,

I have enabled CH_DBG_ENABLE_STACK_CHECK and CH_DBG_FILL_THREADS in chconf.h If there is a problem with the stack sizes how does that normally manifest?

On a hugely positive note since changing the size of my blinker thread working area I haven't seen an unhandled exception yet so I ...
by gp7
Wed Nov 16, 2022 12:55 pm
Forum: STM32 Support
Topic: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option
Replies: 25
Views: 18265

Re: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option

Thank you Giovanni,

I increased the process stack size to 0xD00 and the code managed to proceed much further.
After that I started seeing a stack overflow in dbg_panic_msg. At that point an LED blinker thread was reporting 0 StkUnused. After doubling it's working area to 256 things seemed to start ...
by gp7
Tue Nov 15, 2022 7:31 pm
Forum: STM32 Support
Topic: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option
Replies: 25
Views: 18265

Re: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option

Hi All,

I have checked my stack sizes, removed everything but main thread and I am still able to create an unhandled exception.
I have also changed to Chibios v21.11

When I look at main and idle threads there are 2840 bytes available on main and 64 in idle under StkUnused before ch_queue_fifo ...
by gp7
Fri Nov 11, 2022 2:55 pm
Forum: STM32 Support
Topic: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option
Replies: 25
Views: 18265

Re: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option

Thank you Giovanni,

I performed a diff -qr on my chibios folder and reverted all files back to originals.
Finally I still had an unhandled exception:

I am still receiving an unhandled exception in my code in the function __sch_ready_behind(thread_t *tp)
If I put a breakpoint on ch_pqueue_insert ...
by gp7
Fri Nov 11, 2022 11:55 am
Forum: STM32 Support
Topic: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option
Replies: 25
Views: 18265

Re: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option

Thank you Giovanni,

I found that one of the Chibios 21.6.0 files had been altered. I have returned it to it's original state.
The following line within chMtxLockS was commented out: ch_sch_prio_insert(&mp->queue, &currtp->hdr.queue);

When uncommented I get an unhandled exception within ...
by gp7
Thu Nov 10, 2022 8:07 pm
Forum: STM32 Support
Topic: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option
Replies: 25
Views: 18265

Re: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option

Thanks Giovanni,

The cpp wrapper files are included in the Makefile
I have found that the Mutex objects were initialised in the main loop:

static mutex_t mux_mtx;
chMtxObjectInit(&EmbeddedToolsN::mux_mtx);

In the end of the worker thread (main function) I send data via I2C bus then I have the ...
by gp7
Wed Nov 09, 2022 7:37 pm
Forum: STM32 Support
Topic: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option
Replies: 25
Views: 18265

Re: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option

Apologies to kick this ticket again. I am following the advice on the debugging guide to "never give up"

I have implemented the Lock class as suggested by alex31 and placed breakpoints on the constructor and destructor.

#include "osal.h"

class Lock
{
public:
//Lock(mutex_t &_mtx) : mtx(_mtx ...
by gp7
Fri Oct 21, 2022 5:49 pm
Forum: STM32 Support
Topic: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option
Replies: 25
Views: 18265

Re: SMT32G474- i2cAcquireBus not getting Mutex when built with -O0 compiler option

How is it possible to determine if my stack is corrupt?
I can step through code in my main loop that I have protected with a mutex and the pointer jumps from the start of a function, to the middle, then back to a previous point before ending at VectorF4.
No other threads except idle are running ...