ESP32cam and GPIO interrupt: Camera init failed with error 0x105

I'm working on the ESP32cam module. It works fine until I try to define an interrupt on GPIO. My code is something like

#define SYNC_TRIG                           14

void IRAM_ATTR Sync_Triggered( void )
{
    // Do some stuff
    return;
}

void Camera_Setup( void )
{
	// Turn-off the 'brownout detector'
	WRITE_PERI_REG( RTC_CNTL_BROWN_OUT_REG, 0 );

	// OV2640 camera module
	camera_config_t config;
	config.ledc_channel = LEDC_CHANNEL_0;
	config.ledc_timer = LEDC_TIMER_0;
	config.pin_d0 = Y2_GPIO_NUM;
	config.pin_d1 = Y3_GPIO_NUM;
	config.pin_d2 = Y4_GPIO_NUM;
	config.pin_d3 = Y5_GPIO_NUM;
	config.pin_d4 = Y6_GPIO_NUM;
	config.pin_d5 = Y7_GPIO_NUM;
	config.pin_d6 = Y8_GPIO_NUM;
	config.pin_d7 = Y9_GPIO_NUM;
	config.pin_xclk = XCLK_GPIO_NUM;
	config.pin_pclk = PCLK_GPIO_NUM;
	config.pin_vsync = VSYNC_GPIO_NUM;
	config.pin_href = HREF_GPIO_NUM;
	config.pin_sscb_sda = SIOD_GPIO_NUM;
	config.pin_sscb_scl = SIOC_GPIO_NUM;
	config.pin_pwdn = PWDN_GPIO_NUM;
	config.pin_reset = RESET_GPIO_NUM;
	config.xclk_freq_hz = 20000000;
	config.pixel_format = PIXFORMAT_JPEG;

	if ( psramFound() )
	{
		Serial.println( "PSRAM found. Frame size FRAMESIZE_UXGA (1600x1200)" );
		config.frame_size = FRAMESIZE_UXGA;
		config.jpeg_quality = 10;
		config.fb_count = 2;
	}
	else
	{
		Serial.println( "PSRAM not found. Frame size FRAMESIZE_SVGA (800x600)" );
		config.frame_size = FRAMESIZE_SVGA;
		config.jpeg_quality = 12;
		config.fb_count = 1;
	}

	// Camera init
	esp_err_t err = esp_camera_init( &config );

	if ( err != ESP_OK )
	{
		Serial.printf( "Camera init failed with error 0x%x", err );
		ESP.restart();
		return;
	}

	sensor_t * s = esp_camera_sensor_get();
	// initial sensors are flipped vertically and colors are a bit saturated
	if ( s->id.PID == OV3660_PID )
	{
		s->set_vflip( s, 1 ); // flip it back
		s->set_brightness( s, 0 ); // up the brightness just a bit
		s->set_saturation( s, 0 ); // lower the saturation
	}
}

void setup()
{
    pinMode( SYNC_TRIG, INPUT_PULLDOWN );
    attachInterrupt( SYNC_TRIG, Sync_Triggered, RISING );
    Serial.begin( 115200 );

    // CAMERA SETUP
	Camera_Setup();
}

void loop()
{
    
}

If I remove the line

attachInterrupt( SYNC_TRIG, Sync_Triggered, RISING );

it works fine and I can take picture without problems. But with the line above I get the error

ets Jun 8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

configsip: 0, SPIWP:0xee

clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

mode:DIO, clock div:2

load:0x3fff0018,len:4

load:0x3fff001c,len:1044

load:0x40078000,len:10124

load:0x40080400,len:5828

entry 0x400806a8

ÿPSRAM found. Frame size FRAMESIZE_UXGA (1600x1200)

[E][camera.c:1327] camera_init(): gpio_install_isr_service failed (105)

[E][camera.c:1406] esp_camera_init(): Camera init failed with error 0x105

It seems the attachInterrupt() function corrupts the initializzation of the camera. If I call it after the Camera_Setup() I get

ets Jun 8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

configsip: 0, SPIWP:0xee

clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

mode:DIO, clock div:2

load:0x3fff0018,len:4

load:0x3fff001c,len:1044

load:0x40078000,len:10124

load:0x40080400,len:5828

entry 0x400806a8

ÿPSRAM found. Frame size FRAMESIZE_UXGA (1600x1200)

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

Core 1 register dump:

PC : 0x4010ae1b PS : 0x00060e30 A0 : 0x800d3bc2 A1 : 0x3ffb1f10

A2 : 0x00000000 A3 : 0x00000000 A4 : 0x40081300 A5 : 0x00000000

A6 : 0x3ffc17d0 A7 : 0x0000000a A8 : 0x800fde26 A9 : 0x3ffb1ec0

A10 : 0x00000105 A11 : 0x0000040e A12 : 0x00000000 A13 : 0x00000000

A14 : 0x40081300 A15 : 0x00000000 SAR : 0x00000001 EXCCAUSE: 0x0000001c

EXCVADDR: 0x00000000 LBEG : 0x4008988c LEND : 0x400898a8 LCOUNT : 0xffffffff

ELF file SHA256: 0000000000000000

Backtrace: 0x4010ae1b:0x3ffb1f10 0x400d3bbf:0x3ffb1f30 0x400d3c1d:0x3ffb1f60 0x400d25e1:0x3ffb1f80 0x400d4862:0x3ffb1fb0 0x4008c49e:0x3ffb1fd0

Rebooting...

Any suggestions?

Don't use a pin for an interrupt that is under the camera's control.

1 Like

The #define of pins used by camera:

#define PWDN_GPIO_NUM                           32
#define RESET_GPIO_NUM                          -1
#define XCLK_GPIO_NUM                           0
#define SIOD_GPIO_NUM                           26
#define SIOC_GPIO_NUM                           27
#define Y9_GPIO_NUM                             35
#define Y8_GPIO_NUM                             34
#define Y7_GPIO_NUM                             39
#define Y6_GPIO_NUM                             36
#define Y5_GPIO_NUM                             21
#define Y4_GPIO_NUM                             19
#define Y3_GPIO_NUM                             18
#define Y2_GPIO_NUM                             5
#define VSYNC_GPIO_NUM                          25
#define HREF_GPIO_NUM                           23
#define PCLK_GPIO_NUM                           22

I'm using tha GPIO 14 witch is not used by the camera. You can check the pinout here.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.