- 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. This time it is the modified version. From the previous program Let's make the dice of seven eyes on PSoC 4 with sound, the decoder part of the circuit is simplified and the PWM part is modified to swap. I will explain the changes here.
The environment used is as follows:
・PSoC Creator 4.3
・CY8CKIT-044
1. Change of decoding part
The simplified circuit of the decoding section is as follows. Two inverter logics have been deleted from the previous time.
2. PWM uses swap function
The PWM_1 component settings are as follows. Check the Swap of Period.
3. Program changes
Swap is performed at the timing of the S/W side.
/* ========================================
*
* Copyright YOUR COMPANY, THE YEAR
* All Rights Reserved
* UNPUBLISHED, LICENSED SOFTWARE.
*
* CONFIDENTIAL AND PROPRIETARY INFORMATION
* WHICH IS THE PROPERTY OF your company.
*
* ========================================
*/
#include "project.h"
uint32_t sw=0; //sw is off (Stop rolling dicce)
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
PWM_2_Start();
for(;;)
{
if(sw==0){
// if(Cy_GPIO_Read(SW2_PORT,SW2_NUM)==0){
if(SW2_Read()==0){
PWM_1_WritePeriodBuf(999);
PWM_1_WritePeriod(399);
PWM_1_WriteCounter(0); // Clear counter
PWM_1_Start(); // Start rolling dice
sw=1;
}
}
if(sw==1){
//if(Cy_GPIO_Read(SW2_PORT,SW2_NUM)==1){
if(SW2_Read()==1){
/* Roll dice slowly */
PWM_1_TriggerCommand(1, PWM_1_CMD_CAPTURE);
CyDelay(1500); // keep rolling slowly for 1.5sec
PWM_1_Stop();// Stop rolling dice
sw=0; // sw is off
}
}
}
}
/* [] END OF FILE */
Press SW2 on the kit board to rotate the dice, and release it to slowly move down and stop.
Thanks,
Kenshow
- Labels:
-
PSoC 345 LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Kenshow-san,
Thank you for sharing your example project with the community.
Best regards,
Hari