Code Examples Forum Discussions
Hello all,
The project from the below GitHub link shows how to design a Digital Read Out (DRO) (used in the Mills/Lathe machines) using a PSoC 6 BLE device. A DRO is simply a digital reading of the scale along the axis in the mill or lathe. Usually, it is the X-, Y- and Z- axis for a milling machine, and X- and Z- axis for lathes. Linear encoders which output the position of the scale can be fixed on the axes of these machines and can be connected to a DRO. This PSoC 6 BLE DRO measures the position of all the three axes and sends the data over BLE to an Android App.
Schematic Diagram:
Hardware Required: CY8CKIT-062-BLE PSoC 6 BLE Pioneer Kit
Software Required: PSoC Creator 4.3
PSoC Creator project, Android App and project datasheet are attached in the below GitHub page.
GitHub link: PSoC6 BLE DRO for Mills and Lathe machines
Thanks,
P Yugandhar.
Show LessHi,
As you know, the DMA of PSoC 4 has 2 descriptors to implement PING-PONG, or back-to-back buffering translation.
So I was expecting to configure them for two different translations, which will result utilizing a DMA channel just like they were a couple of DMA channels.
In my previous study, I used 8 DMA channels to implement ADC-DMA-UART for displaying human readable hexadecimal strings.
A study of simple ADC and DMA and UART (CY8CKIT-044)
This time I tried to combine each ADC_RAW_H and ADC_RAW_L, DMA_H_ADR and DMA_L_ADR into one DMA with 2 descriptors.
And also I merged 4 DMAs used to send the result output into one DMA, but it required another DMA to transfer the char addresses into the result string,
I ended up 4 DMAs total, and 3 of them are using two descriptors.
Actually I have been trying to use this dual descriptor feature since I tried to write a simple oscilloscope sample.
A study of simple oscilloscope using ADC and DMA (CY8CKIT-044) version 1
But somehow I have managed to keep failing to use this feature.
This time I decided to challenge this for good, it took me more than a whole week though...
Although I could not find explicit description(s) how to do this.
Following is how I could make it work.
I use DMA_ASC for a sample.
(1) Obviously I "Number of descriptors" needs to be 2
(2) Descriptor 0 Configuration
Transfer mode: Entire descriptor chain per trigger
Post completion actions: "Chain to descriptor 1" (This is automatically checked.)
(3) Descriptor 1 Configuration
Transfer mode: Entire descriptor per trigger
Post completion actions: Chain to descriptor 0
Note: For me this configuration was hard to come up with.
Since descriptor 0 works without farther configuration, it took me very long time and many trials to figure out that
descriptor 1 needs to be manually validated
So initialization for this DMA_ASC looks like
====================
DMA_ASC_Start((void *)h_char, (void *)(&CYDMA_DESCR_BASE.descriptor[DMA_STR_CHANNEL][0].src)) ;
DMA_ASC_SetSrcAddress(1, (void *)l_char);
DMA_ASC_SetDstAddress(1, (void *)(&CYDMA_DESCR_BASE.descriptor[DMA_STR_CHANNEL][1].src)) ;
CyDmaValidateDescriptor(DMA_ASC_CHANNEL, 1) ;
====================
With above modification(s), the schematic was modified
from the previous schematic
to the current schematic
Pins
Tera Term log
main.c
========================
#include "project.h"
#include "stdio.h"
#include "ascii_byte_table.h"
uint32_t h_char_address = (uint32_t) ascii_h ;
uint32_t l_char_address = (uint32_t) ascii_l ;
uint8_t *h_char = (void *)&h_char_address ;
uint8_t *l_char = (void *)&l_char_address ;
char out_str[7] = { '0', 'x', 'H', 'L', '\n', '\r', '\0' } ;
void init_hardware(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
ADC_Start() ;
DMA_UART_Start((void *)out_str, (void *)UART_TX_FIFO_WR_PTR) ;
DMA_STR_Start((void*)h_char, (void *)(&out_str[2])) ;
DMA_STR_SetSrcAddress(1, (void *)l_char);
DMA_STR_SetDstAddress(1, (void *)(&out_str[3])) ;
CyDmaValidateDescriptor(DMA_STR_CHANNEL, 1) ;
DMA_ASC_Start((void *)h_char, (void *)(&CYDMA_DESCR_BASE.descriptor[DMA_STR_CHANNEL][0].src)) ;
DMA_ASC_SetSrcAddress(1, (void *)l_char);
DMA_ASC_SetDstAddress(1, (void *)(&CYDMA_DESCR_BASE.descriptor[DMA_STR_CHANNEL][1].src)) ;
CyDmaValidateDescriptor(DMA_ASC_CHANNEL, 1) ;
DMA_ADC_Start((void *)ADC_SAR_CHAN0_RESULT_PTR, (void *)h_char) ;
DMA_ADC_SetSrcAddress(1, (void *)h_char) ;
DMA_ADC_SetDstAddress(1, (void *)l_char) ;
CyDmaValidateDescriptor(DMA_ADC_CHANNEL, 1) ;
}
int main(void)
{
init_hardware() ;
UART_UartPutString("\x1b[2J\x1b[;H") ;
UART_UartPutString("ADC-DMA-UART 2-descriptors Test\n\r") ;
Timer_Start() ;
for(;;)
{
}
}
========================
ascii_byte_table.h
========================
#ifndef _ASCII_BYTE_TABLE_H_
#define _ASCII_BYTE_TABLE_H_
#include "project.h"
extern const uint8_t ascii_h[256] ;
extern const uint8_t ascii_l[256] ;
#endif
========================
ascii_byte_table.c
========================
#include "project.h"
#include "ascii_byte_table.h"
const uint8_t ascii_h[256]
__ALIGNED(0x100u)
= {
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
'2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2',
'3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3', '3',
'4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4',
'5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5', '5',
'6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6',
'7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7',
'8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8',
'9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9',
'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A',
'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B',
'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C',
'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D',
'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E',
'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F'
} ;
const uint8_t ascii_l[256]
__ALIGNED(0x100u)
= {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
} ;
========================
moto
Show LessHi all,
In order to study how to turn on and control many LEDs, I created a board with a matrix. I decided to make a roulette wheel using 36 LEDs. This time I will run it with DMA in PSoC4.
The environment used is as follows:
・PSoC Creator 4.4
・CY8CKIT-044
36 LEDs are mounted on the Arduino board, and 12 GPIOs are used to configure a 6x6 matrix. The circuit looks like this:
The actual Arduino board was made as shown in the picture below. There were quite a lot of wiring and it got messed up.
For the circuit, delete the part that was built in the digital hardware last time, and change the data setting of GPIO output to be done by DMA. The circuit and pin layout are as follows.
All three DMA settings are the same. For word transfer, increment the source address (specify array data) and fix the destination address (specify GPIO register address). The Configuration of one of them is shown.
Press the SW2 switch to rotate the roulette wheel, and release it to slow down and stop.
The program is as follows:
#include "project.h"
int data1[6]={0x1F,0x2F,0x37,0x3B,0x3D,0x3E};
int data2[36]={0x08,0x08,0x08,0x08,0x08,0x08,
0x04,0x04,0x04,0x04,0x04,0x04,
0x02,0x02,0x02,0x02,0x02,0x02,
0x01,0x01,0x01,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00};
int data3[36]={0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,
0x02,0x02,0x02,0x02,0x02,0x02,
0x01,0x01,0x01,0x01,0x01,0x01};
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()) */
*(int *)0x40040200 = 0x1F; // Initial LED setting
*(int *)0x40040100 = 0x08; // Initial LED setting
*(int *)0x40040300 = 0x00; // Initial LED setting
DMA_1_Start(data1,(void *)0x40040200);
DMA_2_Start(data2,(void *)0x40040100);
DMA_3_Start(data3,(void *)0x40040300);
for(;;)
{
if(sw==0){
// if(Cy_GPIO_Read(SW2_PORT,SW2_NUM)==0){
if(SW2_Read()==0){
PWM_1_WritePeriod(399);
PWM_1_WriteCounter(0);
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_WritePeriodBuf(1999);
PWM_1_TriggerCommand(1, PWM_1_CMD_CAPTURE);
CyDelay(1000); // keep rolling slowly for 1sec
PWM_1_WritePeriodBuf(3999);
PWM_1_TriggerCommand(1, PWM_1_CMD_CAPTURE);
CyDelay(1000); // keep rolling slowly for 1sec
PWM_1_WritePeriodBuf(7999);
PWM_1_TriggerCommand(1, PWM_1_CMD_CAPTURE);
CyDelay(1500); // keep rolling slowly for 1sec
PWM_1_Stop(); // Stop rolling
sw=0; // sw is off
}
}
}
}
When you press the SW2 switch, the roulette wheel rotates, and when you release it, it gradually stops slowly.
Thanks,
Kenshow
Show LessHi all,
In order to study how to turn on and control many LEDs, I created a board with a matrix. I decided to make a roulette wheel using 36 LEDs. This time, it will be a program to test this LED display board.
The environment used is as follows:
・PSoC Creator 4.3
・CY8CKIT-044
36 LEDs are mounted on the Arduino board, and 12 GPIOs are used to configure a 6x6 matrix. The circuit looks like this:
The actual Arduino board was made as shown in the picture below. There were quite a lot of wiring and it got messed up.
The circuit creates a counter to count 6 by combining the components of Coutner and Compare in column side. It is used to select the De-Multiplexer to select the output. The row side of the LED matrix is switched half alternately after 6 counts. As a result, the lighting of the three LEDs moves to shift. This will ensure that the LED board wiring is correct. The circuit and pin layout are as follows.
Since the purpose is to check the lighting of the LED, the PWM output is set to a slow frequency with a 5KHz clock as the input.
The program just starts PWM_1.
#include "project.h"
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
PWM_1_Start();
for(;;)
{
/* Place your application code here. */
}
}
If the connection is successful, the lights will be as shown below.
Thanks,
Kenshow
Show LessHi 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 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
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
Show LessHi,
こんにちは、
I prepared a LED modulator with CapSense and a switch.
今回私は、CapSenseとスイッチを使ったLED調光器を作成しました。
Click SW2, and you can change the LED brightness with taping the CapSense sensor.
You can make the LED brighter more and more by repeating tapping the sensor of CapSense..
スイッチを押すことで割り込みが発生し、CapSenseが反応するようになります。
CapSenseのセンサをタップすることで、LEDの光が徐々に明るくなっていきます。
Click SW2 again, and you can’t change the LED brightness however you tap the CapSense sensor.
また、もう一度スイッチを押すことで再度割り込みが発生し、CapSenseが反応しなくなります。
You can check the status of the modulator and the LED on your display because I contain UART on this program.
UARTを使用することで、現在のLEDと調光器の状態を確認できるようになっています。
PWM component is used to modulate brightness.
PWMは明るさの調整のために用いています。
When you compile and run the program, it will look like the picture below.
プログラムをコンパイルして実行すると以下のようになります。
schematic / 回路図
pin / ピンアサイン
Best regards,
Lina
Show LessHi all,
The electronic dice I posted last time was very popular. Many people have requested that we make on PSoC 4 version, so I made it based on CY8CKIT-044. I have also
created a new LED lighting board. This time it is based on Arduino.
The environment used is as follows:
・PSoC Creator 4.3
・CY8CKIT-044
The block diagram of the hardware is same as LED Test. The H/W block diagram is shown below.
Once the H/W check posted last time is completed, the electronic dice will be completed by changing the decoding circuit, adding SW, and changing the program. Please refer to the previous article for LED wiring and pin assignment. The circuit on PSoC 4 is as follows.
Pin SW2 is Input and Pull Up. Read the value programmatically with GPIO input.
The pin assignments are as follows.
The PWM is set earlier than last time. Actually, the program is more effective.
When the SW2 button is pressed, the dice start to roll, and when they are released, the dice slows down the rolling and stops.
#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_1_Start();
for(;;)
{
if(sw==0){
// if(Cy_GPIO_Read(SW2_PORT,SW2_NUM)==0){
if(SW2_Read()==0){
PWM_1_WritePeriod(400);
PWM_1_WriteCounter(0);
PWM_1_Start(); // Start
rolling dicesw=1;
}
}
if(sw==1){
//if(Cy_GPIO_Read(SW2_PORT,SW2_NUM)==1){
if(SW2_Read()==1){
/* Roll dice slowly */
PWM_1_WritePeriod(1000);
PWM_1_WriteCounter(0);
CyDelay(1500); // keep
rolling slowly for 1.5secPWM_1_Stop();// Stop rolling dice
sw=0; // sw is off
}
}
}
}
Thanks,
Kenshow
Show Less