SPI InstrFetchProhibited
Posted: Thu Nov 30, 2017 6:21 pm
Good Evening
My target: Control an ePaper Display via SPI.
I'm using: ESP32 Core Board V2, WaveShare 1.54 ePaper ssd1607
Environment: esp-idf, not arduino
I know there are already libraries available, but I want to understand how it works technically.
I downloaded the sample of the manufacturer for Arduino. Now I'm trying to port that stuff to ESP32, analyze and learn.
So far I'm pretty happy with the result
I'm almost done but I run into an issue:
As soon as the code executes spi_device_transmit I get a Guru Meditation Error of type InstrFetchProhibited
and the ESP32 reboots.
One part of the code:
Init main function:
I'm using these pins:
Does anybody have an idea why this reboot happens?
I thank you for your time, so far, this board has been an amazing help.
If I didn't provide all necessary informations, please let me know.
Greetings
Martin
My target: Control an ePaper Display via SPI.
I'm using: ESP32 Core Board V2, WaveShare 1.54 ePaper ssd1607
Environment: esp-idf, not arduino
I know there are already libraries available, but I want to understand how it works technically.
I downloaded the sample of the manufacturer for Arduino. Now I'm trying to port that stuff to ESP32, analyze and learn.
So far I'm pretty happy with the result
I'm almost done but I run into an issue:
As soon as the code executes spi_device_transmit I get a Guru Meditation Error of type InstrFetchProhibited
and the ESP32 reboots.
One part of the code:
Code: Select all
void EpdIf::SpiTransfer(unsigned char data){
// dc pin handled externaly
gpio_set_level((gpio_num_t)CS_PIN, LOW);
// SPI Transfer
spi_transaction_t t;
memset(&t, 0, sizeof(t)); //Zero out the transaction
t.length=8; //Command is 8 bits
t.tx_buffer=&data; //The data
ret=spi_device_transmit(spi, &t); //Transmit!
assert(ret==ESP_OK);
gpio_set_level((gpio_num_t)CS_PIN, HIGH);
}
int EpdIf::IfInit(void) {
gpio_set_direction((gpio_num_t)PIN_CS, GPIO_MODE_OUTPUT);
gpio_set_direction((gpio_num_t)PIN_RESET, GPIO_MODE_OUTPUT);
gpio_set_direction((gpio_num_t)PIN_DC, GPIO_MODE_OUTPUT);
gpio_set_direction((gpio_num_t)PIN_MOSI, GPIO_MODE_OUTPUT);
gpio_set_direction((gpio_num_t)PIN_BUSY, GPIO_MODE_INPUT);
spi_bus_config_t buscfg;
buscfg.miso_io_num = -1;
buscfg.mosi_io_num = PIN_MOSI;
buscfg.sclk_io_num = PIN_CLK;
buscfg.quadwp_io_num = -1;
buscfg.quadhd_io_num = -1;
buscfg.max_transfer_sz = 5*1024;
spi_device_interface_config_t dev_config;
dev_config.mode = 0;
dev_config.cs_ena_posttrans = 0;
dev_config.cs_ena_pretrans = 0;
dev_config.clock_speed_hz = 10*1000*1000;
dev_config.spics_io_num = PIN_CS;
dev_config.flags = 0;
dev_config.queue_size = 7;
//Initialize the SPI bus
ret=spi_bus_initialize(HSPI_HOST, &buscfg, 1);
printf("SPI: bus initialization done\r\n");
assert(ret==ESP_OK);
//Attach the display
ret=spi_bus_add_device(HSPI_HOST, &dev_config, &spi);
printf("SPI: display device added to spi bus (%d)\r\n", HSPI_HOST);
assert(ret==ESP_OK);
return 0;
}
Code: Select all
int Epd::Init(const unsigned char* lut) {
printf("epd1n54: Init start\r\n");
/* this calls the peripheral hardware interface, see epdif */
if (IfInit() != 0) {
printf("epd1n54: init error\r\n");
return -1;
}
/* EPD hardware init start */
printf("epd1n54: Init done\r\n");
this->lut = lut;
Reset();
SendCommand(DRIVER_OUTPUT_CONTROL);
SendData((EPD_HEIGHT - 1) & 0xFF);
SendData(((EPD_HEIGHT - 1) >> 8) & 0xFF);
SendData(0x00); // GD = 0; SM = 0; TB = 0;
SendCommand(BOOSTER_SOFT_START_CONTROL);
SendData(0xD7);
SendData(0xD6);
SendData(0x9D);
SendCommand(WRITE_VCOM_REGISTER);
SendData(0xA8); // VCOM 7C
SendCommand(SET_DUMMY_LINE_PERIOD);
SendData(0x1A); // 4 dummy lines per gate
SendCommand(SET_GATE_TIME);
SendData(0x08); // 2us per line
SendCommand(DATA_ENTRY_MODE_SETTING);
SendData(0x03); // X increment; Y increment
SetLut(this->lut);
/* EPD hardware init end */
return 0;
}
I'm using these pins:
Code: Select all
// CLK - GPIO 18
#define PIN_CLK 18 // yellow
// MOSI - GPIO 23
#define PIN_MOSI 23 // blue
// RESET - GPIO 16
#define PIN_RESET 16 // white
// DC - GPIO 17
#define PIN_DC 17 // green
// CS - GPIO 5
#define PIN_CS 5 // orange
// Busy - GPIO 4
#define PIN_BUSY 4 // violett
I thank you for your time, so far, this board has been an amazing help.
If I didn't provide all necessary informations, please let me know.
Greetings
Martin