microcontroller

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

How to erase just some bytes of Flash Memory?

a 夏天 提交于 2019-12-24 05:42:06
问题 My PIC18F87J11 only erases 1024 bytes at a time. Is there away to force it to only erase 2 bytes or more at a time? I am making a Bootloader and sometimes only one line of the HEX file (16 bytes) changes for the application program, so I want to replace that line in memory with the new 16 bytes only . If I try to erase those 16 bytes, automatically 1024 bytes get erased too. Then I am forced to re-write them which takes some time and reduce the speed of the Bootloader. Is there an alternative

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

Reading a Keypad and displaying it using Microprocessor

不羁的心 提交于 2019-12-23 04:46:01
问题 MTS-88.C and I/O BOARD -08 has 8 (Eight) 7-segment displays and 20 key-pads on board. The displays are numbered from 7-SEG.1 to 7-SEG.8 and are connected to Port B’s PB7 to PB0 lines respectively. To display a character on a 7-segment display a byte has to be written to port B. The MSB 4 bits are the address of the 7-segment display and LSB 4 bits are the data. So if we write 58 H to port B then the 6th 7-segment display will show data 8. 20 key-pads are numbered from P01 to P20 and are

How to pass a bitfield (by reference) to a function?

扶醉桌前 提交于 2019-12-23 02:45:38
问题 My question is how to pass a bitfield instance by reference to a function. I have performed this as shown below, but when i eneter the function DAC_set_gain_code, the processor throws an interupt fault. Is what i am doing correct as far as passing the bitfield goes? I have created a bitfield (see below) which represents a 24bit register on an DAC chip, which i want to write into and lives in the .h file. typedef struct { uint8_t rdwr_u8: 1; uint8_t not_used_u8: 3; uint8_t address_u8: 4; uint8

Remake of Fletcher checksum from 32bit to 8

拜拜、爱过 提交于 2019-12-22 12:36:41
问题 Is this conversion right from the original? uint8_t fletcher8( uint8_t *data, uint8_t len ) { uint8_t sum1 = 0xff, sum2 = 0xff; while (len) { unsigned tlen = len > 360 ? 360 : len; len -= tlen; do { sum1 += *data++; sum2 += sum1; tlen -= sizeof( uint8_t ); } while (tlen); sum1 = (sum1 & 0xff) + (sum1 >> 4); sum2 = (sum2 & 0xff) + (sum2 >> 4); } /* Second reduction step to reduce sums to 4 bits */ sum1 = (sum1 & 0xff) + (sum1 >> 4); sum2 = (sum2 & 0xff) + (sum2 >> 4); return sum2 << 4 | sum1;

How to run opencv on on a microcontroller?

二次信任 提交于 2019-12-22 10:31:35
问题 I don't know lots of things about the electronics field and controllers. But I want to know how to combine an opencv program with a red traffic light? I know that the answer is something that is micro controller but I only know that there is a compiler AVR which can compile C to hex and then working with micro controllers. But OpenCV (which I think I won't run on C) is high level and probably won't work with AVR. So what should I do to combine a machine vision program (by OpenCV & C++) and

Java in Embedded Programming

别说谁变了你拦得住时间么 提交于 2019-12-22 08:14:19
问题 Can java programming be used in micro-controller programming like C and C++? If yes what are the requirement for it? What about in PIC16 and PIC32 series micro controller? Any Possibility for them. I could not find much more information about it in the web too.I appreciate your help. Cheers!!! 回答1: To run Java on any platform you will need a Java Virtual Machine (JVM). I would not hold out too much hope for PIC16 due to the memory resources required and perhaps the performance. If you want

How to convert Char into Float

拟墨画扇 提交于 2019-12-22 07:00:04
问题 How to convert an unsigned char value into a float or double in coding in AVR studio 4.? Please help I am a beginner, my question may sound stupid too :/ Like I have got a char keyPressed and I have printed it on the screen using lcd_gotoxy(0,0); lcd_puts (keyPressed); Now I want to use this value to calculate something.. How to convert it into float or double? please help 回答1: if you want for example character 'a' as 65.0 in float then the way to do this is unsigned char c='a'; float f=

Defending “U” suffix after Hex literals

最后都变了- 提交于 2019-12-22 05:23:37
问题 There is some debate between my colleague and I about the U suffix after hexadecimally represented literals. Note, this is not a question about the meaning of this suffix or about what it does. I have found several of those topics here, but I have not found an answer to my question. Some background information: We're trying to come to a set of rules that we both agree on, to use that as our style from that point on. We have a copy of the 2004 Misra C rules and decided to use that as a