PSoC™ 5, 3 & 1 Forum Discussions
Hi all,
I am trying to calibrate resistive touch screen of a 3.5" TFT LCD using PSoC 5LP and emWin library.
I was able to use Touch_sample.c to verify touch detection and moved on to do touch calibration. I am using Touch_calibrate.c sample code from emWin but wasn't successful. I tried to debug and what looks like the code is stuck at while(TouchState.Pressed != 1) and doesn't seem to end the loop.
Any solutions with this regard would be very helpful.
I have attached the c code for reference.
Thanks and regards,
Shamili
Show LessDear Mdm/Sir,
I intend to configure Cy8C24894 to be USB2IIC bridge.
Here I may need to things
- How to configure the chip using PSoC designer?
- Where I can find USB2IIC library for my GUI development?
I think Cypress must have some tutorial or application notes for this application before.
Thanks for the sharing very much!
Thanks & Regards,
Chao
Show LessI am using the following code to setup a double-buffering scheme for the ADC. It appears that the DMA ISR is repeatedly being called rather than when 32 samples have been transferred. If I add the line: CyDmaClearPendingDrq(DMA_1_Chan); then it never gets called.
What could be wrong?
#include <project.h>
#include "adc_dma.h"
#include "idac.h"
#define NSAMPLES 32
#define TFR_CNT NSAMPLES * 2
#define DMA_BYTES_PER_BURST 2
#define DMA_REQUEST_PER_BURST 1
#define DMA_SRC_BASE (CYDEV_PERIPH_BASE)
#define DMA_DST_BASE (CYDEV_SRAM_BASE)
uint8 DMA_1_Chan; //TODO: use the int assigned in DMA_1_dma.h
uint8 DMA_1_TD[2];
uint16_t adc_buffer1[NSAMPLES] ={0};
uint16_t adc_buffer2[NSAMPLES] ={0};
//static volatile uint16_t total;
uint16_t adc_val = 0;
uint8 currentTD = 0;
uint16_t last_total;
void init_adc_dma(void) {
DMA_1_Chan = DMA_1_DmaInitialize(DMA_BYTES_PER_BURST, DMA_REQUEST_PER_BURST, HI16(DMA_SRC_BASE), HI16(DMA_DST_BASE));
DMA_1_TD[0] = CyDmaTdAllocate();
DMA_1_TD[1] = CyDmaTdAllocate();
CyDmaTdSetConfiguration(DMA_1_TD[0], TFR_CNT, DMA_1_TD[1],
TD_INC_DST_ADR | TD_AUTO_EXEC_NEXT | TD_TERMOUT0_EN | DMA_1__TD_TERMOUT_EN);
CyDmaTdSetConfiguration(DMA_1_TD[1], TFR_CNT, DMA_1_TD[0],
TD_INC_DST_ADR | TD_AUTO_EXEC_NEXT | TD_TERMOUT0_EN | DMA_1__TD_TERMOUT_EN);
CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint32)ADC_SAR_1_SAR_WRK0_PTR), LO16((uint32)&adc_buffer1[0]));
CyDmaTdSetAddress(DMA_1_TD[1], LO16((uint32)ADC_SAR_1_SAR_WRK0_PTR), LO16((uint32)&adc_buffer2[0]));
CyDmaChSetInitialTd(DMA_1_Chan, DMA_1_TD[0]);
CyDmaChEnable(DMA_1_Chan, 1);
}
CY_ISR(ISR_DMA_DONE_ADC)
{
CyDmaChStatus(DMA_1_Chan, ¤tTD, NULL);
//process adc_buffer2
if (currentTD == DMA_1_TD[0]) {
LED_BLUE_DR |= LED_BLUE_MASK; //Turn on LED
}
//process adc_buffer1
else if (currentTD == DMA_1_TD[1]) {
LED_BLUE_DR &= ~LED_BLUE_MASK; //Turn off LED
}
CyDmaClearPendingDrq(DMA_1_Chan); //ISR never gets called if this line is included
I am having trouble with SPI routine in my code. This code was ported over from a STM32 to PSOC and is almost running but I am having trouble with the SPI (which is integral to the project). The 5LP connects to a Radio module and sends/receives data and commands via spi.
It first sets spi to low rate to configure a couple of registers and then high rate. I have used DMA to get rid of inter-digit delays.
There is a little routine called "TestSPI()" in main that I call from various points in the code to check the SPI is working correctly. It works perfectly fine and gives expected results until line 100 (A while loop reading status register).
If I call TestSpi before this line it is fine, call it after line 100 and I get rubbish returned in TestSpi.
If I put a 100ms delay after the while statement then I get correct results, but of course I am not able to delay the code here when the application is running.
Thank you
Show LessHi,
I am planing a board with PSOC5LP and I would like to use JTAG configuration to program the PSOC.
Unfortunately, the connection to the programmer (MINI prog3) goes through several cables (and connectors) and the overall length will be long.
I think to use buffer to strengthen the signals but I see that there is no need in pull up/down so I do not know which initial state to set for each signal in the buffer input.
How should I connect the buffer? Which kind of buffers do you recommend?
Many thanks!
Show LessHi
I have a Atmel AT25080B EEPROM connected to a CY8C29666 on port 4.
I have written code for read status, Write data and Read data but i cannot get ti to work.
Does anyone have a code spinet they could share so I get this working.
Any help would be good.
I have included the code in notepad.
Thanks
Gord
Show LessI have a project where we are producing new "Remote" boards. We are using RS485 half duplex. The Master commands are always sent with a 1 set as the 9th bit (Mark).
The Remote UART (that I'm trying to set up) should completely ignore any data word that does not have a 1 as the 9th bit (Mark parity). This way each of the multiple remote boards will ignore any communications from the other remotes.
Only if the 9th bit is a 1 will the UART listen to the rest of the word. The rest of the word is the master command and the remote address. If the address matches the remote's address, set by DIP Switch, the remote processes the command.
Master word = 1yyyyxxxx, 1= 9th bit (Mark), yyyy =command (ie- 0100 = send buffered data), xxxx = remote address
RX
What do I use to have the UART look for the 1 in the 9th bit (mark) and ignore anything that is not a 1?
TX
I'm trying to understand how to control the Mark / Space parity bit before transmitting the data. If I'm reading correctly UART_CTRL_MARK, "Configures whether the parity bit during the next transaction (in Mark/Space parity mode) will be a 1 or 0."
I don't seem to understand the formatting. It looks like I should use UART_WriteControlRegister(UART_CTRL_MARK). How do I tell complete this and say whether I want the bit to be a 1 or a 0? Do I need to check the API control enable box in the UART configuration?
I'm just starting to learn a little C programming. I need basic detailed help from those smarter than I!! This is my first work with PSoC. I would welcome examples!
Right now I'm using the full duplex UART example program to try to understand how everything works. RS232 from my PC characters typed are echoing back to the PC. (115200 baud, 9 data bits, Mark / Space Parity, 1 stop bit, no flow) Notice that I'm transmitting the data twice. My intentions are to transmit one with the Mark parity set and one with Space parity set just so I can look on the scope and make sure I can see it working. I don't seem to know how to control the Mark/Space bit. Once I have this figured out, I can move on to the task above.
CY_ISR(RxIsr)
{
uint8 rxStatus;
uint8 rxData;
do
{
/* Read receiver status register */
rxStatus = UART_RXSTATUS_REG;
if((rxStatus & (UART_RX_STS_BREAK | UART_RX_STS_PAR_ERROR |
UART_RX_STS_STOP_ERROR | UART_RX_STS_OVERRUN)) != 0u)
{
/* ERROR handling. */
errorStatus |= rxStatus & ( UART_RX_STS_BREAK | UART_RX_STS_PAR_ERROR |
UART_RX_STS_STOP_ERROR | UART_RX_STS_OVERRUN);
}
if((rxStatus & UART_RX_STS_FIFO_NOTEMPTY) != 0u)
{
/* Read data from the RX data register */
rxData = UART_RXDATA_REG;
if(errorStatus == 0u)
{
/* Send data backward */
UART_WriteControlRegister(UART_CTRL_MARK);
UART_TXDATA_REG = rxData;
UART_TXDATA_REG = rxData;
}
}
}while((rxStatus & UART_RX_STS_FIFO_NOTEMPTY) != 0u);
Show LessHi All,
I am having an issue getting SPI communication to work. I am using the SPI peripheral in bidirectional mode attempting to interface with this chip. It seems like this should be simple enough as the chip has a single 16-bit command structure. However, when trying to send data, I see the SCLK signal, but I do not see the SDIO signal! It's just low the whole time. Here's a snapshot of the relevant code in my main loop with relevant code on line 61:
#include "project.h"
#include "I2C.h"
#include "MODBUS.h"
#include "MODBUS_Util.h"uint16 Heartbeat_LED_counter = 0;
void SysTickISRCallback(void)
{
Heartbeat_LED_counter++;
}int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
/***********************************************/
/* Custom Code to enable timeout for I2C hang */
CySysTickStart();
for (uint8 i = 0u; i < CY_SYS_SYST_NUM_OF_CALLBACKS; ++i)
{
if (CySysTickGetCallback(i) == NULL)
{
/* Set callback */
CySysTickSetCallback(i, SysTickISRCallback);
break;
}
}
/***********************************************/
/* Indicator LED ON During Setup */
Indicator_LED_OUT_1_Write(0x01);
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
MODBUS_Start();
I2C_Start();
SPI_Master_Start();
uint16 test_spi = 0b0010101001000000;
/* Flash Indicator LED OFF After Setup */
Indicator_LED_OUT_1_Write(0x00);
CyDelay(100);
Indicator_LED_OUT_1_Write(0x01);
CyDelay(100);
Indicator_LED_OUT_1_Write(0x00);
CyDelay(100);
Indicator_LED_OUT_1_Write(0x01);
CyDelay(100);
Indicator_LED_OUT_1_Write(0x00);
CyDelay(100);
CyWdtStart(CYWDT_1024_TICKS, CYWDT_LPMODE_NOCHANGE);
for(;;)
{
SPI_CS_REG_Write(0x00);
CyDelay(100);
SPI_Master_TxEnable();
SPI_Master_WriteTxData(test_spi);
uint8 status = SPI_Master_ReadTxStatus();
while(!(status & SPI_Master_STS_SPI_DONE))
{
status = SPI_Master_ReadTxStatus();
}
SPI_Master_TxDisable();
CyDelay(100);
SPI_CS_REG_Write(0x01);
CyDelay(500);
/* Place your application code here. */
if(MODBUS_Get_Message_Available())
{
MODBUS_Process_Msg();
}
/* Feed the WatchDog */
CyWdtClear();
/* Check Heartbeat LED */
if(Heartbeat_LED_counter >= 1000)
{
Heartbeat_LED_counter = 0;
Indicator_LED_OUT_2_Write(~Indicator_LED_OUT_2_Read());
}
}
}
I am very unsure what's going on, but I do know that if I switch to MOSI+MISO mode and assign MOSI to the same pin as SDIO it seems to at least try to send the data, but the chip doesn't seem to respond. The main problem is just not a hair or a breath of movement on the SDIO pin even though the SCLK signal is there and I called SPI_Master_TxEnable(). I don't know what else I have to do for it to work.
I have attached my project for reference. Also, please don't link me to a different thread. I have read so many and no one has answered my question. This thread gets linked all over the place and I swear to you I have already read it.
Show LessCreator 3.3 works great with my MiniProg3.
Creator 4.2 builds well, but won't program the target. ctrl F5 hangs Creator until I disconnect the USB from the MiniProg3. I can program the hex file using Programmer 3.28.1.
I'd stick with Creator 3.3, but there's no direct interrupt support for Status Registers in UDB documents.
All this is under Windows 7.
Show LessI am trying to send a integer in bytes from python to the PSoC to update the target position of our PID control. The PID control is meant to move the motor to its desired position. But every time I send a byte array from python to PSoC using uart and rx_interrupt, it will go back to zero. I don't know why is it the case and how can I fix this problem? I have attached my workspace and my python file below. I appreciate it so much if you can help me with it! Thank you so much!
Sincerely,
Caesar
Show Less