atmega16

How to use mutex in embedded C and Atmega 16?

六月ゝ 毕业季﹏ 提交于 2019-12-25 05:33:36
问题 I am writting a C code for Atmega Microcontroller and I want to use Mutex in it. What library to include? and how to implement the code? I want this Mutex to prevent a Timer interrupt from changing a variable during a function. 回答1: If you are using an RTOS or threading library, it almost certainly includes a mutex API, and if you are not then you don't need a mutex. In any case you cannot use a mutex in an interrupt handler in any case. Instead, if your timer variable is modified in the

How to convert Char into Float

拟墨画扇 提交于 2019-12-22 07:00:04
问题 How to convert an unsigned char value into a float or double in coding in AVR studio 4.? Please help I am a beginner, my question may sound stupid too :/ Like I have got a char keyPressed and I have printed it on the screen using lcd_gotoxy(0,0); lcd_puts (keyPressed); Now I want to use this value to calculate something.. How to convert it into float or double? please help 回答1: if you want for example character 'a' as 65.0 in float then the way to do this is unsigned char c='a'; float f=

How to use a variable as a parameter in a function that only suports constant expresssion

僤鯓⒐⒋嵵緔 提交于 2019-12-04 04:14:32
问题 I'm using this function: __delay_cycles(var); and I get the following error: Argument to _delay_cycles must be a constant expression Fair enough! But how can I bypass this? I have to delay my program with a different value every time. I receive my data from RS232 and I sore it in an int variable. I have to use this function and I can't modify its structure. I'm using AtMega16. 回答1: One suggestion that immediately springs to mind is to call __delay_cycles() with a constant argument, but do it

How to use a variable as a parameter in a function that only suports constant expresssion

旧城冷巷雨未停 提交于 2019-12-02 00:01:17
I'm using this function: __delay_cycles(var); and I get the following error: Argument to _delay_cycles must be a constant expression Fair enough! But how can I bypass this? I have to delay my program with a different value every time. I receive my data from RS232 and I sore it in an int variable. I have to use this function and I can't modify its structure. I'm using AtMega16. One suggestion that immediately springs to mind is to call __delay_cycles() with a constant argument, but do it in a loop, and vary the number of loop iterations. The loop will add some overhead, so if you need precision