PSoC™ 6 Forum Discussions
Why the I2C slave interrupt sources must be enable for the Psoc6 SCB master I2C mode read or write operation?Show as the flow pictures:
Which interrupt event will be happened for the every step of i2c master operation?
Show Less
Hi
Are there any PSoC platforms that support AoA feature in BLE 5.1 ?
thanks
For my application, I need to read data from the PDM mic on the development board (later to be replaced with an I2S mic for the final application), and transfer the data to an xQueue to be sent over Bluetooth to an app. I have the xQueue Bluetooth component working well, but I'm having trouble configuring and activating the PDM_PCM component. What is the best approach to do this?
I have reviewed the PDM_PCM code example and see that they are using an interrupt to transfer. Unfortinately, I am unable to run this code example directly on my current dev kit (I have an older PSoC6 Dev board with the CY8C6347BZI-BLD53). So in my code, I tried setting up an interrupt to read data from the FIFO and enqueue it into my xQueue object using a semaphore. I then attached a SysInt component to the interrupt pin to fire an ISR. However, it seems that the PDM_PCM component is never enabled even though I start it in my main program. Below are some screenshots of my program and the settings:
System Schematic
PDM_PCM Settings
Interrupt Pin Settings
As mentioned earlier, I'm using FreeRTOS and created a microphoneTask to handle setup and transfer of the microphone data to a queue called txQueue. Here's the code in the task that sets up the PDM_PCM component and interrupt:
void microphoneTask(void *arg)
{
byte count = 0;
word data = {0};
(void)arg;
printf("Microphone Task started\r\n");
// Initialize the microphone semaphore
microphoneSemaphore = xSemaphoreCreateCounting(UINT_MAX, 0);
/* Initialize and enable the microphone interrupt */
Cy_SysInt_Init(&SysInt_PDMDataArrived_cfg, ISR_MicrophoneDataArrived);
NVIC_ClearPendingIRQ(SysInt_PDMDataArrived_cfg.intrSrc);
NVIC_EnableIRQ(SysInt_PDMDataArrived_cfg.intrSrc);
/* Start the PCM component */
Cy_PDM_PCM_Init(PDM_PCM_HW, &PDM_PCM_config);
Cy_PDM_PCM_Enable(PDM_PCM_HW);
for(;;)
{
count = Cy_PDM_PCM_GetNumInFifo(PDM_PCM_HW);
printf("%u Items in Queue\r\n", count);
Cy_GPIO_Inv(BLUE_LED_PORT, BLUE_LED_NUM);
vTaskDelay(100);
// Pend on the microphone semaphore until the microphone has some data available to transfer to the BLE queue
//xSemaphoreTake(microphoneSemaphore, portMAX_DELAY);
// Read data word from the microphone FIFO and transfer to the BLE TX queue
//data.value = Cy_PDM_PCM_ReadFifo(PDM_PCM_HW);
//xQueueSendToBack(txQueue, &data, portMAX_DELAY);
}
}
// Microphone Data transfer interrupt
void ISR_MicrophoneDataArrived()
{
// Trigger the microphone semaphore to handle the data transfer to the BLE queue
BaseType_t xHigherPriorityTaskWoken;
xHigherPriorityTaskWoken = pdFALSE;
xSemaphoreGiveFromISR(microphoneSemaphore, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
int main(void)
{
__enable_irq(); /* Enable global interrupts. */
/* Initialize Hardware peripherals */
UART_Start();
Cy_GPIO_Write(LED_PORT, LED_NUM, LED_OFF);
/* disable Stdin/out buffers */
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
/* Start Hardware Tasks */
xTaskCreate(bleTask,"bleTask", 8 * 1024, 0, 3, 0);
xTaskCreate(bleQueueReader,"bleQueueReader", 400, 0, 3, 0);
//xTaskCreate(timerTask,"timerTask", 400, 0, 1, 0);
xTaskCreate(microphoneTask, "microphoneTask", 400, 0, 1, 0);
/* Start RTOS task scheduler */
vTaskStartScheduler();
printf("Problem running scheduler!");
for(;;)
{
}
}
The microphoneTask task is able to execute when the program is started, but it just pended forever on the semaphore, indicating that something is either wrong with my ISR or it is never being triggered. To test this, I commented the semaphore code out and tried directly polling the value of the FIFO and noted that the value was always zero. It seems that the PDM_PCM component is not running even though I have it enabled. What am I missing here?
Show Less
I found a code example from the PSoC4 that shows how to switch ADC voltage references to measure and calculate the battery voltage going into the PSoC module. I need to do the same thing but using the PSoC6 rather than the PSoC4. However, it looks like the code to actually switch the ADC voltage references is different in the PSoC6 that 4. Here is the function I extracted and adapted to the PSoC6 version so far:
// Reads the current supply voltage to determine battery level
byte BAS_ReadBatteryLevel()
{
int16 adcResult;
int32 mvolts;
uint32 sarControlReg;
uint8 batteryLevel;
/* Set the reference to 1.024V and enable reference bypass */
sarControlReg = ADC_SAR_CTRL_REG & ~ADC_VREF_MASK;
ADC_SAR_CTRL_REG = sarControlReg | ADC_VREF_INTERNAL1024BYPASSED;
/* 25 ms delay for reference capacitor to charge */
CyDelay(25u);
/* Set the reference to VDD and disable reference bypass */
sarControlReg = ADC_SAR_CTRL_REG & ~ADC_VREF_MASK;
ADC_SAR_CTRL_REG = sarControlReg | ADC_VREF_VDDA;
/* Perform a measurement. Store this value in Vref. */
CyDelay(1u);
ADC_StartConvert();
ADC_IsEndConversion(ADC_WAIT_FOR_RESULT);
/* Set the reference to 1.024V and enable reference bypass */
sarControlReg = ADC_SAR_CTRL_REG & ~ADC_VREF_MASK;
ADC_SAR_CTRL_REG = sarControlReg | ADC_VREF_INTERNAL1024BYPASSED;
adcResult = ADC_GetResult16(ADC_BATTERY_CHANNEL);
/* Calculate input voltage by using ratio of ADC counts from reference
* and ADC Full Scale counts.
*/
mvolts = (1024 * 2048) / adcResult;
/* Convert battery level voltage to percentage using linear approximation
* divided to two sections according to typical performance of
* CR2033 battery specification:
* 3V - 100%
* 2.8V - 29%
* 2.0V - 0%
*/
if(mvolts < MEASURE_BATTERY_MIN)
{
batteryLevel = 0;
}
else if(mvolts < MEASURE_BATTERY_MID)
{
batteryLevel = (mvolts - MEASURE_BATTERY_MIN) * MEASURE_BATTERY_MID_PERCENT /
(MEASURE_BATTERY_MID - MEASURE_BATTERY_MIN);
}
else if(mvolts < MEASURE_BATTERY_MAX)
{
batteryLevel = MEASURE_BATTERY_MID_PERCENT +
(mvolts - MEASURE_BATTERY_MID) * (100 - MEASURE_BATTERY_MID_PERCENT) /
(MEASURE_BATTERY_MAX - MEASURE_BATTERY_MID);
}
else
{
batteryLevel = CY_BLE_BAS_MAX_BATTERY_LEVEL_VALUE;
}
return batteryLevel;
}
The constants ADC_SAR_CTRL_REG, ADC_VREF_MASK, and ADC_VREF_INTERNAL1024BYPASSED don't appear to exist on the PSoC6 version of the ADC. Here's my schematic setup for the ADC (I tried to make it as close as possible to the PSoC4 version settings):
Could someone provide some guidance on how I can adapt this code to work on the PSoC6? I'm using the CYBLE-416045-02 BLE Module on a custom PCB running off of a 3V CR2032 battery.
Show Less你好!
我知道 PSOC 6支持8080接口的TFT ,请问现在支持RGB接口吗?
谢谢!
Hi,
I have CY8C6347FMI system and I need to communicate with ICs in both 3.3V and 1.8V domains. Can I do it without level shifters, just by providing diffenet voltages to two different IO domains?
Show LessTrying to send a GATT notification with a payload of ~256 bytes between two BLE devices at 2Mbps. If the devices are at a distance where the initial attempt to send the notification fails (for example, if the frame check sequence is ``bad" as indicated by a sniffer), should a packet sniffer show attempts to retransmit the notification occurring with each successive connection event until transmission succeeds (i.e. frame check sequence ``good")? Is there any situation in which retransmission of a failed (i.e. unacknowledged) GATT notification does not occur during the very next device connection event (connection interval currently set to ~25ms), and if so, is there any firmware setting to control this time to retransmit?
Show LessWill PSoC Creator be supporting the CY8CKIT-062S* Family of Dev Boards in the Future....possible Time-line?
Hello Community
I am working on a PSoC 6 Project which implements the CY8C6347FMI-BUD53
Programming environment is the ModuxToolBox Version: 2.2.0
Pushbutton connected to P0_4 ( wakeup pin ), PMIC_ENABLE connected to P0_5 (wakeup out).
I want to shut down the VDDD Domain for sleep. only keeping vbackup running for later pushbutton interrupt.
I tested this code.
// VDDD is shutdown at PMIC_ENABLE disabled, and Enter Hibernate.
if (Cy_SysPm_PmicIsOutputEnabled())
{
Cy_SysPm_PmicUnlock();
Cy_SysPm_PmicDisable(CY_SYSPM_PMIC_POLARITY_HIGH);
}
resStat = Cy_SysPm_SystemEnterHibernate();
// not reach
if (resStat != CY_SYSPM_SUCCESS) {
printf("ERR Hibernate. ret:0x%x\r\n", resStat);
}
after that,
Pressing Pushbutton while PSoC6_MCU is System_hibernate_mode, but pmic_wakup_out :P0[5] is not changed to High,
so and MCU does not return to System_LP_mode .
Show Less