avr

avr timer1 16bit fast PWM

南楼画角 提交于 2021-02-10 23:13:09
问题 I am using an Atmega328p-pu. I am trying to use the timer 1 for both a 16 bit PWM as well as using the overflow inturrupt to increment a timer. My code is below, I also set the F_CPU to 8000000UL in the make file. I would like the to have a variable that counts up for a defined amount of time and then resets and continues. so far I would expect it to count up for 7.5 seconds. I believe I should have a clock frequency of 8 MHz, then with fast PWM with a 1 prescaler and ICR1 at 5000 I would

avr timer1 16bit fast PWM

主宰稳场 提交于 2021-02-10 23:04:08
问题 I am using an Atmega328p-pu. I am trying to use the timer 1 for both a 16 bit PWM as well as using the overflow inturrupt to increment a timer. My code is below, I also set the F_CPU to 8000000UL in the make file. I would like the to have a variable that counts up for a defined amount of time and then resets and continues. so far I would expect it to count up for 7.5 seconds. I believe I should have a clock frequency of 8 MHz, then with fast PWM with a 1 prescaler and ICR1 at 5000 I would

Generating square wave in AVR Assembly without PWM

北慕城南 提交于 2021-02-08 08:06:11
问题 I'm using an ATmega328. The thing is that I want to generate a square wave of a given frequency and of a given amplitude. PWM can't be used because I was given a board that has already been soldered, so the wave has to be put at the output of an R2R resistor ladder that is connected to the B port of the processor. So, basically, the idea is that I have to put the pins of port B in 0 and VOLUME (VOLUME is a number that goes from 1 to 255) periodically, with a given frequency and a duty cycle

accessing AVR registers with C? [closed]

假如想象 提交于 2021-01-29 11:19:38
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 years ago . Improve this question I've been trying to learn everything I can about micro-controllers lately. Since this is self-study, it's taken me a while to learn how the things work at the bare metal. Long story short, I don't want to use the AVR libraries in my C code; I want to access

What is the benefit of having the registers as a part of memory in AVR microcontrollers?

寵の児 提交于 2020-12-15 19:37:37
问题 Larger memories have higher decoding delay; why is the register file a part of the memory then? Does it only mean that the registers are "mapped" SRAM registers that are stored inside the microprocessor? If not, what would be the benefit of using registers as they won't be any faster than accessing RAM? Furthermore, what would be the use of them at all? I mean these are just a part of the memory so I don't see the point of having them anymore. Having them would be just as costly as

What is the benefit of having the registers as a part of memory in AVR microcontrollers?

霸气de小男生 提交于 2020-12-15 19:32:33
问题 Larger memories have higher decoding delay; why is the register file a part of the memory then? Does it only mean that the registers are "mapped" SRAM registers that are stored inside the microprocessor? If not, what would be the benefit of using registers as they won't be any faster than accessing RAM? Furthermore, what would be the use of them at all? I mean these are just a part of the memory so I don't see the point of having them anymore. Having them would be just as costly as

What is the benefit of having the registers as a part of memory in AVR microcontrollers?

血红的双手。 提交于 2020-12-15 19:31:30
问题 Larger memories have higher decoding delay; why is the register file a part of the memory then? Does it only mean that the registers are "mapped" SRAM registers that are stored inside the microprocessor? If not, what would be the benefit of using registers as they won't be any faster than accessing RAM? Furthermore, what would be the use of them at all? I mean these are just a part of the memory so I don't see the point of having them anymore. Having them would be just as costly as

How to make Atmega328 timmer interrupt tick every 1 second?

生来就可爱ヽ(ⅴ<●) 提交于 2020-12-15 06:36:46
问题 I've an Atmega328p and I've connected an LED to it's D4 pin and I want it to turn LED on/off every one second. I found this tutorial and I've change it base on some online AVR timmer calculator and the 12MHZ external crystal which I've used, to this : #define F_CPU 12000000UL #include <avr/io.h> #include <avr/interrupt.h> int main(void) { DDRD |= 1 << 4; PORTD |= 1 << 4; ICR1 = 0xB71B; TCCR1B |= (1 << WGM12); // Mode 4, CTC on OCR1A TIMSK1 |= (1 << ICIE1); //Set interrupt on compare match

ATTiny85 - Software UART with Timer1

拜拜、爱过 提交于 2020-12-06 15:47:31
问题 So recently I tried to implement Software UART (TX only) for the ATTiny85. I want to drive it with the internal Timer1. The timer shall interrupt with the frequency of the Baudrate. Every ISR one bit will be transmitted, until there is nothing left to send and the interrupt will be disabled again. (Note: F_CPU=1000000 ; Fuses are the factory default (E:FF, H:DF, L:62) ) #include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> #include <stdint.h> #define SET(reg, pos) (reg |= 1<<