PSoC™ 6 Forum Discussions
When I create a task, it seems to run just fine. But as soon as I call any blocking function (vTaskDelay), the app never seems to re-enter the Ready state. I have configTICK_RATE_HZ is defined in FreeRTOSConfig.h. Is there anything else I can look at?
Show LessIs it possible to configure the CY8CPROTO-063-BLE to run the eInk Display CY8CKIT-028-EPD?
Hello everyone, this is my second question on this lovely community.
If the person who had helped in my previous question sees this, I posted this in a new post so the other one doesn't get out of context and doesn't become too long 🙂
Last time, a member helped solve my previous problem, which is to generate a 45 kHz signal over a period of 10 ms every second. I will post below the build and the code, and what my new problem is according to their suggestion.
The idea is to use a timer, and call an interrupt one overflow of the timer counter to generate the signal over 10 ms and disable the PWM afterwards.
Here is the m04 code:
#include "project.h"
#include <stdio.h>
void Counter_Int_Handler() //Counter interrupt handler
{
printf("Handler is here \r\n");
Cy_TCPWM_ClearInterrupt(Timer_HW, Timer_CNT_NUM, CY_TCPWM_INT_ON_TC); //Clearing the interrupt
Cy_GPIO_Inv(LED_PORT, LED_NUM);
CyDelay(10);
Cy_GPIO_Inv(LED_PORT, LED_NUM);
PWM_Disable();
CyDelay(990);
PWM_Start();
printf("End of Handler \r\n\n");
}
int main(void)
{
UART_Start();
Timer_Start();
PWM_Start();
bool flag = true;
Cy_GPIO_Write(LED_PORT,LED_NUM,1);
Cy_SysInt_Init(&SysInt_1_cfg,Counter_Int_Handler); //Configuring the interrupt
NVIC_ClearPendingIRQ(SysInt_1_cfg.intrSrc); //Clearing the interrupt
NVIC_EnableIRQ(SysInt_1_cfg.intrSrc); //Calling the interrupt handler
__enable_irq(); //Enable global interrupts
//(void)Cy_TCPWM_Counter_Init(Timer_HW, Timer_CNT_NUM, &Timer_config);
Cy_TCPWM_Enable_Multiple(Timer_HW, Timer_CNT_MASK); //
Cy_TCPWM_TriggerReloadOrIndex(Timer_HW, Timer_CNT_MASK);
printf ("\033[3J"); //Clearing PuTTY's scrollback buffer
printf ("\ec"); //Clearing previous PuTTY outputs
printf("UART link established \r\n\n");
__enable_irq();
for(;;)
{
printf("Hello for loop! \r\n");
Cy_SysPm_Sleep(CY_SYSPM_WAIT_FOR_INTERRUPT);
}
}
The problem is that once the interrupt handler is called and start executing, it executes infinitely and never exits back to the for loop.
Also, although I am I managed to get the interrupt service routine to work, I am not quite sure if I understand how I exactly did it, nor what is the exact logic behind it as well; you could say I am following my sense and basic understanding of these matters.
My questions are as following:
1) Is the interrupt logic correct?
2) Could the interrupt logic used here be enhanced to be more efficient and/or exit to the for loop and back to the interrupt again without flags?
3) How to use flags?
I will post a weird attempt of mine to grasp the idea of flags, but in my opinion I failed miserably and most probably didn't actually understand anything.
Here is the miserable attempt on grasping flags:
#include "project.h"
#include <stdio.h>
void Counter_Int_Handler() //Counter interrupt handler
{
bool flag = true;
printf("Handler is here \r\n");
Cy_TCPWM_ClearInterrupt(Timer_HW, Timer_CNT_NUM, CY_TCPWM_INT_ON_TC); //Clearing the interrupt
Cy_GPIO_Inv(LED_PORT, LED_NUM);
CyDelay(10);
Cy_GPIO_Inv(LED_PORT, LED_NUM);
PWM_Disable();
CyDelay(990);
PWM_Start();
if (flag == true){
printf("End of Handler flag trigered \r\n\n");
NVIC_ClearPendingIRQ(SysInt_1_cfg.intrSrc);
__NVIC_DisableIRQ(SysInt_1_cfg.intrSrc);
}
}
int main(void)
{
UART_Start();
Timer_Start();
PWM_Start();
bool flag = false;
Cy_GPIO_Write(LED_PORT,LED_NUM,1);
Cy_SysInt_Init(&SysInt_1_cfg,Counter_Int_Handler); //Configuring the interrupt
NVIC_ClearPendingIRQ(SysInt_1_cfg.intrSrc); //Clearing the interrupt
NVIC_EnableIRQ(SysInt_1_cfg.intrSrc); //Calling the interrupt handler
__enable_irq(); //Enable global interrupts
//(void)Cy_TCPWM_Counter_Init(Timer_HW, Timer_CNT_NUM, &Timer_config);
Cy_TCPWM_Enable_Multiple(Timer_HW, Timer_CNT_MASK); //
Cy_TCPWM_TriggerReloadOrIndex(Timer_HW, Timer_CNT_MASK);
printf ("\033[3J"); //Clearing PuTTY's scrollback buffer
printf ("\ec"); //Clearing previous PuTTY outputs
printf("UART link established \r\n\n");
if (flag == true){
for(;;){
printf("Hello for loop! flag is true \r\n");
NVIC_EnableIRQ(SysInt_1_cfg.intrSrc); //Calling the interrupt handler
flag = false;
Cy_SysPm_Sleep(CY_SYSPM_WAIT_FOR_INTERRUPT);
}
}
else {
printf("Flag is flase! \r\n");
flag = true;
return flag;
}
}
and here is the output of the last attempt with the flag:
I am excited and looking forward everyone's suggestions/solutions!
Thank you and best regards,
HappyPotamus.
Show LessHi.
I'm using Modustoolbox to run the example AnyCloud_MQTT_Client with AWS on the board CY8CPROTO-062-4343W.
I modified the example just to update the RTC to be able to add a timestamp to the MQTT json messages that are sent to the cloud.
If I update the RTC before the MQTT connection is done, then, once the app connects to the MQTT broker the RTC goes to EPOCH 1970-01-01 00:00:00. Dunno if this means that the RTC is reseted.
If I wait until the app connects to MQTT and then I update the RTC then it works fine and the RTC keeps providing updated time.
Any idea why this is happening? or what am I missing here?
I'm using the code snippes in [1] to update the RTC
[1] https://infineon.github.io/psoc6hal/html/group__group__hal__rtc.html
Show Less
Hello,
I have a CY8CMOD-062-4343W evaluation board that I'm trying to get up and running in Modus Toolbox for a BLE project. I started with the BLE_CapSense_Buttons_and_Slider example project. I got that up and running and it worked great with the CySmart app and the terminal output matched what was expected in the README.
Then I started adding in my own BLE Characteristics using the Bluetooth Configurator (v 2.30). After making some changes, the BLE now fails to start, and I get the following messages on my terminal:
Bluetooth Stack Initialization Successful!
[613] hci_open(): init error (0x4021c00)
[613] hci_write(): UART is NOT initialized
[613] handle_hci_tx_command(): hci write failed (0xb7)
I am not sure what would be causing the HCI initialization to fail, and I can't find anything on what these error messages mean. It is weird to me that I get the Initialization Successful message, since I would have thought that initializing HCI would be part of the BLE stack setup.
It is also worth noting that the ble_app_management_cb() method is never called like it is in the example app, so I don't get the messages about my device name and address.
I can however touch the capsense slider and I see that the ble_task handles this by calling the ble_send_notification() method which seems to finish without errors despite the HCI not being initialized.
Any help on tracking down this error would be greatly appreciated.
Best regards,
Cory
Show LessI'm looking for general guidance on Psoc6 device security. AN22111 seems titled correctly, but is no longer published. Is there something new in the works or can I get access to the old one?
Show Less- Is the vector unit capable of running when the actual CPU is in sleep or deep sleep?
- What are the approximate timings for ECDSA signing and verification assuming the Clk_Peri is running at 75MHz?
Thanks!
Bryan
Show LessHello,
Question 1:Where can I configure the generated .map file (memory map)?
Question 2:I want to count the size of ROM and RAM occupied by each file. How to set Modus Toolbox 2.3?
Question 3:How to configure Modus Toolbox 2.3 like the .map file generated by Keil ?
Best wishes,
JCD
Show LessHello everyone,
I am new to PSoC and embedded systems in general. I am using a CY8CPROTO-063-BLE PSoC 6 PROTOTYPING KIT. I am trying to generate a signal of 45 kHz over 1 second, where it pulses for 10 ms of the entire second and the rest is a flat line. I have been attempting to replicate this small project for a long time, and I am really frustrated (Sorry I am a newbie and don't know nor understand much about PSoC).
This is basically similar to an example provided by the company itself, but they did not include any code with it. I guess the idea here is to use a timer counter (OneSecTImer in the pic) to time the other timer counter (Counter in the pic) to work every second, whereas the PWM (FreqGen in the pic) is what generates a signal for the Counter to capture. I am not sure if I am supposed to use a UART or not, but I included it and have been using printf() function to print the desired outputs to PuTTY program. The clocks of the FreqGen and Counter are at 1 MHz, whereas the clock for the OneSecTimer is at 1 kHz (I am not sure if these values are acceptable).
This picture is the settings for the OneSecTimer (also I am not sure if I am choosing the correct period, but I am aware that the count starts from 0 hence why I used 999u).
These are the settings for the PWM FreqGen. I am sure I had done the period wrong, as I had assumed that the period is supposed to be related to the desired 45 kHz output. And I had read on some other post that the compare should be half of the period (In the code I used one of the PDL commands to rewrite the period and compare).
These are the settings for the Counter, with the count input mode as rising edge. I am not sure if my settings will lead me to me to my desired goal.
This is the code I am using in the CM4, and nothing on CM0 other than the default generated code.
#include "project.h"
#include <stdio.h>
//----NOT SURE IF THESE ARE NECESSARY AND WHAT IS THEIR ROLE EXACTLY----//
#define PWM_FreqGen (PWM_FreqGen_HW)
#define OneSecTimer (OneSecTimer_HW)
#define Counter (Counter_HW)
#define MY_Counter_CNT_NUM (0UL)
#define MY_Counter_CNT_MASK (1UL << MY_Counter_CNT_NUM)
#define MY_TCPWM_FreqGen_NUM (0UL)
//----------------------------------------------------------------------//
void Counter_Int_Handler() //Counter interrupt handler
{
NVIC_ClearPendingIRQ(Counter_Int_cfg.intrSrc);
}
int main(void)
{
__enable_irq(); //Enabling global interrupts
UART_Start();
OneSecTimer_Start();
FreqGen_Start();
Counter_Start();
Cy_SysInt_Init(&Counter_Int_cfg,Counter_Int_Handler); //Calling the interrupt but what for?
NVIC_EnableIRQ(Counter_Int_cfg.intrSrc);
float period = 25;
float compare = period/2;
printf ("\ec"); //Clearing previous PuTTY outputs
printf("Link successful\r\n");
for(;;)
{
Cy_TCPWM_PWM_SetPeriod0(FreqGen_HW,FreqGen_CNT_NUM,period);
Cy_TCPWM_PWM_SetCompare0(FreqGen_HW, FreqGen_CNT_NUM,compare);
//-----------------------------TESTING BLOCK-----------------------------//
float status = Cy_TCPWM_PWM_GetStatus(Counter_HW,Counter_CNT_NUM);
float compare0 = Cy_TCPWM_PWM_GetCompare0(Counter_HW,Counter_CNT_NUM);
float compare1 = Cy_TCPWM_PWM_GetCompare1(Counter_HW,Counter_CNT_NUM);
float period0 = Cy_TCPWM_PWM_GetPeriod0(Counter_HW,Counter_CNT_NUM);
float period1 = Cy_TCPWM_PWM_GetPeriod1(Counter_HW,Counter_CNT_NUM);
float statusmask = Cy_TCPWM_PWM_GetStatus(Counter_HW,Counter_CNT_MASK);
float compare0mask = Cy_TCPWM_PWM_GetCompare0(Counter_HW,Counter_CNT_MASK);
float compare1mask = Cy_TCPWM_PWM_GetCompare1(Counter_HW,Counter_CNT_MASK);
float period0mask = Cy_TCPWM_PWM_GetPeriod0(Counter_HW,Counter_CNT_MASK);
float period1mask = Cy_TCPWM_PWM_GetPeriod1(Counter_HW,Counter_CNT_MASK);
//-----------------------------------------------------------------------//
if(status >= 45000){ //What I actually want this condition to be is to acces this statement when frequency is 45 kHz or greater
printf("First condition loop executed.\r\n");
printf("status: %f",status); printf("\n\r");
printf("compare0: %f",compare0);printf("\n\r");
printf("compare1: %f",compare1); printf("\n\r");
printf("period0: %f",period0); printf("\n\r");
printf("period1: %f",period1); printf("\n\r");
float GeneratedSignal = Cy_GPIO_Read(GeneratedSignal_PORT,GeneratedSignal_NUM);
printf("GeneratedSignal: %f",GeneratedSignal); printf("\n\r");
printf("Using mask:\r\n");
printf("statusmask: %f",statusmask); printf("\n\r");
printf("compare0mask: %f",compare0mask);printf("\n\r");
printf("compare1mask: %f",compare1mask); printf("\n\r");
printf("period0mask: %f",period0mask); printf("\n\r");
printf("period1mask: %f",period1mask); printf("\n\r");
Cy_GPIO_Write(RED_PORT,RED_NUM,!Cy_GPIO_Read(RED_PORT,RED_NUM));
CyDelay(500);
Cy_GPIO_Write(RED_PORT,RED_NUM,!Cy_GPIO_Read(RED_PORT,RED_NUM));
CyDelay(500);
}
else { //Ignore the else statement
//printf("Signal out of desired range!\r\nCurrent Signal value of Status = %f",status); printf(" Hz\r\n");
//printf("Compared to a signal of %f",capture); printf(" Hz\r\n");
printf("First condition loop executed.\r\n");
printf("status: %f",status); printf("\n\r");
printf("compare0: %f",compare0);printf("\n\r");
printf("compare1: %f",compare1); printf("\n\r");
printf("period0: %f",period0); printf("\n\r");
printf("period1: %f",period1); printf("\n\r");
float GeneratedSignal = Cy_GPIO_Read(GeneratedSignal_PORT,GeneratedSignal_NUM);
printf("GeneratedSignal: %f",GeneratedSignal); printf("\n\r");
for (int i = 9; i >= 0; i--){
Cy_GPIO_Write(RED_PORT,RED_NUM,!Cy_GPIO_Read(RED_PORT,RED_NUM));
CyDelay(100);
}
}
printf("Next cycle~\r\n");
CyDelay(1000);
//Cy_TCPWM_PWM_Disable(FreqGen_HW, FreqGen_CNT_NUM); Do I need to disable and enable this?
}
}
I had tried many different readable parameters as an attempt to find the generated signal, but I am left with so many question. Before the questions, here is the picture of the output on PuTTY. Another note, retarget I/O is ticked.
I have no idea what most of these numbers output actually mean as the numbers seem like gibberish right now.
For my questions:
1) Is the logic of the build correct and what are the settings that I need to change.
2)If all the settings are now correct, would the attached code output the actual generated signal by the PWM?
3)How do I modify the code or correct so it pulses the 45 kHz signal over 10 ms out of a whole second.
4)Why does the PWM interrupt cause the loop to execute only once when the interrupt is called in void main in the first place?
5)When I do comment out the interrupt, the entire loop keeps on looping correctly with the LEDs blinking as I had written in the code. On the other hand, when I do include the interrupt, only the printf() functions execute and then it feels like the rest of the loop is frozen and not executing.
6)Do I need to add an ADC in order to actually be able to read and generate a signal or is the logic build provided sufficient?
I know this is very long, and thank you to everyone who will help or just tag a long in the journey of learning PSoC and solving this small project.
Best regards,
Issa Hoballah.
Show LessI am using the CY8C6116BZI-F54 PSoC 6 in a design and I am utilizing the internal SegLCD peripheral driver to drive a 3.3 V COG LCD with 46 SEGs and 6 COMs. I am having an issue where the when I command certain segments to turn off, it disables all of the segments on the same common line. It seems like the Device Configurator is generating code that is allowing this problem to occur. For example, in cycfg_routing.h, here are the defined terms for the COMs:
#define LCD0_DRIVE0_COM0 15
#define LCD0_DRIVE0_COM1 16
#define LCD0_DRIVE0_COM2 17
#define LCD0_DRIVE0_COM3 18
#define LCD0_DRIVE0_COM4 19
#define LCD0_DRIVE0_COM5 14
And here are the defined terms for the SEGs that I am seeing the problem occur with:
#define LCD0_DRIVE0_SEG9 15
#define LCD0_DRIVE0_SEG15 16
#define LCD0_DRIVE0_SEG16 17
#define LCD0_DRIVE0_SEG17 18
#define LCD0_DRIVE0_SEG18 19
I noticed there doesn't seem to be any LCD0_DRIVE0_SEGXY terms that happen to match LCD0_DRIVE0_COM5's value of 14. This creates a problem when calling the Cy_SegLCD_ClrPixel() function to clear the segment on each common with the same defined value. Let me explain. Considering the defined terms above in cycfg_routing.h, if I call the following functions in my application after initializing the LCD peripheral with all of the segments ON:
Cy_SegLCD_ClrPixel(LCD0, CY_SEGLCD_PIXEL(LCD0_DRIVE0_SEG_9, 0UL));
Cy_SegLCD_ClrPixel(LCD0, CY_SEGLCD_PIXEL(LCD0_DRIVE0_SEG_15, 1UL));
Cy_SegLCD_ClrPixel(LCD0, CY_SEGLCD_PIXEL(LCD0_DRIVE0_SEG_16, 2UL));
Cy_SegLCD_ClrPixel(LCD0, CY_SEGLCD_PIXEL(LCD0_DRIVE0_SEG_17, 3UL));
Cy_SegLCD_ClrPixel(LCD0, CY_SEGLCD_PIXEL(LCD0_DRIVE0_SEG_18, 4UL));
It will disable all of the segments on COMs 0 - 4, even though I only intend to clear a single segment with each function call. Upon further inspection of the CY_SEGLCD_PIXEL() macro, it seems like all of the LCD0_DRIVE0_SEGXY terms should be unique and different from all of the LCD0_DRIVE0_COMXY terms.
So my question is, why is the Device Configurator and SegLCD Configurator tools generating these defined terms with matching values between the COMs and some of the SEGs? Am I missing something, or is there a bug with the configuration tool(s)? I checked the HSIOM routing for the pins assigned to each of the aforementioned SEGs and COMs and they are all using different HSIOM routing, so I don't believe this would be a hardware issue where the SEG signals are clashing with the COM signals on those pins.
I have verified that all of my pin assignments and segment mapping in the configuration tools are correct and all physical connections to my LCD are correct as well.
I have included the BSP with the generated source files for the project I am referring to to aid in the discussion. Please let me know if I should include any application code, or if I am missing something, or if there may be an issue in the configuration tool(s).
Show Less