Tagged Questions
2
votes
2answers
134 views
Understanding volatile class fields in AVR C++ programs
I'm having some confusion about what members to declare volatile in a program I'm writing in C++ for an AVR microcontroller, with interrupts. When it's plain C it makes sense - the compiler doesn't ...
1
vote
1answer
36 views
How to flash error if a macro is not defined in program
I want my program to flash compile time error like "LCD_PORT not defined" if it is not defined in program itself. For that I modified the header file like this
...
1
vote
0answers
71 views
How to get rid of “Invalid opcode 0x002A at PC=0x004” in ISIS Proteus?
I have used ATmega 8 and have simulated a circuit to use interrupts, when i give an external interrupt i.e. when a push button is pressed all the LEDs connected to PORTB supposed to be lit up, but i ...
1
vote
1answer
93 views
AVR Time Delay without Arduino Libraries
Trying to figure out how to do something like delay() in Arduino but just for straight AVR code. What's the typical way to do waits and such on AVR chips?
7
votes
2answers
264 views
Program AVR EEPROM directly from C source
When you include the following code in an AVR C source, you can apparently directly program the fuses, without the need for an extra command or .hex file:
...
5
votes
2answers
220 views
Decoding multiple quadrature rotary encoders
Scenario
I have 4 ACZ16 quadrature rotary encoders connected to GPIO Port D on an ATMega168P. I am only trying to extract rotation direction from them. Position is irrelevant, and it is guaranteed ...
1
vote
2answers
284 views
AVR GCC : Global / Static Array not getting initialized properly
Im having problem with global arrays in my C code. What i am trying to do is to use a display buffer (array of 8 uint8_t with each uint8_t representing a row) to light up the leds in 8x8 led matrix ...
2
votes
1answer
170 views
ATMega168 SPI tranmission will not start
Scenario
I have an ATMega168 using an external 10MHz crystal. The DIV/8 fuse bit is not set. The processor takes the outputs from 4 quadrature rotary encoders. Their rotation direction information is ...
4
votes
2answers
129 views
Turn on and let LED stay on if value is over threshold in main while-loop
I'm totally stuck with this rather trivial (?) problem, i've got this pseudo code that i will convert to C (i'm programming a ATmega8 MCU):
...
1
vote
2answers
405 views
Measuring 32V using ADC of Atmega8
I'm trying to measure the battery voltage of 30V using the ADC of an AVR Atmega8, AVCC is connected to 5V.
I connected a suitable voltage divider: R1 is 270k, R2 is 10k. The result I get is wrong at ...
3
votes
1answer
165 views
PROGMEM data vs. calculated data
On an arduino project I'm working on (ATMega328 at the moment) I have a bunch of vector distance data that I need to use for various pixels in a matrix.
It's a relatively simple calculation:
...
25
votes
2answers
748 views
Who receives the value returned by main()?
I know that in computers, value returned by the main() function is received by the operating system.
But, what happens in the ...
1
vote
1answer
536 views
Converting from int to string for AVR ATmega32
I am trying to read data from the ADC and display it on a HD44870 compatible LCD with an ATmega32. As the data from the ADC is a 10-bit unsigned integer, the LCD expects a string, some conversion is ...
6
votes
1answer
250 views
Time Base ISR Concurrency
This is sort of a "classic" problem, and I think I have a solution, but I want to vet it with this community. I am building a project using the ATtiny88 microcontroller, and I'm programming in ...
3
votes
2answers
276 views
avr attiny84: wrong delay
I'm pretty new to avr programming. I'm facing a strange problem that I can't solve so far.
I've wrote a simple code:
...
3
votes
2answers
297 views
Can't set to Fast PWM OCRA mode
Trying to have Fast PWM mode when TOP == ORCA.
Works fine with OCA toggle (measuring correct frequency), but doesn't work in ...
1
vote
1answer
288 views
UART Communication Issues
I am using a UART to communicate with RS232 on a Roving Networks RN-42 SM bluetooth module. I have the transmitter and receiver connected to a logic analyzer.
The issue that I am having is that my ...
1
vote
2answers
503 views
Interfacing AVR microcontroller to ADC, waveform generator and other peripherals
I am doing first project with AVR microcontroller ATmega32-A.
In this project I am interfacing with ADC (AD7798), waveform Generator (AD9833), Multiplexer, Capacitive sensor, Demodulator. I have ...
1
vote
1answer
153 views
Fast PWM and Atmega1280 problem
Hello I have some problems to understand how to bind a Timer to a Pin and because of that my code isn't running...
...
-4
votes
2answers
189 views
problem with reading values in case
I am using ATmega32-A microcontroller and CodeVisionAVR compiler. I am able to read values from an AD7798 external ADC successfully. I am also generating wave from with an AD9833 using SPI ...
4
votes
1answer
221 views
Formula calculation and printing negative value.
I am successfully reading external ADC value using ATmega32-A.
...
1
vote
2answers
292 views
Analog to digital conversion
I am using an Atmega32-A microcontroller and an AD7798 external ADC. I am able to set the ADC registers and read back ADC values. I have written the following code:
...
0
votes
1answer
136 views
Loop is executing infinite times
I am working with an ATmega32-A microcontroller. Using USART communication, I am displaying data on monitor and am using switch case to select different commands. In one of the commands I have written ...
2
votes
1answer
183 views
Problem with while loop
I am trying to read external ADC AD7798 values using ATmega32-A controller. In the datasheet, Status register Bit 7 (SR7) indicates the conversion is finished or ...
8
votes
3answers
940 views
What is bit banging
I am new to microcontroller programming. I am using ATmega32-A controller and CodeVisionAVR compiler. I am using the waveform generator(AD9833) to generate a sinewave signal using SPI communication. I ...
1
vote
1answer
117 views
problem with printing function return value
I am new to programming. I have small doubt, I know this is simple question but I am confused. I have the following function:
...
1
vote
2answers
279 views
how to check SPI signals
I am working with ATmega32-A micro controller. I am trying to read ADC (AD7798) values. I am setting ADC registers as shown below. Images also attached.
...
2
votes
4answers
478 views
ADC registers setup using spi communication
I'm new to microcontrollers - I'm trying to read external ADC values from an AD7798 ADC using SPI communication.
Initially I have to setup some ADC registers - some registers are not configured. To ...
8
votes
5answers
508 views
What's wrong with this casting in C code for AVR?
I defined two variables:
uint8_t a[2];
uint16_t b;
Next I want to use a as variable of type ...
2
votes
2answers
201 views
Microcontrol port for lcd
Ihave modify an existing lcd library, it only works on DDRA for exmple if i change:
Update error Fixed:
I have found the error in the code assembly delay was too short for port B, C and D. by ...
0
votes
1answer
455 views
3
votes
2answers
671 views
Convert DS18B20 temperature to string
I want to convert DS18B20 temperature (4-bytes code from datasheet) to string with accuracy 0.1°C (like sprintf %.1f). AVR. C language (avr-gcc). I need for small ...
-1
votes
1answer
159 views
Loop across ports (avr)
I am trying to scan a key matrix that is 9 rows long. Currently my code is a bunch of if statements, one per row, and I would like it get it down to a small if loop. I don't think I can put PINB, ...
3
votes
1answer
1k views
How do I create a static library for the AVR Atmega328p?
I am attempting to create a library much like the Arduino in C.
I have tried in the past and although I have lost the code, I remember simply getting loads of undefined references to functions ...
2
votes
2answers
765 views
How to pass string for EEPROM write for ATMega32? (in the following code)
How could I pass a string for EEPROM write first and read in the code as:
...
1
vote
1answer
308 views
UC1698 based LCD driven by AVR
Ok so i've got a BTHQ128128 fstn display that i'm tryinf to drive via an ATMEGA128 AVR chip using gnu-c (avrlibc). Found some code on the interweb, but still not able to get the display to show ...
5
votes
2answers
685 views
Teensy USB Interrupts
I'm trying to learn about interrupts using one of the Teensy USB boards. It's got an AVR AT90USB1286 chip on it. I'm using the code below, and I'm expecting my ISR block to get called and periodically ...
2
votes
2answers
597 views
'keyboard from scratch' registering key presses
For my first hardware hack I'm taking a stab at a 'mechanical keyboard from scratch' (where scratch means individual components).
I plan to use a teensy++ board (16MHz) and was wondering about how to ...
3
votes
2answers
1k views
Macros V/S inline functions while programming for avr-gcc
I have been doing my first serious work of programming these days. I have been exposed to a lot of code by different developers. One thing I find confusing is how do these developers decide when to ...
8
votes
5answers
3k views
Start off with embedded C with ATmega32 (ATmega AVR series)
I have a ATmega32 board laying around and I figure it would be perfect to start off with microcontrollers. I once did some babbling in embedded C (thats when I got this board) but the flow was stopped ...