- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
Through this programing of the dice, I was able to learn various PSoC designs. Since I created a program that uses DMA in PSoC 4, I also created a program that uses DMA in PSoC 6.
The environment used is as follows:
・PSoC Creator 4.2
・CY8CKIT-062-BLE
The DMA functionality of PSoC6 is designed to be more flexible than PSoC4, so one channel can be transferred using offset. Since the circuit of the counter and decoder part is not required, the circuit is only the DMA timing input. The circuit is shown below.
The DMA transfer is the following image.
The DMA component was set as follows.
The program on CM4 is as follows:
#include "project.h"
uint32_t sw=0; //sw is off (Stop rolling dicce)
uint32 Buffer[12]={0x37,0x01,0x1D,0x01,0x15,0x01,0x1C,0x00,0x14,0x00,0x08,0x00};
int main(void)
{
__enable_irq(); /* Enable global interrupts. */
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
#ifndef SW2
CapSense_Start();
CapSense_ScanAllWidgets(); // Start Initial Scan
#endif
PWM_1_TriggerSwap();
DMA_1_Start ((void const *)Buffer, (void const *)0x40320280);
PWM_2_Start();
for(;;)
{
#ifdef SW2
if(sw==0){
if(Cy_GPIO_Read(SW2_0_PORT,SW2_NUM)==0){
Timer_SetPeriod(400);
Timer_SetCounter(0);
Timer_Start(); // Start rolling dice
sw=1;
}
}
if(sw==1){
if(Cy_GPIO_Read(SW2_0_PORT,SW2_NUM)==1){
/* Roll dice slowly */
Timer_SetPeriod(2000);
Timer_SetCounter(0);
CyDelay(1500); // keep rolling slowly for 1.5sec
Timer_Disable();// Stop rolling dice
sw=0; // sw is off
}
}
#else
if(!CapSense_IsBusy())
{
CapSense_ProcessAllWidgets();
if(sw==0){ // If sw is on, check start botton0.
if(CapSense_IsWidgetActive(CapSense_BUTTON0_WDGT_ID)) // Check button 0 state
{
/* Start rolling dice*/
PWM_1_SetCounter(0);
PWM_1_SetPeriod0(399);
PWM_1_SetPeriod1(1999);
PWM_1_Start(); // Start rolling dice
sw=1; // sw is on
}
}
if(sw==1){ // If sw is on, check stop botton0.
if(CapSense_IsWidgetActive(CapSense_BUTTON1_WDGT_ID)) // Check button 1 state
{
/* Roll dice slowly */
PWM_1_TriggerSwap();
CyDelay(1500); // keep rolling slowly for 1.5sec
PWM_1_Disable();// Stop rolling dice
sw=0; // sw is off
}
}
CapSense_UpdateAllBaselines();
CapSense_ScanAllWidgets(); // Start next scan
}
#endif
}
}
/* [] END OF FILE */
Thanks,
Kenshow
- Labels:
-
PSoC 6