atmega

Reversing bits in a byte with AVR

冷暖自知 提交于 2020-04-18 05:47:25
问题 I am currently working on a problem that wants me to build a subroutine that will reverse the bits in R16. 00000011 => 11000000 or 10101000 => 00010101 For the class we are using the AVR subset and the subroutine needs to work in norfair. This is what I have so far, any help would be appreciated! ldi r16,3 ;00000011 回答1: The naive solution is to loop through the bits with the shift operator and check. But be aware that AVR doesn't have a barrel shifter so it can only shift by 1, any other

displaying Hexadecimal value in LCD

丶灬走出姿态 提交于 2020-01-06 06:45:32
问题 I wrote LCD interface program for Atmega328 (Though there are libraries available, I wanted to write from scratch). But have two problems. 1. Sometimes LCD does not display correctly. Only few strips are seen. I end up in resetting once or twice. 2. I am unable to display hexadecimal values usingdisplayOneByteHexValue(). However ASCII coversion was correct and I could see that in Atmel Simulator. Below is the code. I am using Atmel Studio 6.2 /* * EmbeddedProgram1.c * * Created: 16-05-2015 08

CRC-32 on MicroController (Atmel)

一个人想着一个人 提交于 2019-12-25 08:09:20
问题 I am currently trying to implement a CRC-32 for an incoming datastream (Serial communication) on an ATMEGA1280 and I am a little lost how to do this on the embedded side in C.... If anyone could point me in the proper direction and/or help in anyway i would greatly appreciate it... 回答1: You should know what polynomial you are dealing with. So it is not enough to know that you are using CRC, but you should also know polynomial. You are looking for function with this kind of prototype uint32_t

FATFS returns FR_DISK_ERR the second time I use an identical line of code

放肆的年华 提交于 2019-12-25 03:33:23
问题 I am using FATFS to write data to an SD card. It partially works and I am able to write EEPROM data to the SD card. But when I use a different function later on in the code it returns 'FR_DISK_ERR' even though I'm using the same line of code. The first time I try to write to the SD card is as follows (At this point I have already initialized the SD card and made the file, that is not the issue): //write EEPROM to EEPROM file fr = f_open(&File, file_name, FA_OPEN_APPEND | FA_WRITE); if (fr ==

How can i add a architecture which is available in new version of gcc to a old version of gcc?

陌路散爱 提交于 2019-12-25 01:49:56
问题 I want to add Atmega1281 architecture to my current version of gcc that i am using i.e. v3.3. The Atmega1281 is not supported in the v3.3 and its support got added in v4.2.1 . I cannot upgrade the gcc to 4.2.1, so i need to add the support to my existing compiler. Is there any way to do this ? 回答1: You don't need to update GCC (I presume you are actually using AVR-GCC to generate AVR specific machine code...). All AVR chips use the same AVR core and instruction set. The only thing that

Using Serial Peripheral Interface (SPI) to talk to several slaves simultaneously

回眸只為那壹抹淺笑 提交于 2019-12-24 17:16:08
问题 I have four Atmega328p in a single board and I want one of them send the same data (i.e. sensor readings) to the other three simultaneously. I'm not interested in a bidirectional communication. I read this thread (How can I broadcast data to multiple SPI slaves and how it works?) about SPI broadcasting, and someone mentioned not being possible because in SPI communication is full duplex and MISO and MOSI lines are active at the same time. However, I was wondering if I could just let the MISO

Beginner: AVR C++ Atmel Studio 6

≡放荡痞女 提交于 2019-12-23 20:01:57
问题 I'm having an issue working out what libraries I have access to. I understand that I can use the Atmel Studio 6 IDE to program the microcontroler (Atmega328p) in C++; however, I can't work out where it is documented what libraries I have access to. For example, can I use the STL (so like, vectors, deques...)? If someone could point me towards some documentation, that'd be great. Thanks. 回答1: Atmel Studio 6 doesn't come with an implementation of STL. There are some libraries that avr-gcc comes

Bluetooth control signals (DTR, DSR, RTS, CTS) on Android

好久不见. 提交于 2019-12-23 15:13:04
问题 I would like to remotely reprogram my Arduino via Android over Bluetooth SPP. The first step is to reset the ATMEGA microcontroller. This is accomplished on the Arduino by toggling the DTR line. Is there any API to control the Bluetooth SPP control lines from the Android environment? 回答1: Also it is supported by SPP in general to send or receive the control signals (DTR, DSR, RTS, CTS) I do not know any API or library for android right know, but as you just want to reset your controller... If

what is the fastest algorithm for permutations of three condition?

依然范特西╮ 提交于 2019-12-23 09:19:51
问题 Can anybody help me regarding quickest method for evaluating three conditions in minimum steps? I have three conditions and if any of the two comes out to be true,then whole expression becomes true else false . I have tried two methods: if ((condition1 && condition2) || (condition1 && condition3) || (condition2 && condition3)) Another way is to by introducing variable i and i = 0; if (condition1) i++; if (condition2) i++; if (condition3) i++; if (i >= 2) //do something I want any other

what is the fastest algorithm for permutations of three condition?

对着背影说爱祢 提交于 2019-12-23 09:19:28
问题 Can anybody help me regarding quickest method for evaluating three conditions in minimum steps? I have three conditions and if any of the two comes out to be true,then whole expression becomes true else false . I have tried two methods: if ((condition1 && condition2) || (condition1 && condition3) || (condition2 && condition3)) Another way is to by introducing variable i and i = 0; if (condition1) i++; if (condition2) i++; if (condition3) i++; if (i >= 2) //do something I want any other