- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey All
Wishing all of you and your families a very happy and prosperous new year in advance !!!
Anyone one working or has worked on UART? I need a task to be accomplished as below:
- PSoC4 should receive a character string and store it in an array.
- The programming should be interrupt based, specially with UART Rx interrupt and no delays included.
For example, let us assume I am receiving a character string "OK\n". On receiving the entire string, I should come to know that the entire string has been received. I will compare that string with a setpoint string "OK\n". If both match, an LED should blink.
Regards
Shaunak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a UART Rx project in example projects, the Rx ISR is
enabled in properties, however in the project itself the ISR is not
"doing anything". Should be simple to add your code into that
ISR (there are place holders for your code so it does not get over-
written on compile, example below). Remember to declare global
variables volatile that are used in your ISR.
/* User code required at start of ISR */
/* `#START UART_1_RXISR_START` */
/* `#END` */
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The last character of the string is "\n" which is 0x0a in ASCII. When you buffer your string (could be a circular buffer) you can signal the controlling program that a complete string has arrived.
-Mark begin of string
-Get character.
-When character is \n store 0x00 (end-of-string indicator) and signal "String received" else store character and loop
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Attached is example project of using UART for receiving commands. It utilizes non-blocking circular buffer to receive characters from UART Rx and split them into command messages when termination characters are found (0x0D and/or 0x0A). Project closely follows code posted by Bob Marlowe before. This demo shows how to change colors of the LED on the PSoC4 PioneerBoard.
Each received message has one "command" byte followed by "value string":
<cmd><value string> <\r> [<\n>], example: R255\n (set red LED to 255).
If one <cmd> byte is not enough for your commands, change it to 2 (or more).
Note that in this project UART rate was set to 230k to match speed of my Bluetooth HC-05 dongle. Change it to your own UART rate.
odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you everyone for giving solutions, though I am still not getting results. Please share a project that works with UART Receive interrupt configured such as an interrupt is generated each time a byte is received.
Thanks in advance.
Regards
Shaunak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The project Odissey1's posted contains some usable code, why don't you base on that or do you have got any other difficulties?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Shaunak,
in my project, interrupt is fired on every char received, but then characters go into receiving buffer for further processing when CPU is available. This way UART will not interrupt processes run by the CPU. This is the way simple UART input should operate...
If you don't need complex command structure, just replace processing portion in the above project with:
void ProcessCommandMsg(void)
{
//check received message for valid command
if (RB.RxStr == 'OK') // 'OK' string received..
{
\\do something...
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you all for support. I am sorry I replied late as I was having some other tasks on plate. Check my next post on this thread only, that discusses the GSM SIM300 related project.
Regards
Shaunak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bob, Dana and Odissy
Thanks for your support. Actually I am working on GSM SIM300 module interfacing with PSoC4 and developing project for sending and receiving messages on certain events. In this project, I need to take care of the timeout feature also. If any of all of us has worked on GSM SIM300, he/she can help me out with this. For those who have not worked on it, I have a SIM300 library for AVR microcontroller that I found while searching on internet. I believe we all can do the analogy of PSoC4 with AVR and have a complete GSM solution, which is never done as far as I know. Please find attached the entire project targetted to AVR based on C language. The developer of the project is Mr. Avinash Gupta. Here is the link that explains the project:
http://extremeelectronics.co.in/avr-tutorials/sending-an-receiving-sms-using-sim300-gsm-module/
Please go through this project and let this thread be live through open discussion and development for GSM SIM300 with PSoC4.
Regards
Shaunak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can anyone please explain how to write UART receive interrupt service routine and clear the UART Rx FIFO not empty interrupt? Currently I am sending "AT" command to the GSM SIM300 Module and want to receive "OK" in return. But I am not getting desired results. When I debugged it, I came to know that my code does not come out of UART Interrupt service routine. Please find attached my project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Shaunak!
Just use
ch = UART_UartGetByte();
UART_ClearRxInterruptSource(UART_INTR_RX_NOT_EMPTY);
Dangerous is the use of a global variable named ch which can be overlooked/overwritten easily. Additionally it should be declared to be volatile since it is changed in an interrupt handler.
You write data to the LCD. This should not be done in an interrupt handler because you may run into troules later when the project grows: Writing to LCD contains some delays which will hinder any other interrupt to be handled until this interrupt finishes. That could be a remarkable time making other parts of the progem to fail.
Usually the structure of an interrupt-driven receiver just reads-off the character and saves it in a buffer, clearing the interrupt and optionally setting a flag indicating a char received or found an end-of-message,. In the main-loop the flags are checked and acted upon them.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bob!
Thank you. It works now as per your suggestions.
Regards
Shaunak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Shaunak, you are always welcome!
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi people.
In first time sorry to write this question in this post. I am newly
1º) how do i open new thread?
2º) my question is: I try to communicate (In basic form) the UART block with the Hyperterminal. if I put UART_1_UartPutString("Ejemplo") I recive (in Hyperterminal) ASCII noise. No the word Ejemplo
then how i solve this?
very thanks for your patience and time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum!
Check the baud-rate selected for HyperTerminal and your UART, must be the same.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Has the Hyperterminal program got a baud selection? Can you post your complete project, 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.
And please tell us which board exactly you use.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I follow the steps in element14 web (USB-UART utility proyect)
and the same result, noise ascii.
I download the zip and programed it into the board, the echo program work bad ( if I push the number 5 in the keyboard, appear a triangle simbol)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you post your complete project, 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.
And please tell us which board exactly you use.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My intention is when i push SW2 button the LED ( included in the board) it turn on and at the same time I wanna see in the terminal some text.Also put some character by keyboard (and receive echos like feedback)
Programming started for device: 'PSoC 4200 CY8C4245AX*-483
PD:I Sorry by dirt code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I asked for the board, not for the chip (which I could take from the project).
I assume you are using a CY8CKIT-042 Pioneer kit.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The OutputString should be a bit more generous, use [20] to be on the safe side.
You read from UART outside of the "if (switched pressed) but a character received != 0 is not saved and will get overwritten.
The switch will read 1 when not pressed and 0 when pressed.
So the logic is that your 35678 is printed over and over again
What external connections did you make? You have to provide 2 wires to connect to the KitProg part on the board.
You need to enable interrupts globally (CyGlobalIntEnable) when using PrintString()
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes, CY8CKIT-042 Pionner Kit, and Creator3.3, Win 10.
Very Thanks for your time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi bob..
Very thanks for you collaboration , with out you will be impossible.
thanks for your time and patience...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, you are always welcome!
The "noise" you see at the screen of PuTTY comes from the open UART-bridge Rx input, so when the chip runs more noise is produced.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PuTTY and Hyperterminal both just display what they get. When there is a difference in the programs it must be in the setup of one of these programs.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys!
How to implement an check 'OK' string if response is arrived actually to my cypress?
MAIN
uint32 rxData;
UART_Start(); // ZigBee module
PWM_Start();
UART_ClearRxBuffer();
UART_PutString("AT\n\r");
FOR
rxData = UART_GetChar();
if(rxData){
CyDelay(2000);
PWM_Stop(); //control LED status
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Some of the posts at the beginning of this thread walk through/explain how to do it using the example project