PSoC™ 6 Forum Discussions
Hi. I'm trying to transfer an array to SPI peripheral using DMA on a psco6 (CY8CKIT-062-BT-WIFI).
The array length is a large arbitrary number that doesn't fit as a 2D transfer. let's say 643 bytes.
My idea is to divide it into two descriptor and chain them. i.e. first descriptor transfers 10x64 bytes, and second descriptor transfers 3 bytes. ( I'm not sure if there's any other way.)
The problem that I have is that it doesn't start the second descriptor. here is the code that I'm trying to get working:
#define txDma_ENABLED 1U
#define txDma_HW DW0
#define txDma_CHANNEL 2U
#define txDma_IRQ cpuss_interrupts_dw0_2_IRQn
/* Interrupt priority for TXDMA */
#define TXDMA_INTERRUPT_PRIORITY (7u)
volatile bool tx_dma_done = false;
cy_stc_dma_descriptor_t txDma_Descriptor_1 =
{
.ctl = 0UL,
.src=0UL,
.dst = 0UL,
.xCtl = 0UL,
.yCtl = 0UL,
.nextPtr = 0UL,
};
cy_stc_dma_descriptor_t txDma_Descriptor_0 =
{
.ctl = 0UL,
.src=0UL,
.dst = 0UL,
.xCtl = 0UL,
.yCtl = 0UL,
.nextPtr = 0UL,
};
const cy_stc_dma_descriptor_config_t txDma_Descriptor_0_config =
{
.retrigger = CY_DMA_RETRIG_IM,
.interruptType = CY_DMA_DESCR_CHAIN,
.triggerOutType = CY_DMA_1ELEMENT,
.channelState = CY_DMA_CHANNEL_DISABLED,
.triggerInType = CY_DMA_1ELEMENT,
.dataSize = CY_DMA_BYTE,
.srcTransferSize = CY_DMA_TRANSFER_SIZE_DATA,
.dstTransferSize = CY_DMA_TRANSFER_SIZE_WORD,
.descriptorType = CY_DMA_2D_TRANSFER,
.srcAddress = NULL,
.dstAddress = NULL,
.srcXincrement = 1,
.dstXincrement = 0,
.xCount = 1,
.srcYincrement = 0,
.dstYincrement = 0,
.yCount = 1,
.nextDescriptor = 0UL,
};
const cy_stc_dma_channel_config_t txDma_channelConfig =
{
.descriptor = &txDma_Descriptor_0,
.preemptable = false,
.priority = 3,
.enable = false,
.bufferable = false,
};
const uint8_t small_buffer[10]={0xA1,0xB2,0xC3};
uint32_t configure_tx_dma(uint8_t* tx_buffer)
{
cy_en_dma_status_t dma_init_status;
const cy_stc_sysint_t intTxDma_cfg =
{
.intrsrc=txDma_IRQ,
.intrPriority = 7u
};
/* Initialize descriptor */
dma_init_status = Cy_DMA_Descriptor_Init(&txDma_Descriptor_0, &txDma_Descriptor_0_config);
Cy_DMA_Descriptor_SetXloopSrcIncrement(&txDma_Descriptor_0, 1);
Cy_DMA_Descriptor_SetYloopSrcIncrement(&txDma_Descriptor_0, 64);
Cy_DMA_Descriptor_SetXloopDataCount(&txDma_Descriptor_0, 64);
Cy_DMA_Descriptor_SetYloopDataCount(&txDma_Descriptor_0, 10);
Cy_DMA_Descriptor_SetNextDescriptor(&txDma_Descriptor_0, &txDma_Descriptor_1);
dma_init_status = Cy_DMA_Descriptor_Init(&txDma_Descriptor_1, &txDma_Descriptor_0_config);
Cy_DMA_Descriptor_SetXloopSrcIncrement(&txDma_Descriptor_1, 1);
Cy_DMA_Descriptor_SetYloopSrcIncrement(&txDma_Descriptor_1, 3);
Cy_DMA_Descriptor_SetXloopDataCount(&txDma_Descriptor_1, 3);
Cy_DMA_Descriptor_SetYloopDataCount(&txDma_Descriptor_1, 1);
Cy_DMA_Descriptor_SetNextDescriptor(&txDma_Descriptor_1, 0UL);
if (dma_init_status!=CY_DMA_SUCCESS)
{
return INIT_FAILURE;
}
dma_init_status = Cy_DMA_Channel_Init(txDma_HW, txDma_CHANNEL, &txDma_channelConfig);
if (dma_init_status!=CY_DMA_SUCCESS)
{
return INIT_FAILURE;
}
/* Set source and destination for descriptor 1 */
Cy_DMA_Descriptor_SetSrcAddress(&txDma_Descriptor_0, tx_buffer);
Cy_DMA_Descriptor_SetDstAddress(&txDma_Descriptor_0, (void *)&SCB6->TX_FIFO_WR);
Cy_DMA_Descriptor_SetSrcAddress(&txDma_Descriptor_1, small_buffer);
Cy_DMA_Descriptor_SetDstAddress(&txDma_Descriptor_1, (void *)&SCB6->TX_FIFO_WR);
/* Initialize and enable the interrupt from TxDma */
Cy_SysInt_Init(&intTxDma_cfg, &tx_dma_complete);
NVIC_EnableIRQ((IRQn_Type)intTxDma_cfg.intrSrc);
/* Enable DMA interrupt source. */
Cy_DMA_Channel_SetInterruptMask(txDma_HW, txDma_CHANNEL, CY_DMA_INTR_MASK);
/* Enable DMA block to start descriptor execution process */
Cy_DMA_Enable(txDma_HW);
return INIT_SUCCESS;
}
void tx_dma_complete(void)
{
/* Check tx DMA status */
if ((CY_DMA_INTR_CAUSE_COMPLETION != Cy_DMA_Channel_GetStatus(txDma_HW, txDma_CHANNEL)) &&
(CY_DMA_INTR_CAUSE_CURR_PTR_NULL != Cy_DMA_Channel_GetStatus(txDma_HW, txDma_CHANNEL)))
{
/* DMA error occurred while TX operations */
//handle_error();
}
tx_dma_done = true;
/* Clear tx DMA interrupt */
Cy_DMA_Channel_ClearInterrupt(txDma_HW, txDma_CHANNEL);
}
void spi_dma_transfer()
{
Cy_DMA_Channel_SetDescriptor(txDma_HW, txDma_CHANNEL,&txDma_Descriptor_0);
Cy_DMA_Channel_Enable(txDma_HW, txDma_CHANNEL);
}
Show Less
Hi.
I'm using
cyhal_spi_transfer(cyhal_spi_t *obj, const uint8_t *tx, size_t tx_length, uint8_t *rx, size_t rx_length, uint8_t write_fill)
function to transfer a larg bunch of data (1250 bytes) over spi. it works very well if I have a tx buffer and a rx buffer.
However, If I just wanna use this function to receive same amount of b
bytes by doing:
cyhal_spi_transfer(&mSPI, NULL, 0, rx_buffer, 1250, 0xff);
it will have two long pauses in the middle:
it sends 1 byte, then pause, then send 1248 bytes, then pause, then another single byte.
Is there any work around for this? (except having a dummy tx buffer (I'm already doing it))
I'm running on cy8cking-062s2-43012 kit. SPI 6 on P12 at 25MHz master. CPU and clocks at 100MHz,
Show Less
I am using the CY8CPROTO-063-BLE kit for a motor control application. This kit has the built-in debugger on it.
If I use the debug utility in PSOC Creator, I can't see watch variables in "real time" - I have to pause the program so that my watch variables update.
Is there a different debug utility/program I can use with the PSOC6 kit, where I can see watched variables, and stream trace data, in real time?
I am including a screenshot of the Segger Ozone debugger, just to show the features (like streaming data) that I am looking for. [I am not sure if Ozone will work with the PSOC6].
Show Less
I'm working on a project using the XMC4800 microcontroller. What are some best practices for optimizing power consumption?"
by
Kat Williamson 📢
Show LessHi.
Can someone please explain to me that by who the code for cortex M0 is generated?
I remember that in PSoC creator, there were two main files for each processor. plus two ld files.
Can Okami tell me what TDs mean
When I used 3 SPI+3 DMA high-speed communication, there was indeed a delay, and I couldn't reach 20Mhz
smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/PSoC-6/spi-dma/td-p/670617
Show LessHello guys, (EDIT down)
You were helping me with other topics and I appreciate it! I want to tell you that I was working on my Project normally, and accidentally I pressed right-click and some option that collapsed all my subprojects in the workspace and they only showed TopDesigns inside each one, my 'mains' and other stuff disappeared! 😞 I'm not sure if this is undoable but I saw that my workspace has an asterisk * which means I didn't save it, but I'm pressing Ctrl+Z and it doesn't undo the action. My files seem to appear inside the folders so they are still there.
How could I fix it? I'm not touching anything because I'm afraid to ruin all the programs I have created. And I have no backup yet! 😕 Leave you the screenshots below attached of how it was before and how it is now my workspace.
Edit: Guys I found the solution, it was only a matter of a tab, I never noticed, that the Source and Components tabs are just on the right side of the workspace, you can select them, I was in the Components tab, and that's why I couldn't see my files, that is Source. I'm not sure how to solve a post, that maybe can be useful for someone in the future, but if you find the solution yourself, how can I reply to my post?
Thanks in advance,
Best regards, Gio
Show Less