2015-09-15 05:43 AM
i am currently working on the usart example of stm32f07
however this example sends only one string i wanted to know how to send two strings at different press of buttons #stm-32f072015-09-15 06:01 AM
Have the IRQ Handler feed the output from a FIFO buffer (aka ring buffer, google if unfamiliar), rather than deal with the string directly, and push the strings into the FIFO buffer.
You could do it without interrupts too.2015-09-15 09:21 AM
could you please send me the code
i know that would be a piece of cake for u and can u recommend me a book that i can read so that i can understand stm programming better2015-09-15 09:23 AM
i was actually working on making a calculator by accepting data through usart Rx and displaying the options via Tx.
2015-09-15 11:57 AM
Yes, but doing your homework doesn't advance my projects.
Geoff Brown has a good breakdown of STM32 peripherals/functionhttp://www.cs.indiana.edu/~geobrown/book.pdf
Joseph Yiu has a good book on the Cortex-M0http://www.amazon.com/The-Definitive-Guide-ARM-Cortex-M0/dp/0123854776
Some things like strings, buffering, interrupts and FIFOs are more universal in application, and not specific to STM32 uses. Perhaps some Computer Science texts would be more applicable there.2015-09-15 11:25 PM
can u atleast help me with the buffer please.
ive been stuck on this for the past 3 days as i have limited knowledge on c programs2015-09-16 07:35 AM
Hi,
you have plenty of example of circular/ring buffer on the internet since it is a wide used technic in drivers or communication. Basically, you need a pointer for the head, tail and end of the buffer. You add bytes with the head pointer and read with the tail pointer. If a pointer go pass the end you set it back to the start. If the head go higher than the tail you have an overflow error. Here is how I am declaring mine usually.uint8_t RxCircularBuffer[RX_CIRCULAR_BUFFER_LENGHT] = {0};
uint8_t* RxTail = &RxCircularBuffer[0];
uint8_t* RxHead = &RxCircularBuffer[0];
uint8_t* const RxStart = &RxCircularBuffer[0];
uint8_t* const RxEnd = &RxCircularBuffer[RX_CIRCULAR_BUFFER_LENGHT - 1];
I would have a look to UART with DMA used also. They are giving you more information on continuous communication.
I am sure clive1 wants to help you but it is best if you find your way out with some cues. And moreover , the poor guy cannot provide codes for everyone :(
2015-09-16 08:05 AM
FIFO buffering example, bottom end of first page, [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/UART%20example%20code%20for%20STM32F0&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F]this thread.
2015-09-30 02:54 AM
2015-09-30 03:09 AM
Seem to be a couple of issues here, will review more fully later.
Use if while() when if () would be appropriate Strings are 'const' not 'volatile' in this context String output could be in a subroutine, should iterate until the last NUL character has been seen rather than sizeof(), this would allow it to be generic rather than hard coded. The loops waiting for input should look for RXNE to be set high, ie there's a character waiting. The values read will be ASCII digits, you might want to read more than one, and then convert to binary, either by subtracting '0', or using atoi() or sscanf(). When writing out the answer you'll need to convert back to ASCII, which could now be additional digits, consider itoa() or sprintf() to create the string, and then calling string output subroutine. I don't understand the button usage.void OutString(char *s)
{
while(*s) // Not NUL
{
if (USART_GetFlagStatus(USART1, USART_FLAG_TXE) != RESET) // if it's empty
USART_SendData(USART1, *s++); // Out char, and advance
}
}