在新样本准备就绪后,我也很难在GPIO1上产生中断。它适用于单次拍摄模式。以下是我的代码。我究竟做错了什么?我首先从主程序中调用'set_range_it'然后调用'start_cont_range'。我期待每100毫秒测量一次,但没有任何东西。
硬件或中断处理程序没有任何问题。如果我手动将引脚拉高,MCU会检测到中断并执行正确的代码。
def set_range_it(self):
while(self.i2c1.mem_read(1,self.addr,0x004D,addr_size = 16)[0]& 0x01)!= 0x01:
pyb.delay(1)
self.i2c1.mem_write(0x09,self.addr,0x001B,addr_size = 16)
self.i2c1.mem_write(0x01,self.addr,0x0017,addr_size = 16)
self.i2c1.mem_write(0x30,self.addr,0x0011,addr_size = 16)
self.i2c1.mem_write(0x04,self.addr,0x0014,addr_size = 16)
self.i2c1.mem_write(0x00,self.addr,0x0017,addr_size = 16)
self.i2c1.mem_write(0x07,self.addr,0x0015,addr_size = 16)
def start_cont_range(self):
while(self.i2c1.mem_read(1,self.addr,0x004D,addr_size = 16)[0]& 0x01)!= 0x01:
pyb.delay(1)
self.i2c1.mem_write(0x03,self.addr,0x0018,addr_size = 16)
以上来自于谷歌翻译
以下为原文
I have also great trouble generating an interrupt on GPIO1 after a new sample is ready. It works in the one shot mode. Below is my code. What am I doing wrong? I'm first calling 'set_range_it' and then 'start_cont_range' from the main program. I'm expecting a range measurement every 100ms but there is nothing.
There is nothing wrong with the hardware or the interrupt handler. If I pull the pin high manually the MCU detects the interrupt and executes the correct code.
def set_range_it(self):
while (self.i2c1.mem_read(1, self.addr, 0x004D, addr_size=16)[0] & 0x01) != 0x01:
pyb.delay(1)
self.i2c1.mem_write(0x09, self.addr, 0x001B, addr_size=16)
self.i2c1.mem_write(0x01, self.addr, 0x0017, addr_size=16)
self.i2c1.mem_write(0x30, self.addr, 0x0011, addr_size=16)
self.i2c1.mem_write(0x04, self.addr, 0x0014, addr_size=16)
self.i2c1.mem_write(0x00, self.addr, 0x0017, addr_size=16)
self.i2c1.mem_write(0x07, self.addr, 0x0015, addr_size=16)
def start_cont_range(self):
while (self.i2c1.mem_read(1, self.addr, 0x004D, addr_size=16)[0] & 0x01) != 0x01:
pyb.delay(1)
self.i2c1.mem_write(0x03, self.addr, 0x0018, addr_size=16)