Hi everyone,
I'm trying to interface the nrf5340 with the intan chip rhd2132, that allows to record signals. I can read successfuly the registers, but when I try the recording task, It does not work. I'm using the PPI module to handle the spim.
void ppi_configuration()
{
nrfx_err_t err_code;
uint8_t ppi_channel1,ppi_channel2; // ppi_channel3;
err_code = nrfx_gppi_channel_alloc(&ppi_channel1);
if (err_code != NRFX_SUCCESS)
{
printk("PPI channel allocation error for channel 1");
}
err_code = nrfx_gppi_channel_alloc(&ppi_channel2);
if (err_code != NRFX_SUCCESS)
{
//printk("PPI channel allocation error for channel 2");
}
// err_code = nrfx_gppi_channel_alloc(&ppi_channel3);
// if (err_code != NRFX_SUCCESS)
// {
// printk("PPI channel allocation error for channel 3");
// }
uint32_t timer_event_addr = nrfx_timer_compare_event_address_get(&timer, NRF_TIMER_CC_CHANNEL0);
spim_start_task_addr = nrf_spim_task_address_get(spim_inst.p_reg, NRF_SPIM_TASK_START);
nrfx_gppi_channel_endpoints_setup(ppi_channel1, timer_event_addr, spim_start_task_addr);
spim_end_event_addr = nrf_spim_event_address_get(spim_inst.p_reg, NRF_SPIM_EVENT_END);
uint32_t counter_task_addr = nrfx_timer_task_address_get(&counter, NRF_TIMER_TASK_COUNT);
nrfx_gppi_fork_endpoint_setup(ppi_channel1, counter_task_addr);
uint32_t counter_event_addr = nrfx_timer_compare_event_address_get(&counter, NRF_TIMER_CC_CHANNEL4);
uint32_t counter_seq_task_addr = nrfx_timer_task_address_get(&counter_seq, NRF_TIMER_TASK_COUNT);
nrfx_gppi_channel_endpoints_setup(ppi_channel2, counter_event_addr, counter_seq_task_addr);
nrfx_gppi_channels_enable(1 << ppi_channel1 | 1 << ppi_channel2); // | 1 << ppi_channel3); AL MOMENTO IL CANALE 3 non è abilitato
}This is the spim initializationvoid spim_initialization(void)
{
nrfx_spim_config_t spim_config = NRFX_SPIM_DEFAULT_CONFIG(SCK_PIN,
MOSI_PIN,
MISO_PIN,
CS1_PIN);
spim_config.ss_active_high = false,
spim_config.irq_priority = 0,
spim_config.orc = 0xFF,
spim_config.frequency = NRFX_MHZ_TO_HZ(16),
spim_config.mode = NRF_SPIM_MODE_0,
spim_config.bit_order = NRF_SPIM_BIT_ORDER_MSB_FIRST,
spim_config.miso_pull = NRF_GPIO_PIN_NOPULL,
NRFX_COND_CODE_1(NRFX_SPIM_EXTENDED_ENABLED, (spim_config.use_hw_ss = true; spim_config.ss_duration = 0x04;), ()); //prova con 0x00
nrfx_err_t status = nrfx_spim_init(&spim_inst, &spim_config, NULL, NULL);
//nrfx_err_t status = nrfx_spim_init(&spim_inst, &spim_config, spim_event_handler, NULL);
if (status != NRFX_SUCCESS)
{
//printk("SPI initialization failed with error code: %d\n", status);
//return 0;
}
else
{
//return 1;
}
}This part handles the spim through the nrfx spim flags:void spim_convert_trx_setup() // NEW VERSION
{
spim_inst.p_reg->TXD.PTR = (uint32_t)convert_commands[0];
spim_inst.p_reg->RXD.PTR = (uint32_t)spim_trx_result_conv[0];
spim_inst.p_reg->TXD.LIST = 1;
spim_inst.p_reg->RXD.LIST = 1;
spim_inst.p_reg->TXD.MAXCNT = 2; // we want to transfer 2 bytes for each trx
spim_inst.p_reg->RXD.MAXCNT = 2; // we want to receive 2 bytes for each trx
nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TRX(convert_commands[0], 2, spim_trx_result_conv[0], 2);
uint32_t spim_flags = NRFX_SPIM_FLAG_TX_POSTINC | NRFX_SPIM_FLAG_RX_POSTINC | NRFX_SPIM_FLAG_NO_XFER_EVT_HANDLER | NRFX_SPIM_FLAG_REPEATED_XFER | NRFX_SPIM_FLAG_HOLD_XFER;
nrfx_spim_xfer(&spim_inst, &xfer_desc, spim_flags);
//printk("spim_convert_trx_setup.\n");
}Do you have any suggestion? Thanks