GPIO toggle gets interrupted

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

GPIO toggle gets interrupted

1,222件の閲覧回数
arvindprakash
Contributor I

Hi,

We are using custom IMX6 board. We have a requirement of toggling a GPIO line at higher speed. We are using the the following code

   volatile u32 *gpio_base_addr = (u32) ioremap_nocache(GPIO_ADDR,32);

   spin_lock(&gpio_spinlock);
   gpio_high_val = readl(gpio_base_addr) | 0x200;

   gpio_low_val = readl(gpio_base_addr) &  0xFFFFDFF;

   gpio_base_addr = gpio_high_val;

   gpio_base_addr = gpio_low_val;

                    ...

                    ... for 20 times

                    ...

   gpio_base_addr = gpio_high_val;

   gpio_base_addr = gpio_low_val;

          

   spin_unlock(&gpio_spinlock);

We are able to get the twenty toggle cycles most of the time. Sometimes we are not getting the full toggle cycles, the line simply remains low  after 10 to 15 toggles. We want the complete cycles all the time.

We are using the GPIO (3, 14) and disabled the drivers which are using GPIOs from the bank 3 in the DTS, but still it gets interrupted.

Thanks,

Arvind

ラベル(1)
タグ(2)
0 件の賞賛
返信
2 返答(返信)

1,102件の閲覧回数
arvindprakash
Contributor I

Hi Igor,

   Our device has only one core, and as per our understanding the usage of spinlock should avoid the context switching.

we have tried spin_lock(), spin_lock_irqsave() and spin_lock_irq() but still the toggle cycles get interrupted.

we would like to know whether the issue is related to iomem access or GPIO bus(interrupts)

Thanks

Arvind

0 件の賞賛
返信

1,102件の閲覧回数
igorpadykov
NXP Employee
NXP Employee

Hi Arvind

linux is mulitasking operating system so each process can interrupt gpio routine.

May be recommended to try processors with M4 core running freertos, like i.MX7.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信