cancel
Showing results for 
Search instead for 
Did you mean: 

Sending counter with USART2 (NUCLEO)

bartekguzek
Associate II
Posted on May 20, 2015 at 18:58

Hello. I'm new to microcontrolles and I need to write a program that allows sending counter every 15 miliseconds through USART2. Counter should increase every second. I got the sending part. It's working but I can't get this counter and sending after 15 ms to work. Can anyone help?

4 REPLIES 4
Posted on May 21, 2015 at 03:23

Well you could configure the SysTick to fire every 1ms (1KHz), count every 15 entries to the ticker interrupt, and initiate the data send, count every 1000 entries to get your 1 second count.

ST makes dozens of STM32 parts, you'll need to be specific about which one.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
bartekguzek
Associate II
Posted on May 21, 2015 at 13:23

I have the sending part with delay but I can't figure out how to increment and sending int variable to terminal. I got NUCLEO 411RE

Posted on May 21, 2015 at 13:39

> I can't figure out how to increment

variable++;

> and sending int variable to terminal

char[10] buf;

unsigned int i;

sprintf(buf, ''%d\n'', variable);

for (i = 0; s[i] != '\0'; i++) {

  SendOneCharacterThroughUart(s[i]);

}

You might perhaps want to take some general C course and start with a somewhat simpler project - blinking a LED is usually the first one should start with.

JW

bartekguzek
Associate II
Posted on May 21, 2015 at 13:45

Well I wrote it wrong way. I know how to increment variables but I could not get sending it just right. I could only see <0> in terminal. Thank You for your help.