atmega

How to store a number in decimal format in avr

陌路散爱 提交于 2019-12-18 09:45:26
问题 I am trying to enter the decimal values using a keypad in ATMega8 Till now I have been able to enter only the integer values The code is given below switch (keyCode) { case (0xee): keyPressed="1"; b=1; a=a*10+b; break; case (0xed): keyPressed="4"; b=4; a=a*10+b; break; case (0xeb): k keyPressed="7"; b=7; a=a*10+b; break; case (0xde): keyPressed="2"; b=2; a=a*10+b; break; case (0xdd): keyPressed="5"; b=5; a=a*10+b; break; case (0xdb): keyPressed="8"; b=8; a=a*10+b; break; case (0xd7):

C++: closure to pass member function as normal function pointer

一个人想着一个人 提交于 2019-12-13 14:23:30
问题 I'm trying to call a member function of an external library which takes a function pointer as a parameter: Timer::every(unsigned long period, void (*callback)(void)); But unfortunately the parameter I want to pass is a member function: void MyClass::the_method_i_want_to_pass(void); Since I'm programming for the ATMega under Arduino (AVR) there is just limited support of c++11. My first approach raises a type error: void MyClass::the_method_i_want_to_pass() {...} MyClass::MyClass() { //

Solving “redeclared as different kind of symbol” error

狂风中的少年 提交于 2019-12-13 07:26:02
问题 I'm currently working on Arduino. I'm working for Lamp using Atmega1284. I saw an example code, ModbusIP_ENC28J60 -> Lamp. I first compiled it without adding anything, it compiled properly. Now, I'm adding WebSocketServer, since I want this to work on websocket too. I added few necessary lines, but I ended up with this error: error: 'EthernetClass Ethernet' redeclared as different kind of symbol I don't understand what's wrong with the code or what I should change. Can someone help me with

Counting without “counter” in microcontroller is Possible?

和自甴很熟 提交于 2019-12-13 04:35:40
问题 Hello friends i am new in microcontroller domain wants to know is this not possible to counts an events without using counter i mean by monitoring the pin which is connected to the the event generator.i am asking this question because presently i want to calculate the frequency of sensor i have already checked it frequency by using DSO(Digital storage oscilloscope) and it(DSO) says its frequency is 98khz but as we all now that the maximum value of an 8 bit counter is 255 then how it is

Unable to connect to Atmega328P chip with 16MHz crystal

牧云@^-^@ 提交于 2019-12-13 02:26:37
问题 I am trying to connect to Atmega328P chip through eXtreme Burner. I used 22pf capacitors and 10K pull for reset. I am able to read the chip if I use 8 MHz Crystal. But cannot read if I connect 16MHz crystal. When I looked at the datasheet, it says fuse bits are same for 8 MHz and 16 MHz. I get "Power On Failed" error message with 16 MHz. I am using USBASP programmer. Please note: With 8 MHz crystal, though I am able to read the device, I get error message "Incorrect Chip Found! Continue". If

how to write code for transfer data from internal memory via SPI Master to 2 slave

不羁岁月 提交于 2019-12-12 04:06:55
问题 I receive data from USB to the internal memory of Atxmega 128A1 if ( (SWITCHPORTL.IN & PIN1_bm) == 0 ) { j = 0; while (j < NUM_BYTES) { // Wait till there is unread data in the receive buffer while((USART.STATUS & USART_RXCIF_bm) == 0 ){}; // Read out the received data __far_mem_write(j+SDRAM_ADDR, USART.DATA); if (j == (NUM_BYTES-1)) { // Toggle LED 1 LEDPORT.OUTTGL = PIN1_bm; } j++; } } How to write code for transfer data from internal memory via SPI Master to two slaves such that odd and

Basic I/O in Microcontroller AVR using WinAVR

廉价感情. 提交于 2019-12-11 20:13:36
问题 I want to drive a BLDC motor, i use ATMEGA32 as CPU of controller , i have a problem in reading hall effect sensor from BLDC motor this is my code : DDRB=(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5); DDRD=(0<<0)|(0<<1)|(0<<2)|(0<<3); PORTD=(1<<0)|(1<<1)|(1<<2)|(1<<3); PORTB as OUTPUT and PORTD as INPUT this is main program : if (~(PORTD &(1<<0)) && PORTD &(1<<1) && ~(PORTD &(1<<2))) /// 0 1 0 { PORTB=(1<<0)|(0<<1)|(0<<2)|(1<<3)|(0<<4)|(0<<5); } else if (~(PORTD &(1<<0)) && PORTD &(1<<1) && PORTD

Avrstudio 4.19 toolchain using gcc 4.7.x

纵饮孤独 提交于 2019-12-11 10:27:16
问题 I'm using makefile style compiling of my ATMEGA projects. As legacy of Arduino IDE, develepment toolchain is mostly aimed to gcc 4.3.2. Avrstudio 4.19 + Jtagice MKII CN + gcc 4.3.2 + make works somehow. But my problem is that gcc 4.3.2 is rather buggy. I see e.g. random bugs related to optimization of non-volatile variables, register cached values are not always written back to memory and also wrong warning are annoying. Hence using gcc 4.7.0 solves problem but I cannot load any such a

Setting up Interrupts on atmega328 in pure C

可紊 提交于 2019-12-11 04:03:44
问题 I am currently working on an Arduino Uno Board and I am trying to write it in pure C without the use of Arduino's Libraries. My project which I am working should work like this: Set LEDs PB0 to BP7 ON and OFF . Set interrupt on PD2 connected to a Button. When the Button is pressed the LEDs should STOP (pause). When the Button is pressed Again the LEDs should turn ON again starting from the last LED which was OFF . To be more precise: The function play() is called LEDs are starting to blink

XMega Timer and Microseconds

馋奶兔 提交于 2019-12-11 03:30:24
问题 I'm trying to bit bang out some data out of an atxmega128a3u and need to toggle a pin as fast as 4us but so far I'm not getting anywhere close to that... Here I'm setting my timer for 88us but am getting around 146us. int main(void) { //CRYSTAL SETUP OSC_XOSCCTRL = OSC_FRQRANGE_12TO16_gc | OSC_XOSCSEL_XTAL_16KCLK_gc; // 16Mhz Crystal OSC_CTRL |= OSC_XOSCEN_bm; while(!(OSC_STATUS & OSC_XOSCRDY_bm)); //Wait for crystal to stabilize. CCP = CCP_IOREG_gc; CLK_CTRL = CLK_SCLKSEL_XOSC_gc; //END