avr

C Undefined reference

独自空忆成欢 提交于 2019-12-11 08:02:07
问题 I have the following code: main.c #include "checksum.h" void main() { char *Buf ="GPGGA204502.005106.9813N11402.2921W1090.91065.02M-16.27M"; checksum(Buf); } checksum.c #include <stdio.h> #include <string.h> checksum(char *Buff) { int i; unsigned char XOR; unsigned long iLen = strlen(Buff); printf("Calculating checksum...\n"); for (XOR = 0, i = 0; i < iLen; i++) XOR ^= (unsigned char)Buff[i]; printf("%X \n",XOR); } checksum.h #ifndef CHECKSUM_H_INCLUDED #define CHECKSUM_H_INCLUDED void

How to wake up by bluetooth a device in bluetooth stand by (like the avr Sony STR-DN1080)

北城以北 提交于 2019-12-11 07:48:24
问题 I'm trying to understand how my AVR STR-DN1080 can be woken up by bluetooth using a raspberry pi instead of my android phone. Let me explain: - My AVR Sony STR-DN1080 can go into bluetooth stand-by mode. In such case, I can use my android phone, search among the paired devices, find my "STR DN1080 XXXX" device, simply click on it and the phone starts doing something and after few seconds, my AVR wakes up and switches on. - so I thought I could use my Raspberry PI 3B + to use its bluetooth and

How to find the address of a variable when using AVR?

痞子三分冷 提交于 2019-12-11 06:02:29
问题 I am trying to write a program that detects pixel level collision of bitmaps on a Teensy micro controller compiling with AVR-GCC. I am trying to work out how to calculate the position of a single byte of the bitmap on the screen and have been told I should be using pointers. I don't see the relationship between the physical address of a bitmap byte and it's position on the screen, but I would like to investigate. The problem is, I have no way of printing this address. AVR doesn't have printf

AVR SBI or CBI on Higher Ports H+

烈酒焚心 提交于 2019-12-11 05:39:12
问题 I have a problem on using CBI or SBI in avr assembly, when working with Port H through L. From the documentation [http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_SBI.html] the SBI takes parameter of 5 bit only which if I am using port H or higher, the address from _SFR_IO_ADDR(PORTH) will exceed the allowed range. Is there any alternative to achieve this? Thanks. 回答1: You need to LD the value, perform the OR or AND necessary to manipulate the bits, and then ST the value back. Unless

How to compile clang to use as compiler for avr?

谁说我不能喝 提交于 2019-12-11 05:25:31
问题 I'd like to cross-compile clang to use as compiler for avr (arduino to be more detailed). i feel i should do smth like next: create standalone toolchain from android ndk compile with correct CC and CXX parameters. Smth else? Does it support --target=avr or how can i compile? Does it make sense as it will be used like IDE autocompletion tool to parse the sources using clang-c API? UPDATE: configuration with --host and --target params: export CROSS_COMPILE=arm-linux-androideabi export CC=$

reinterpret_cast<volatile uint8_t*>(37)' is not a constant expression

一笑奈何 提交于 2019-12-11 04:26:10
问题 gcc fails to compile the code below, while clang compiles ok. I have no control on the macro PORTB , as it is in a 3rd party library ( avr ). Is it a gcc bug? How can I work around it in gcc ? As a workaround is somehow possible to create a pre-processor macro which extracts the numerical value from PORTB? Note this question is similar, but not identical to my previous question. It is also different from this question, where the developer has the flexibility to change the rhs of the

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

How can I prevent the need to copy strings passed to a avr-gcc C++ constructor?

偶尔善良 提交于 2019-12-11 02:33:44
问题 In the ArduinoUnit unit testing library I have provided a mechanism for giving a TestSuite a name. A user of the library can write the following: TestSuite suite("my test suite"); // ... suite.run(); // Suite name is used here This is the expected usage - the name of the TestSuite is a string literal. However to prevent hard-to-find bugs I feel obliged to cater for different usages, for example: char* name = (char*) malloc(14); strcpy(name, "my test suite"); TestSuite suite(name); free(name);

Unexpected float behaviour in C with AVR atmega8

↘锁芯ラ 提交于 2019-12-10 15:44:17
问题 I've been trying to figure out why I cannot get a sensible value from multiplying an unsigned int with a float value. Doing something like 65535*0.1 works as expected but multiplying a float with a uint from memory creates mad values. I have a function that reads an ADC and returns an uin16_t. With this value I am printing it to a 4-digit led-display, which is working fine. Multiplying the same value with 1.0 returns something different entirely (it's too large for my display so I don't