embedded

Event button as a module or as user program?

无人久伴 提交于 2020-01-25 17:52:30
问题 I am programming a push button to start the software in a linux based board. A push button on Linux based embedded board. GPIO didn't work with that Linux kernel, so instead, I used the event interface. The button is basically listening for button press to activate all the hardware and stops the hardware when it's pressed twice. I would like to know whether write as a kernel module or as a user program? Or as a deamon? 回答1: If it's possible to do it in user space (i.e. daemon) you should do

Embedded C++ static initialization of struct arrays

房东的猫 提交于 2020-01-25 06:48:10
问题 While migrating to C++ I require a certain function that seems to have been deprecated. sorry, unimplemented: non-trivial designated initializers not supported What is the correct way to implement the following data storage system in C++ for memory constraint systems? typedef union union_t { float f; int i; } arg; typedef struct type_t { int a; arg b; int d; } element; const element list[] = { { .a = 1, .b = { .f = 3.141519f }, .d = 6 }, { .a = 3, .b = { .i = 1 }, } }; Often the use of std

How to make Timer1 more accurate as a real time clock?

不想你离开。 提交于 2020-01-24 19:03:27
问题 I have PIC18F87J11 with 8 MHz oscillator and I am using timer1 as real time clock. At this moment I have it toggle an LED every 1 minute. I noticed it does work perfect fine the first few times but slowly it starts toggling the LED every 59 seconds. Then every few minutes it keeps going down to 58, 57, etc. I don't know if its impossible to get an accurate clock using internal oscillator or if I need external oscillator. My settings look right for timer1, I just hope I can resolve this issue

Game Boy: Half-carry flag and 16-bit instructions (especially opcode 0xE8)

。_饼干妹妹 提交于 2020-01-23 05:14:11
问题 Like so many others, I am writing a Game Boy emulator and I have a couple of questions regarding the instruction 0xE8 ( ADD SP, n with an 8-bit immediate). It is claimed here that in 16-bit instructions the half-carry flag is set if a carry occurs from bit 7 to bit 8, whereas here it is said that the half-carry flag indicates carry from bit 11 to bit 12. In this Reddit thread there seems to be a bit of confusion regarding the issue, and the (notoriously flawed, I hear) Game Boy CPU manual

SIGTRAP despite no set breakpoints; hidden hardware breakpoint?

妖精的绣舞 提交于 2020-01-22 10:40:14
问题 I am debugging this piece of software for an STM32 embedded system. In one of the functions my programs keeps hitting some sort of breakpoint: SIGTRAP, Trace/breakpoint trap However, in GDB, when I do info breakpoints I get No breakpoints or watchpoints . The breakpoint actually corresponds to a breakpoint I had set quite some time ago, in another version of the executable. When I set that breakpoint, GDB told me automatically using a hardware breakpoint on read-only memory (or a similar

How to handle changing data structures on program version update?

China☆狼群 提交于 2020-01-22 05:41:04
问题 I do embedded software, but this isn't really an embedded question, I guess. I don't (can't for technical reasons) use a database like MySQL, just C or C++ structs. Is there a generic philosophy of how to handle changes in the layout of these structs from version to version of the program? Let's take an address book. From program version x to x+1, what if: a field is deleted (seems simple enough) or added (ok if all can use some new default)? a string gets longer or shorter? An int goes from

Stray characters seen at output of snprintf

此生再无相见时 提交于 2020-01-22 02:15:53
问题 I have a string creating function in C which accepts an array of structs as it's argument and outputs a string based on a predefined format (like a list of list in python). Here's the function typedef struct { PacketInfo_t PacketInfo; char Gnss60[1900]; //and other stuff... } Track_json_t; typedef struct { double latitude; double longitude; } GPSPoint_t; typedef struct { UInt16 GPS_StatusCode; UInt32 fixtime; GPSPoint_t point; double altitude; unsigned char GPS_Satilite_Num; } GPS_periodic_t;

Output debug via printf on a Cortex-M3 CPU, stalls at BKPT instruction + confusion about JTAG and sw ports

∥☆過路亽.° 提交于 2020-01-21 05:16:30
问题 I have a Keil ULINK2 USB emulator box attached to the JTAG connector on my board, which is working fine with the Cortex-M3 CPU onboard (TI/Stellaris/LuminaryMicro LM3S series). It seems that both a JTAG and a SWJ-DP port share the same pins (and thus connector on your board) on these CPUs. One appears not to have ITM (printf) capability, the other does. The previous firmware people have always used stdio to UART (serial port), but I need the serial port freed up so that debug messages do not

How are floating point operations emulated in software? [closed]

故事扮演 提交于 2020-01-20 07:04:26
问题 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 3 years ago . How does software perform floating point arithmetic when the CPU has no (or buggy) floating point unit? Examples would be the PIC, AVR, and 8051 microcontrollers architectures. 回答1: "Emulated" is the wrong term in the context of PIC, AVR and 8051. Floating-point emulation refers

serial port configuration using boost ASIO

。_饼干妹妹 提交于 2020-01-15 14:24:21
问题 I am configuring serial port using boost asio. but why below code is giving error? If I comment set_option it works fine. below code gives error serial_config.cpp:13: error: expected unqualified-id before numeric constant In file included from /home/chirag/boost_install/include/boost/asio/serial_port_service.hpp:25, from /home/chirag/boost_install/include/boost/asio/basic_serial_port.hpp:30, from /home/chirag/boost_install/include/boost/asio.hpp:25, from serial_config.cpp:1: /home/chirag