Configurating EXTI for Events

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Post Reply
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Configurating EXTI for Events

Post by alexblack »

Hi.
I porting my old project from ChibiOS 17.x to current 19.x ( STM32F303). I used EXTI driver for processing pin change interrupt and analog comparator interrupt. Also it is used for event generation to start ADC from external pin, wake up the CPU from sleep mode by UART. New PAL functions for enabling and processing PIN CHANGE interrupts work well. Analog Comparator Interrupt also is working, I used extiEnableLine for this.
One question is about how to setup HARDWARE PIN EVENT for generation ADC START event for example.
palEnablePadEvent is setup only interrupt mode:

Code: Select all

file "..\os\hal\ports\STM32\LLD\GPIOv2\hal_pal_lld.c"
...
193 EXTI->IMR1 |= padmask;
194  EXTI->EMR1 &= ~padmask;
...

When I used EXTI driver - it do it. extiEnableLine do not work because it stopped by debug assertion:

Code: Select all

file "..\os\hal\ports\STM32\LLD\EXTIv1\stm32_exti.h"
...
66 /* Masked out lines must not be touched by this driver.*/
67   osalDbgAssert((mask & STM32_EXTI_IMR1_MASK) == 0U, "fixed lines");
...

What is the reason to do such check?
Also I used UARTs events (line 25 and 26) for wake up the CPU from deepsleep mode and it is also stopped by extiEnableLine.
Maybe there is another way to set EXTi in new 19.x version, but I can't found?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Configurating EXTI for Events

Post by Giovanni »

Hi,

The reason is that fixed lines cannot be programmed, their bits into some registers are not defined (FTSR, RTSR for example). Probably another function is needed that just enables/disables the line without setting a "mode".

Giovanni
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: Configurating EXTI for Events

Post by alexblack »

I think for fixed lines it is simple to add some configuration bits to "ioeventmode_t mode" like "PAL_MODE_ACTION_EVENT" to function palEnablePadEvent and it will be ok.
For the other lines extiEnableLine looks ok, but for forbidden mask it is need to skip setting the FTSR, RTSR in function code, for example.
alexblack
Posts: 277
Joined: Mon Sep 24, 2012 3:52 pm
Been thanked: 33 times

Re: Configurating EXTI for Events

Post by alexblack »

Hi.
There is no function extiDisableLine() in current EXTI model.
It may be like this:

Code: Select all

/**
 * @brief   STM32 EXTI line deinitialization.
 *
 * @param[in] line      line to be released
 *
 * @api
 */
void extiDisableLine(extiline_t line) {
  uint32_t mask = (1U << (line & 0x1FU));

  osalDbgCheck(line < STM32_EXTI_NUM_LINES);

#if STM32_EXTI_NUM_LINES > 32
  if (line < 32) {
#endif
    extiEnableGroup1(mask, 0);
#if STM32_EXTI_NUM_LINES > 32
  }
  else {
    extiEnableGroup2(mask, 0);
  }
#endif
}
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Configurating EXTI for Events

Post by Giovanni »

Hi,

Moved in change request.

Giovanni
Post Reply