Hi,
We are using ncs tag v1.0.0.
I am using i2c_scanner example firmware. It works find when used as it is.
When I added "UART2" in this firmware i am getting hard fault.
If i2c is removed from this firmware then "UART2" works fine.
Below is my prj.conf file.
CONFIG_TRUSTED_EXECUTION_NONSECURE=y CONFIG_I2C=y CONFIG_I2C_NRFX=y CONFIG_I2C_2=y CONFIG_I2C_2_NRF_TWIM=y CONFIG_NEWLIB_LIBC=y # UART 2 CONFIG_SERIAL=y CONFIG_UART_NRFX=y CONFIG_UART_INTERRUPT_DRIVEN=y CONFIG_UART_2_NRF_UARTE=y
Below is my .overlay file
&i2c2 { status = "ok"; sda-pin = < 13 >; scl-pin = < 14 >; clock-frequency = <I2C_BITRATE_STANDARD>; }; &uart2 { status = "ok"; current-speed = < 9600 >; tx-pin = < 16 >; rx-pin = < 17 >; rts-pin = < 18 >; cts-pin = < 19 >; };
below is my the main function.
void main(void) { struct device *i2c_dev; k_sleep(500); printk("Starting i2c scanner...\n"); i2c_dev = device_get_binding(I2C_DEV); if (!i2c_dev) { printk("I2C: Device driver not found.\n"); return; } uart2 = device_get_binding("UART_2"); uart_irq_callback_set(uart2, UDi_Uart2RxInt); uart_irq_rx_enable(uart2); uint8_t error = 0u; i2c_configure(i2c_dev, I2C_SPEED_SET(I2C_SPEED_STANDARD)); printk("Value of NRF_TWIM3_NS->PSEL.SCL: %ld \n",NRF_TWIM3_NS->PSEL.SCL); printk("Value of NRF_TWIM3_NS->PSEL.SDA: %ld \n",NRF_TWIM3_NS->PSEL.SDA); printk("Value of NRF_TWIM3_NS->FREQUENCY: %ld \n",NRF_TWIM3_NS->FREQUENCY); printk("26738688 -> 100k\n"); for (u8_t i = 4; i <= 0x77; i++) { struct i2c_msg msgs[1]; u8_t dst = 1; /* Send the address to read from */ msgs[0].buf = &dst; msgs[0].len = 1U; msgs[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP; error = i2c_transfer(i2c_dev, &msgs[0], 1, i); if (error == 0) { printk("0x%2x FOUND\n", i); } else { //printk("error %d \n", error); } } }
when "uart_irq_callback_set(uart2, UDi_Uart2RxInt);" is called it creates hard fault as shown below
Peripheral<HT> <HT> Domain<HT> <HT> Status<CR><LF> 00 NRF_P0<HT> <HT> Non-Secure<HT> OK<CR><LF> 01 NRF_CLOCK<HT> <HT> Non-Secure<HT> OK<CR><LF> 02 NRF_RTC1<HT> <HT> Non-Secure<HT> OK<CR><LF> 03 NRF_NVMC<HT> <HT> Non-Secure<HT> OK<CR><LF> 04 NRF_UARTE1<HT> <HT> Non-Secure<HT> OK<CR><LF> 05 NRF_UARTE2<HT> <HT> Non-Secure<HT> OK<CR><LF> 06 NRF_TWIM2<HT> <HT> Non-Secure<HT> OK<CR><LF> 07 NRF_SPIM3<HT> <HT> Non-Secure<HT> OK<CR><LF> 08 NRF_TIMER0<HT> <HT> Non-Secure<HT> OK<CR><LF> 09 NRF_TIMER1<HT> <HT> Non-Secure<HT> OK<CR><LF> 10 NRF_TIMER2<HT> <HT> Non-Secure<HT> OK<CR><LF> 11 NRF_SAADC<HT> <HT> Non-Secure<HT> OK<CR><LF> 12 NRF_PWM0<HT> <HT> Non-Secure<HT> OK<CR><LF> 13 NRF_PWM1<HT> <HT> Non-Secure<HT> OK<CR><LF> 14 NRF_PWM2<HT> <HT> Non-Secure<HT> OK<CR><LF> 15 NRF_PWM3<HT> <HT> Non-Secure<HT> OK<CR><LF> 16 NRF_IPC<HT> <HT> Non-Secure<HT> OK<CR><LF> 17 NRF_VMC<HT> <HT> Non-Secure<HT> OK<CR><LF> 18 NRF_FPU<HT> <HT> Non-Secure<HT> OK<CR><LF> 19 NRF_EGU1<HT> <HT> Non-Secure<HT> OK<CR><LF> 20 NRF_EGU2<HT> <HT> Non-Secure<HT> OK<CR><LF> 21 NRF_GPIOTE1<HT> <HT> Non-Secure<HT> OK<CR><LF> <CR><LF> SPM: NS image at 0xc000<CR><LF> SPM: NS MSP at 0x20020620<CR><LF> SPM: NS reset vector at 0xd941<CR><LF> SPM: prepare to jump to Non-Secure image.<CR><LF> ***** Booting Zephyr OS v1.14.99-ncs2 *****<CR><LF> Starting i2c scanner...<CR><LF> device_get_binding<CR><LF> Exception occurred in Secure State<CR><LF> ***** HARD FAULT *****<CR><LF> Fault escalation (see below)<CR><LF> ***** BUS FAULT *****<CR><LF> Precise data bus error<CR><LF> BFAR Address: 0x50008120<CR><LF> ***** Hardware exception *****<CR><LF> Current thread ID = 0x200200ec<CR><LF> Faulting instruction address = 0xc7a0<CR><LF> Fatal fault in ISR! Spinning...<CR><LF>
Regards,
Smitesh Mali