Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 6 Forum Discussions

Haiping
Level 1
First reply posted First like given First question asked
Level 1

Hi, 

We are  configuring I2C on the CY8CKIT-062S2-43012 EVB as a slave and use Infineon Bridge Control Panel as a host using USB-I2C bridge. We can successfully verify and test the code from "I2C_Slave_using_callback"  example code, but when we copy the same code into another example code "Dual_CPU_Empty_app", the code does not work anymore. The issue is that the there is no event get triggered from SCB at all. The clock, NVIC, pin reg setting seem the same.

The new app does include freeRTOS, although commenting out the vTaskStartScheduler (so we don't actually activate the freertos) does not help. The code may still linked with freertos though.

Greatly appreciated for your hints and things to look at!

void i2c_slave_init(void)
{
cy_rslt_t result;

/* Allocate and initialize a I2C resource and auto select a clock */
result = cyhal_i2c_init(&i2c_slave, CYBSP_I2C_SDA,
CYBSP_I2C_SCL, NULL);

if (result == CY_RSLT_SUCCESS)
{
/* Configure the I2C resource to be slave */
result = cyhal_i2c_configure (&i2c_slave, &i2c_slave_cfg);
}

if (result == CY_RSLT_SUCCESS)
{
/* Configure I2C slave write buffer for I2C master to write into */
result = cyhal_i2c_slave_config_read_buff(&i2c_slave, i2c_write_buffer,
SL_WR_BUFFER_SIZE);
}

if (result == CY_RSLT_SUCCESS)
{
/* Configure I2C slave read buffer for I2C master to read from */
result = cyhal_i2c_slave_config_write_buff(&i2c_slave, i2c_read_buffer,
SL_RD_BUFFER_SIZE);
}

/* Handle error if I2C slave configuration failed */
if (result != CY_RSLT_SUCCESS) handle_error();

/* Register I2C slave event callback */
cyhal_i2c_register_callback(&i2c_slave,
(cyhal_i2c_event_callback_t) handle_i2c_slave_events, NULL);

/* Enable events */
cyhal_i2c_enable_event(&i2c_slave, (cyhal_i2c_event_t)
(CYHAL_I2C_SLAVE_WR_CMPLT_EVENT \
| CYHAL_I2C_SLAVE_RD_CMPLT_EVENT \
| CYHAL_I2C_SLAVE_ERR_EVENT \
| CYHAL_I2C_SLAVE_READ_EVENT \
| CYHAL_I2C_SLAVE_WRITE_EVENT\
| CYHAL_I2C_SLAVE_RD_IN_FIFO_EVENT\
| CYHAL_I2C_SLAVE_RD_BUF_EMPTY_EVENT),\
I2C_SLAVE_IRQ_PRIORITY, true);
}

int main(void)
{
cy_rslt_t result;

/* Initialize the device and board peripherals */
result = cybsp_init() ;
if (result != CY_RSLT_SUCCESS)
{
CY_ASSERT(0);
}

/* Initialize the I2C slave */
i2c_slave_init();

/* Enable global interrupts */
__enable_irq();

/* Initialize retarget-io to use the debug UART port */
result = cy_retarget_io_init(CYBSP_DEBUG_UART_TX, CYBSP_DEBUG_UART_RX,
CY_RETARGET_IO_BAUDRATE);

/* retarget-io init failed. Stop program execution */
if (result != CY_RSLT_SUCCESS)
{
CY_ASSERT(0);
}

printf("Hello World from M4 !!!\r\n\n");

//xTaskCreate(task_print_mem, "print mem task", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 4, NULL );
//vTaskStartScheduler();
CY_ASSERT(0);
for (;;)
{

}
}

0 Likes
1 Solution
Aashita_Raj
Moderator
Moderator 250 replies posted 250 sign-ins 100 replies posted
Moderator

Hi @Haiping ,

So far as I see, pasting the code from the code example "I2C_Slave_using_callback" might have not worked. Can you please check if you have included the FreeRTOS library through library manager?  

If possible, can you please attach your project here so that we can also check at our end?

Best Regards,

Aashita

View solution in original post

0 Likes
1 Reply
Aashita_Raj
Moderator
Moderator 250 replies posted 250 sign-ins 100 replies posted
Moderator

Hi @Haiping ,

So far as I see, pasting the code from the code example "I2C_Slave_using_callback" might have not worked. Can you please check if you have included the FreeRTOS library through library manager?  

If possible, can you please attach your project here so that we can also check at our end?

Best Regards,

Aashita

0 Likes