GPIO toggle gets interrupted

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

GPIO toggle gets interrupted

567 次查看
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 回复数

447 次查看
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 项奖励

447 次查看
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 项奖励