Issue with external interrupt

Hi,

I’m attempting to trigger a snapshot every time the camera receives a TTL pulse. I keep getting the same error which I believe is related to pin allocation:

ValueError: ExtInt vector 14 is already in use

. Below is my code.

import sensor, image, time
from pyb import Pin, ExtInt

sensor.reset()                   
sensor.set_pixformat(sensor.RGB565) 
sensor.set_framesize(sensor.QVGA)   
sensor.skip_frames(time = 2000)    
clock = time.clock()                
syncFlag = 0

def callback (line):
    syncFlag = 1
    
while(True):
    ext = ExtInt(Pin('P0'), ExtInt.IRQ_RISING, Pin.PULL_UP, callback)
    if (syncFlag == 1):
        img=image.snapshot()
        syncFlag = 0

Don’t create the interrupt in the loop. Make it outside of the loop.