- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
I would like to connect my dev psoc 5lp to the PC. Using Hyperterminal to input a number(interger) then do something on that number (convert to another number) the output it back to the PC. Is anyone here can help me with the template code? I've been looking into the uart datasheet but only template codes for TX,RX, and half size available.
Thank you in advance,
Cheers.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Easiest would be to use the USBUART component, no voltage-driver problems, no cable/wiring problems. Just use on PC-side the emulated COM-port. There are some example projects for USBUART, just right-click on the component on the schematic or in the catalog and select "Find Example Project".
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@BigD
check previous post and UART project attached
http://www.cypress.com/?app=forum&id=4749&rID=105248
odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you guys,
I managed to get an example code that uses USBUART to control an LED's intensity. I will give it a try later to use the actual UART following Bob's example code.You guys are very helpful!
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
...and you are always welcome!
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I notice in this isr that there are several statements such as :
UART_1_rxBuffer[UART_1_rxBufferWrite] = UART_1_RXDATA_REG;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum, Joe.
Best practice is always to post your complete project here, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi Joe,
From the 1st impression, seems like you had couple of typos there where using "I" instead of "i" in your for loop.
seconds...you just need to use the funciton "UART_IsReady()" to check whether the UART is ready to transfer the next data or not.
But as Bob said, its better to post the whole project here then we can all help you out.
Cheers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks guys.
The loop code here isn't the real code. Just quickly typed.
Bob. I have to remove company code then Ill send tomorrow.
But still my question remains. What triggers the interrupt and is the ISR that is triggered the one in the UART int file?
By reading the datasheet it would seem that each arriving character triggers a separate interrupt. is this correct?
If so, I think what I am seeing is not the first but the last char sent. The loop is overwriting the first position every time and not advancing. So it would seem that the loop is the problem and what I need is a counter and a point to start it from.
BigD. I couldn't find any UART IS Ready() function.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi. Here is attached project.
I simplified it a lot.
Mostly all is in the UART Interrupt file.
It polls a Modbus device for a register.
The device returns the message 04 03 02 00 00 74 44
The UART stores the data but when I try to retrieve it from the rxBuffer, First time it is polled, the info is correct. each additional time the information is incremented and placed in the wrong register of the DataIn registers.
How do I stop this incrementation??
Also there is a timer on the Top design.
Its purpose is to count serial bus pulses to determine if the bus is idle for a specific time.
It should enable when the bus goes high and interrupt after a specific time.
If the bus goes low it should reset the timer.
Is it configured ok?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the file UART_1_INT.c near line 180 you question the variable i outside of the loop. Per definition the value is not defined.
The stubs you use for UART are called everytime a character is received, so processing some characters at that point is not correct.
The interrupt for the PWM tc signal needs some modification:
Set the interrupt mode to "Rising Edge"
In the interrupt handler read the status of the PWM to clear the tc flag, look at the datasheet.
If you are expecting to receive a defined number of characters you may query UART_GetRxBufferSize() and act accordingly without using any interrupt.
Personally I do not like to make modifications in the generated files, they might get lost occationally. Have a look at the isr_StartEx() functions and the declarations using CY_ISR_PROTO() and CY_ISR() in the System Reference Guide which you find using Creator's "Help" menu.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This might help -
http://www.cypress.com/?rID=38267 AN54460
CY_ISR_PROTO(MyIntFunc); // Prototype declaration
then
CY_ISR(MyIntFunc) // Interrupt function definition
{
// Place code here
}
In initialization part of the program
isr_StartEX(MyIntFunc); // Start Interrupt with my handler
CY_ISR-macro have a look into the "System Reference Guide" under Help -> Documentation.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi. Thank you for the reply.
The problem seems to have been that the rx buffer needed to be cleared outside of the interrupt so I cleared it at the poll request. Works fine now.
But my questions about the timer and what exactly initiates the interrupt still need to be addressed.
I under stand and use the CYPROTO already.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"But my questions about the timer and what exactly initiates the interrupt still need to be addressed."
Can you please precise your question?
The timer itself does not generate an interrupt, instead the signal of the timer may be connected to an isr component.
You connected an isr to the tc output. When changing the isr's mode to "rising edge" it should work correctly.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"But my questions about the timer and what exactly initiates the interrupt still need to be addressed."
The Tc output of timer triggers the external ISR, in your case named DeadSpaceTimer, per the following
description of the Tc output in the datasheet -
So when the timer completes a period it fires the interrupt for you letting you know
it completed its timeout. Note you have timer configured in one shot mode, so you
would need to restart the timer to generate another timeout.
Regards, Dana.