Code Examples Forum Discussions
Hi all,
Through this programing of the dice, I was able to learn various PSoC designs. I've considered 7LEDs dice with ModusToolbox, but I gave up because ModusToolbox doesn't have a tool like the circuit input of PSoC Creator. In addition, Creator generats C functions using the created component name, so it was easy to program. Unfortunately, in MTB, it is necessary to make detailed settings with the cy_ function, and there are few CEs that use the function when using Device Configurator, which causes confusion in how to use the cy_ function.
Last time, I was able to express a 7LED dice with DMA of PSoC6, so I can create it on MTB without a circuit input tool. I hope you can see it as a CE of DMA that kicks from PWM.
The environment used is as follows:
・ModusToolbox 2.2
・CY8CKIT-062-BLE
The DMA trigger inputs PWM overflow. The circuit image is as follows.
The DMA transfer is the following image.
Set this in Device Configurator. The settings for DMA_1 are shown below.
The PWM_1 settings are shown below. The period can be changed with swap.
The clock settings for PWM_1 are as follows.
The Pin settings are as follows. Drive Mode is set to LEDx pin: "Strong Drive, Input buffer off", SW2: "Resistive Pull-Up, Input Buffer on".
The program on CM4 is as follows:
#include"cy_pdl.h"
#include "cyhal.h"
#include "cybsp.h"
uint32 Buffer[12]={0x37,0x01,0x1D,0x01,0x15,0x01,0x1C,0x00,0x14,0x00,0x08,0x00};
uint32_t sw=0; //sw is off (Stop rolling dicce)
int main(void)
{
cy_rslt_t result;
/* Initialize the device and board peripherals */
result = cybsp_init() ;
if (result != CY_RSLT_SUCCESS)
{
CY_ASSERT(0);
}
__enable_irq();
//DMA_1_Start ((void const *)Buffer, (void const *)0x40320280);
if (CY_DMA_SUCCESS != Cy_DMA_Descriptor_Init(&DMA_1_Descriptor_0, &DMA_1_Descriptor_0_config))
{
while(1); // Handle Error
}
if(CY_DMA_SUCCESS != Cy_DMA_Channel_Init(DMA_1_HW, DMA_1_CHANNEL, &DMA_1_channelConfig)){
while(1); // Handle Error
}
Cy_DMA_Descriptor_SetSrcAddress(&DMA_1_Descriptor_0, (void const *)Buffer);
Cy_DMA_Descriptor_SetDstAddress(&DMA_1_Descriptor_0, (void const *)0x40320280);
Cy_DMA_Descriptor_SetNextDescriptor(&DMA_1_Descriptor_0, &DMA_1_Descriptor_0);
Cy_DMA_Channel_Enable(DMA_1_HW, DMA_1_CHANNEL);
Cy_DMA_Enable(DMA_1_HW);
//Cy_TCPWM_PWM_Init(PWM_2_HW, PWM_2_NUM, &PWM_2_config);
//Cy_TCPWM_PWM_Enable(PWM_2_HW, PWM_2_NUM);
for (;;)
{
if(sw==0){
if(Cy_GPIO_Read(SW2_PORT,SW2_NUM)==0){
Cy_TCPWM_PWM_Init(PWM_1_HW, PWM_1_NUM, &PWM_1_config);
Cy_TCPWM_PWM_Enable(PWM_1_HW, PWM_1_NUM);
Cy_TCPWM_TriggerStart(PWM_1_HW, PWM_1_MASK);
sw=1;
}
}
if(sw==1){
if(Cy_GPIO_Read(SW2_PORT,SW2_NUM)==1){
/* Roll dice slowly */
Cy_TCPWM_TriggerCaptureOrSwap(PWM_1_HW, PWM_1_MASK);
CyDelay(1500); // keep rolling slowly for 1.5sec
Cy_TCPWM_PWM_Disable (PWM_1_HW, PWM_1_NUM);
sw=0; // sw is off
}
}
}
}
/* [] END OF FILE */
Usage: Press SW2 to rotate the dice and release it to slow down and stop.
Thanks,
Kenshow
Show LessDescription
This project demonstrates Advanced Sector Protection technique in S25FL512S NOR Flash. It shows the behavior of flash in Password Protection Mode.
The Password Protection Mode can be enabled by programming a 64-bit password to the flash and setting the ASP Register [2] bit to zero. The password can be read and verified till the ASP register has not been programmed. Once ASP register has been programmed, the password can no longer be read. In the Password Protection Mode, the PPB array remains locked by default at POR or hardware reset. The Password Unlock command PASSU (E9h) along with the correct password is required to unlock the PPB array. After unlocking, the PPB bits can be programmed or erased. The PPB bits remain unlocked till the next power cycle.
Link
The project is available in GitHub here.
All necessary information like requirements, supported kit, hardware/software setup, getting started with code example, steps followed and expected output are mentioned in the readme file of the project.
Show LessTopics are getting fragmented when they are getting locked...
There are several post about cyelftool (not cymcuelftool) for different platforms than Windows. Unfortunately I can't reply when they get locked...
Referred from this topic: cyelftool for mac/linux / cyelftool vs cymcuelftool
So here it is, cyelftool for Mac.
Show LessHello,
KBA225808 can be tried up to V6.0 of CSD.
CSD V7.0 requires a program modification.
The following of main.c has been changed.
Please see the following thread.
Measure Cmod and Cp of PSoC 4S CapSense for CSD V7.0
Up to CSD V6.0 [The unit of u8_cpValue[] are pF(picofarad).]
From CSD V7.0 [The unit of u8_cpValue[] are fF(femtofarad).]
Be sure to set the following definition in main.c to 0.
(Set to 1 to enable CapSense Tuner.)
Build this project and program it into CY8C4045AZI-S413 of CY8CKIT-145-40XX.
Here, if a program for I2C communication with CY8C4045AZI-S413 is written in CYBLE-022001-00, it will not work properly.
Use the PSoC Programmer to erase the CYBLE-022001-00 program.
Launch the Bridge Control Panel and follow the steps below to open V70_2ch Cp.iic and V70_2ch Cp.ini.
1. [File] -> [Open File...] -> [V70_4ch Cp.iic] open
2. [Chart] -> [Variable Settings] -> [Loading...] in Submenu -> [V70_4ch Cp.ini] open -> [OK] in Submenu
3. Click the following line in the [Editor] tab.
r 08 x x x x x @0WID0 @1WID0 @2WID0 @3WID0 @0WID1 @1WID1 @2WID1 @3WID1 p
4. Select the [Chart] tab next to the [Editor] tab and click [Repeat].
Then, touch SLD0(0.0) and SLD4(0.6).
Click the next line in the [Editor] tab if you want to see the Cmod value.
r 08 x @0CMOD @1CMOD @2CMOD @3CMOD x x x x x x x x p
And change the valiable settings of [Chart].
Best regards,
Yocchi
Show LessSummary
This example project shows how to use an unconfigured SCB block as UART in the bootloadable project and as SPI master during bootloading process. This method can be used when all the available SCB blocks are used in the bootloadable project for UART communication and wants to implement an external memory (SPI) bootloader. This project will configure the SCB block for UART communication initially and re-configure it as SPI master when bootloader starts. Already available “NOR Flash Bootloader” project is modified to use an un-configured SCB block.
Changes made to the already available “NOR Flash Bootloader” project is explained below. Please refer the documentation for “NOR Flash Bootloader” for more details about how external memory bootloader project works.
Requirements
Design Tool: PSoC Creator 4.3
Programming language: C
Associated devices: All PSoC4 BLE devices
Required hardware: This project is tested with CY8CKIT-042-BLE-A Bluetooth® Low Energy 4.2 Compliant Pioneer Kit and S25FL064L Serial NOR flash.
Connections
SCB SPI connections between Flash and PSOC
MOSI | P0[0] |
MISO | P0[1] |
SCLK | P0[3] |
CS | P0[2] |
SCB UART connections
RX | P0[0] |
TX | P0[1] |
Dedicated UART Connections
TX | P1[5] |
PSoC Creator Schematic
Output
SCB block will be configured as UART when the bootloadable starts and print a message in UART terminal saying that, SCB is successfully configured for UART communication.
Message from dedicated UART block
Message from SCB configured as UART
When bootloader starts, the unconfigured SCB block will be re-configured as SPI master. Immediately after starting the SCB block as SPI master, device ID is read from flash to verify that SCB block is successfully configured as SPI master. This project is tested with S25FL064L and the device ID for this flash device is 0x01, 0x60 and 0x17.
Message after SCB is configured as SPI master.
Show Less
Using the CY8CKIT-149 PSoC® 4100S Plus Prototyping Kit, what view the touchpad serial data in a terminal emulator? Reading serial data is a very important design consideration in my application.
Show LessHi all,
Through this dice, I was able to learn various PSoC designs. In the past, UDB implemented counters and decoders, but I tried this part is implemented by DMA. The data value is transferred to GPIO for LED lighting by DMA and blinks.
Please see past posts for more information on electronic dice.
"PSoC 4 Seven Eyes Dice"
“PSoC 4 Seven Eyes Dice with sound”
“Let's make the dice of seven eyes on PSoC 4 with sound - version 2”
The environment used is as follows:
・PSoC Creator 4.3
・CY8CKIT-044
Since PSoC 4 cannot represent multiple offset transfers with one DMA, we used three DMAs. The transfer image of DMA is as follows.
The circuit is as following:
The DMA component settings are all the same.
The circuit is as following:
The program adds the data for the transfer and the initial settings for DMA.
:
uint32 Data1[6]={0x0007,0x0007,0x0007,0x0003,0x0003,0x0003};
uint32 Data2[6]={0x000D,0x0007,0x0005,0x0007,0x0005,0x0002};
uint32 Data3[6]={0x0003,0x0001,0x0001,0x0000,0x0000,0x0000};
int main(void)
{
/* Proximity sensor state. */
uint8 proximity = INACTIVE;
CyGlobalIntEnable; /* Enable global interrupts. */
/* Enable and start the CapSense block. */
CapSense_Start();
/* Initialize the baselines of all CapSense widgets. */
CapSense_InitializeSensorBaseline(CapSense_PROXIMITYSENSOR__PROX);
/* Enable and start PWM block. */
PWM_2_Start();
DMA_1_Start(Data1,(void *)0x40040000);
DMA_2_Start(Data2,(void *)0x40040100);
DMA_3_Start(Data3,(void *)0x40040300);
for(;;)
{
:
:
The dice rolls when you hold your hand over the proximity sensor, and the dice slowly rolls when you move it away, and then stops.
Thanks,
Kenshow
Show LessHi all,
Through this programing of the dice, I was able to learn various PSoC designs. This time it is the modified version from Let's make the dice of seven eyes on PSoC 6 with CapSense & sound,the protagonist of the game. The PWM part is modified to swap.
The environment used is as follows:
・PSoC Creator 4.2
・CY8CKIT-062-BLE
The components are placed on the PSoC 6 kit so that sound and CapSense can be used. The decoding circuit has also been simplified. The circuit of PSoC6 is as follows.
The PWM_1 component settings are as follows. Checked “Enable Swap Period”.
The pin assignments are as follows.
In the program, the PWM_1 component uses the period value swap. The program looks like this:
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(999);
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
} /* [] END OF FILE */
Thanks,
Kenshow
Show LessHi 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
Show LessHi,
Can i get any sample code for water tolerance. How guard sensor is handle in code???