PSoC™ 5, 3 & 1 Forum Discussions
Hello,
I am learning to use ARM MCUs and I want to make a stack monitor. I managed with filling it, monitor it ecc, but I want to start to fill it from a proper unused location without knowing the r13 value in debug. So I just need to implement a way to store the r13 somewhere in the code and using it later. So far I was visually checking the content of r13 in debug and adjusting the code accordingly.
What is the right way of storing locally the content of SP (r13) register in a ARM Cortex M3?
Thank you,
Show LessI implemented a UART based bootloader on PSoC5LP kit having CY8C5888LTI-LP097 controller which stores the application on internal flash. Now I want the Bootloader to download the application on External Flash or EEPROM and Download the application from external memory upon a key press to the internal memory. IS it possible ? if yes then guide me how to proceed.
Show LessMy environment is CY8CKIT-059 PSoC 5LP Prototyping Kit and PSoC Creator 4.2 on Windows 10.
I want to send a 32bit value from CPU(C lang) to Datapath.
First of all, I created a sending program(OneDrive) by interrupt and it works(See sreg_out.cysym in an archived file).
And I tryed to make this program correspond to DMA, but it is not successful currently.
#include "project.h"
const uint32_t patterns[] = {
0b11111111000000001111111100000000,
0b11110000111100001111000011110000,
0b11001100110011001100110011001100,
0b10101010101010101010101010101010,0b11001100110011001100110011001100,
0b11110000111100001111000011110000,
};uint8_t send_buffer[2][24];
/* Defines for sreg_dma */
#define sreg_dma_BYTES_PER_BURST 4
#define sreg_dma_REQUEST_PER_BURST 1
#define sreg_dma_SRC_BASE (CYDEV_SRAM_BASE)
#define sreg_dma_DST_BASE (CYDEV_PERIPH_BASE)/* Variable declarations for sreg_dma */
/* Move these variable declarations to the top of the function */
uint8 sreg_dma_Chan;
uint8 sreg_dma_TD[2];void InitDma()
{
/* DMA Configuration for sreg_dma */
sreg_dma_Chan = sreg_dma_DmaInitialize(sreg_dma_BYTES_PER_BURST, sreg_dma_REQUEST_PER_BURST,
HI16(sreg_dma_SRC_BASE), HI16(sreg_dma_DST_BASE));
sreg_dma_TD[0] = CyDmaTdAllocate();
sreg_dma_TD[1] = CyDmaTdAllocate();
CyDmaTdSetConfiguration(sreg_dma_TD[0], 24, sreg_dma_TD[1], sreg_dma__TD_TERMOUT_EN | CY_DMA_TD_INC_SRC_ADR);
CyDmaTdSetConfiguration(sreg_dma_TD[1], 24, sreg_dma_TD[0], sreg_dma__TD_TERMOUT_EN | CY_DMA_TD_INC_SRC_ADR);
CyDmaTdSetAddress(sreg_dma_TD[0], LO16((uint32)send_buffer[0]), LO16((uint32)sreg_out_DMA_PTR));
CyDmaTdSetAddress(sreg_dma_TD[1], LO16((uint32)send_buffer[1]), LO16((uint32)sreg_out_DMA_PTR));
CyDmaChSetInitialTd(sreg_dma_Chan, sreg_dma_TD[0]);
CyDmaChEnable(sreg_dma_Chan, 1);
}CY_ISR(OnInterruptSO)
{
}int main(void)
{
CyGlobalIntEnable;
memcpy(send_buffer[0], patterns, 24);
memcpy(send_buffer[1], patterns, 24);InitDma();
//so_isr_StartEx(OnInterruptSO);for(;;)
{
}
}
According to this discussion, PSoC 5LP seems that it supports 32bit DMA transferring. However, I don't make much progress because there is no concrete exsamples(Official documents detailed that 8bit DMA transfer).
Please tell me if you know a good solution.
Show LessHi. good night. How can I program the psoc 5lp kit, in assembly language?
Hi,
I have CY3295-mtk manufacturing kit and it has CY8C3866AXI-040 MCU on it. Manufacturing kit has SWD interface to program it's MCU. I have CY8CKIT-059 PSoC® 5LP Prototyping Kit and it has programmer and SWD pins (such as SWDIO SWDCLK etc.). Can I just connect my manufacturing kit's SWD connector to prototype kit's swd pins to program mtk? I have the hex file. If so, can anyone share me pinout and how to connect them?
Hi, I tried to use this with Creator 4.2, errors thats its missing components, component update
did not cure.
Missing components (which are in 4.0) are
Dependencies were set correctly.
Seems a shame this is not kept up to date, very useful component.
https://www.cypress.com/validated-components
As stated on that web page validated components.
Regards, Dana.
Show LessHi,
The DisplayPort AUX signal is half duplex.
We are considering converting that half duplex to full duplex.
So we are considering using PSoC, is it feasible?
Have there been any such cases in the past?
I think PSoC4 if it doesn't need UDB resources,
Do you think that conversion of DisplayPort will require UDB?
Regards,
Show LessSorry for the nub question, but i never use DMA before and want to receive the 36 bytes from DMX data stream..
I try to use UART interrupt for update PWM registers by that fast way
const unsigned int PWMA[40]=
{
5000 ,//PWMA[0] NOT ACTUALLY, DUMMY
5000 ,//PWMA[0] NOT ACTUALLY, DUMMY
5000 ,//PWMA[0] NOT ACTUALLY, DUMMY
5000 ,//PWMA[0] NOT ACTUALLY, DUMMY
PWM_1_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_1_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_2_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_2_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_3_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_3_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_4_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_4_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_5_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_5_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_6_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_6_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_7_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_7_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_8_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_8_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_9_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_9_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_10_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_10_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_11_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_11_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_12_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_12_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_13_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_13_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_14_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_14_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_15_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_15_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_16_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_16_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_17_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_17_PWMUDB_sP8_pwmdp_u0__D1_REG ,
PWM_18_PWMUDB_sP8_pwmdp_u0__D0_REG ,
PWM_18_PWMUDB_sP8_pwmdp_u0__D1_REG
};
CY_ISR(UAR_INT)
{
if(ADRR<37)
{
if(DMADDR[dmxcount]==dmxcount) CY_SET_REG8( (PWMA[dmxcount]),UART_RXDATA_REG);
ADRR++;
}
dmxcount++;
}
But anyway it no so fast and after correct receiving of 9 bytes I lost bytes 10, 11 ..etc ,,
So I connect the DMA component to break interrupt, and configure
CY_ISR(UAR_INT)
{
Received[dmxcount]=UART_RXDATA_REG;
dmxcount++;
}
void DMA_Config()
{
/* Defines for DMA_1 */
#define DMA_1_BYTES_PER_BURST 36
#define DMA_1_REQUEST_PER_BURST 1
#define DMA_1_SRC_BASE (CYDEV_SRAM_BASE)
#define DMA_1_DST_BASE (CYDEV_PERIPH_BASE)
/* Variable declarations for DMA_1 */
/* Move these variable declarations to the top of the function */
uint8 DMA_1_Chan;
uint8 DMA_1_TD[1];
/* DMA Configuration for DMA_1 */
DMA_1_Chan = DMA_1_DmaInitialize(DMA_1_BYTES_PER_BURST, DMA_1_REQUEST_PER_BURST, HI16(DMA_1_SRC_BASE), HI16(DMA_1_DST_BASE));
DMA_1_TD[0] = CyDmaTdAllocate();
CyDmaTdSetConfiguration(DMA_1_TD[0], 2, DMA_1_TD[0], 0);
CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint32)Received[dmxcount]), LO16((uint32) (PWMA[dmxcount])));
CyDmaChSetInitialTd(DMA_1_Chan, DMA_1_TD[0]);
CyDmaChEnable(DMA_1_Chan, 1);
}
But nothing care, all of the PWM outputs are 0..
Show LessThe kitProg that I use is CY8C5868LTI-LP039 and target is CY8C5888LTI-LP097. When I connect the J6 USB port to my PC, the device is not detected. whereas when I Connect the KITPROG USB to PC, it works . Could you please explain why? As I am new to PSoc .
Show LessHi all,
I'm coming across a problem with my firmware for a USB Mouse+Keyboard composite device using the USBFS component. The device is self-powered rather than bus powered. Long story short, I'm sometimes having problems gracefully handling USB disconnect/reconnect. I manage to connect normally when I plug to a host PC, but sometimes I am unable to connect/reconnect unless I fully power cycle the PSoC. Windows will usually just throw a "USB Device has malfunctioned" pop-up at me. Sometimes it will just show the composite device in the device manager with a little yellow marker on it denoting that "The Device Could Not Start".
I had thought this code working but something must be wrong that I'm not seeing. My USB functions are below with descriptions, maybe someone will see something I'm not catching:
I have two variables in my usb source file that serve as flags used in the code below:
//Connection to host has been established
volatile static bool USB_IsConnected = false;
//VUSB has been detected
static bool USB_VBusPresent = false;
I call USBFS_Start() only once, when the PSoC first starts. To actually begin exchanging data with the host, I call USB_Init():
/** USB_Init
* - Attempts to begin communication with USB host
* - Returns bGetConfiguration status.
*/
static bool USB_Init (void){
USBFS_InitComponent(0,USBFS_DWR_POWER_OPERATION);
CyDelay(50);
if (USBFS_bGetConfiguration()){
USBFS_LoadInEP(USB_KEYBOARD_ENDPOINT_NUM,(uint8_t *)USB_KeyboardDataBuff,USB_KEYBOARD_DATA_SIZE);
USBFS_LoadInEP(USB_MOUSE_ENDPOINT_NUM,(uint8_t *)USB_MouseDataBuff,USB_MOUSE_DATA_SIZE);
return true;
}
return false;
}
My main USB function is Process_USB():
/** Process_USB
* - Handles USB Connection/Disconnection
* - Handles Endpoint data exchange for Mouse+Keyboard
*/
void Process_USB (void){
static bool is_connected = false, conn_prev = false;
static keyboard_led_t led_data_prev;
is_connected = USB_UpdateConnection();
if (is_connected){
/*We are currently connected*/
if (USBFS_bGetEPAckState(USB_MOUSE_ENDPOINT_NUM)){
/*Mouse Data Updated Here - Snipped*/}
if (USBFS_bGetEPAckState(USB_KEYBOARD_ENDPOINT_NUM)){
/*Keyboard Data Updated Here - Snipped*/
}
} else if (conn_prev) {
/*Connection lost, terminate EPs*/
USBFS_TerminateEP(USB_KEYBOARD_ENDPOINT_NUM);
USBFS_TerminateEP(USB_MOUSE_ENDPOINT_NUM);
}
conn_prev = is_connected;
LED_2_Write(is_connected);
}
The main thing I want to point out is the call to USB_UpdateConnection, which governs the behavior of this function. If we are connected, it will update endpoints and exhange data with the host. If not, the endpoints are terminated, to be restarted in USB_Init() upon reconnection.
In order to track the state of my USB connection. I am regularly calling my USB_UpdateConnection() function every time I enter Process_USB(). When VBUS is present, and we are not currently enumerated with the host, this function will call USB_Init() to attempt to enumerate. If it fails, it will try again on the next time through. If VBUS is not present, the flags will be set as such to begin calling USB_Init() once VBUS returns.
/** USB_UpdateConnection
* - Handles USB Enumeration when VBUS is detected
* - returns: 0 -> No VBUS/Host detected
* 1 -> Enumerated with host
*/
static bool USB_UpdateConnection (void){
static bool connected = false;
if (USBFS_VBusPresent() == USBFS_VBUS_VALID){
/*VBUS is present*/
USB_VBusPresent = true;
if (!connected){
/*New connection, Enumerate*/
#ifdef DEBUG_USB
DBG_UART_PutStringConst("USB: CONNECTING\r\n");
#endif
if (USB_Init()){
#ifdef DEBUG_USB
DBG_UART_PutStringConst("USB: CONNECTED\r\n");
#endif
USB_IsConnected = true;
connected = true;
}
}
} else {
/*No VBUS Present*/
if (connected){
/*Disconnected*/
#ifdef DEBUG_USB
DBG_UART_PutStringConst("USB: DISCONNECT\r\n");
#endif
connected = false;
}
USB_IsConnected = false;
USB_VBusPresent = false;
connected = false;
}
if (!USB_IsConnected && USB_VBusPresent){
/*No Data Connection, but VBus still present*/
#ifdef DEBUG_USB
DBG_UART_PutStringConst("USB: NO HOST\r\n");
#endif
connected = false;
}
return connected;
}
I also have an activity check I am calling every 100mS to keep an eye on USB activity to trigger a reconnect:
/** USB_Timeout_Tick
* - Checks USB activity every 500mS
* - Detects when no activity has occurred, denoting a connection problem,
* and sets USB_IsConnected to match.
*/
void USB_Timeout_Tick (void){
static uint8_t counter = 0;
if (USB_IsConnected){
if (++counter >= USB_DATA_TIMEOUT_COUNT){
if (!USBFS_CheckActivity()){
#ifdef DEBUG_USB
DBG_UART_PutStringConst("USB: ACT TIMEOUT\r\n");
#endif
USB_IsConnected = false;
}
counter = 0;
}
} else {
counter = 0;
}
}
This counter will trigger an activity check every 500mS. If no activity on the bus, it will flag as disconnected, and will attempt to reconnect in USB_UpdateConnection(). In my case, I haven't seen this actually trigger in this instance, but I figured I'd include it for completeness.
For some reason this setup is not 100% reliable to make a USB connection to a host (I've tested both my Windows 7 PC and a Raspberry Pi). It works most of the time, but will for some reason I can't determine just get stuck calling USB_Init() and USBFS_bGetConfiguration() simply never returns true. It then spends all eternity attempting to enumerate and not being able to do so.
Does anyone out there maybe have some tips of what I could try here to make connection/reconnection to the host a more reliable process? I can't seem to figure out the "Trigger" for what's causing it to sometimes just not work. Even writing this up, this same code is now suddenly working, but it's only a matter of time before I start having problems with it again.
Show Less