Using two I2s instances on PSoC6 CY8CPROTO-062-4343 kit

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

cross mob
shsh_4753781
Employee
Employee
10 sign-ins 5 sign-ins First reply posted

Hello,

I am trying to use two I2S instances to design a project for collecting data using im69d130 microphone shield2go from Infineon. As per the datasheet, I can use two I2S block. One is on port5 and other on port 11.

However, to startwith, I am trying to initialise I2S but initialisation fails. I am making use of HAL library.

Should I configure clocks for Shield2Go board, it has three pins: DATA, SCLK,WCLK? Is I2S instance master or slave?

How in general we can read mic data using m69d130 microphone shield2go.

My code looks like this:

1) cyhal_i2s_t i2s_0;
const cyhal_i2s_pins_t i2s_0_rx_pins = { .sck = P5_4, .ws = P5_5, .data =
P5_6 };
const cyhal_i2s_config_t i2s_0_config = { .is_tx_slave = false,
.is_rx_slave = true, .mclk_hz = 0, .channel_length = 16,
.word_length = 16, .sample_rate_hz = 24000u };
cy_rslt_t result = cyhal_i2s_init(&i2s_0, NULL, &i2s_0_rx_pins,
NC, &i2s_0_config, NULL);

 The result variable is expected to return 0 if everything goes well. It return me a big integer number that means I2S was not initialised. Can you tell me how to proceed?

2 ) Also, is there a way to see the value of variable with out optimisation? While debugging, I see <optismized value>.

I tried to use volatile keyword like volatile cy_rslt_t result , but I dont want to use it all the time. Is there away to turn off optimisation in debug mode? updating CXXXFlags in project make file does not work. 

I used emptyPSoC app to create the project.

Thankyou.

0 Likes
1 Solution
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

The initialization might be failing due to one of the following reasons:

- Some of the I2S pins are being used by another block (CYHAL_I2S_RSLT_ERR_INVALID_PIN)

- Not able to achieve the desired sample rate (CYHAL_I2S_RSLT_ERR_CLOCK)

If you sort out the optimization issue with the cy_result, it would be nice to know which value was returned. You could also run in debug mode and enter to the cyhal_i2s_init() function to see exactly where is failing.

View solution in original post

0 Likes
4 Replies
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

The initialization might be failing due to one of the following reasons:

- Some of the I2S pins are being used by another block (CYHAL_I2S_RSLT_ERR_INVALID_PIN)

- Not able to achieve the desired sample rate (CYHAL_I2S_RSLT_ERR_CLOCK)

If you sort out the optimization issue with the cy_result, it would be nice to know which value was returned. You could also run in debug mode and enter to the cyhal_i2s_init() function to see exactly where is failing.

0 Likes

The issue was with the clock. Now I can initialize the I2S blocks.

https://github.com/Infineon/mtb-example-psoc6-pdm-to-i2s

Refer to the clock_init() function.

 

This helped. Thankyou.

0 Likes
shsh_4753781
Employee
Employee
10 sign-ins 5 sign-ins First reply posted

Hi RodolfoGL,

Thank you for the reply. Do I have to init the clock before calling cyhal_i2s_init(). Which clocks to initialise and also do I have to enable them? Clock might be one reason for failing. Do you have a code snippet of clock initialisation before calling i2s_init() ?

Not able to solve the optimisation issue till now.

Thanks

0 Likes
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

In PSoC 6, the I2S uses the HFCLK1. If you haven't configured that in the Device Configurator, you can do it using the clock HAL driver. Refer to this code example:

https://github.com/Infineon/mtb-example-psoc6-pdm-to-i2s

Refer to the clock_init() function.

0 Likes