embedded

Why strcpy() and strcat() is not good in Embedded Domain

家住魔仙堡 提交于 2019-12-03 17:32:42
Here i want to know about strcpy() and strcat() disadvantages i want to know about these functions danger area in embedded domain/environment. somebody told me we never use strcpy,strcat and strlen functions in embedded domain because its end with null and sometimes we works on encrypted data and null character comes so we cant got actual result because these functions stop on null character. So i want to know all things and other alternative of these functions. how we can use other alternatives functions The str* functions works with strings. If you are dealing with strings, they're fine to

GCC MIPS-32 Calling Conventions / Stack Frame Definition

旧街凉风 提交于 2019-12-03 17:17:23
问题 There appears to be no definitive standardized stack frame and C language calling conventions (register usage and such) for the MIPS-32 Processor Architecture. That is, it appears to be completely up to the assembler/compiler tool chain to define their own stack frame and calling conventions. I've struggled to find a definitive reference of what conventions the GCC compiler uses for MIPS-32 instruction set. I'm specially using GCC cross-compiler on Cygwin that targets a MIPS-32 core being

Compute logarithmic expression without floating point arithmetics or log

…衆ロ難τιáo~ 提交于 2019-12-03 17:09:22
I need to compute the mathematical expression floor(ln(u)/ln(1-p)) for 0 < u < 1 and 0 < p < 1 in C on an embedded processor with no floating point arithmetics and no ln function. The result is a positive integer. I know about the limit cases (p=0), I'll deal with them later... I imagine that the solution involves having u and p range over 0..UINT16_MAX , and appeal to a lookup table for the logarithm, but I cannot figure out how exactly: what does the lookup table map to? The result needs not be 100% exact, approximations are OK. Thanks! Since the logarithm is used in both dividend and

PID controller integral term causing extreme instability

ぐ巨炮叔叔 提交于 2019-12-03 16:49:02
问题 I have a PID controller running on a robot that is designed to make the robot steer onto a compass heading. The PID correction is recalculated/applied at a rate of 20Hz. Although the PID controller works well in PD mode (IE, with the integral term zero'd out) even the slightest amount of integral will force the output unstable in such a way that the steering actuator is pushed to either the left or right extreme. Code: private static void DoPID(object o) { // Bring the LED up to signify frame

Initialization of a microSD card using an SPI interface

眉间皱痕 提交于 2019-12-03 16:46:19
问题 I'm using a microSD card in an embedded design. The card is connected to a microcontroller using the SPI interface. It worked fine for all cards I've used before, but now my new card will not initialize. The card is a Transcend 2 GB microSD card (TS2GUSD). After sending the initial clock train to switch to SPI mode, I do the following: CMD0 (Argument 0, CRC 0x95) -> Response 0x01 -> OK CMD8 (Argument 0x000001AA, CRC 0x87) -> Response 0x01 0x000001AA -> Means it's SDC V2+ card, the voltage

Why is Read-Modify-Write necessary for registers on embedded systems?

别等时光非礼了梦想. 提交于 2019-12-03 16:39:24
问题 I was reading http://embeddedgurus.com/embedded-bridge/2010/03/different-bit-types-in-different-registers/, which said: With read/write bits, firmware sets and clears bits when needed. It typically first reads the register, modifies the desired bit, then writes the modified value back out and I have run into that consrtuct while maintaining some production code coded by old salt embedded guys here. I don't understand why this is necessary. When I want to set/clear a bit, I always just or/nand

Program received signal SIGTRAP, Trace/breakpoint trap

大城市里の小女人 提交于 2019-12-03 16:29:56
问题 I'm debugging a piece of (embedded) software. I've set a breakpoint on a function, and for some reason, once I've reached that breakpoint and continue I always come back to the function (which is an initialisation function which should only be called once). When I remove the breakpoint, and continue , GDB tells me: Program received signal SIGTRAP, Trace/breakpoint trap. Since I was working with breakpoints, I'm assuming I fell in a "breakpoint trap". What is a breakpoint trap? 回答1: Breakpoint

Does anyone have a good guide to designing and error tracking/control system for C?

牧云@^-^@ 提交于 2019-12-03 16:28:49
I'm new to the software engineering side of C development; does anyone have a good guide on how to design an error tracking or error control system for a C project (especially embedded)? Something talking about error tracking for C libraries would be helpful too. In my experience the strategies here fall into a few camps. Use of global variables ala errno . How this works is essentially any function can store an error code in the global variable, so after executing the function you can read the error code to see if it executed properly. There are some obvious issues here when working in a

Free alternative to MPLAB (PIC development)

穿精又带淫゛_ 提交于 2019-12-03 16:16:20
问题 I started using MPLAB recently, but for someone that works with Eclipse and VS the IDE it's very limited. Do you know any free IDE or how to configure Ecplise or Netbeans to PIC development? Thanks all 回答1: The underlying toolchain (compiler/linker etc.) can be used from any environment including Eclipse and Visual Studio, though Eclipse is probably the more flexible in this respect. MPLAB has a feature to export a project as a makefile that can be used with GNU make, although you may rather

Embedded systems file encryption library

霸气de小男生 提交于 2019-12-03 15:51:00
I've got a project and a part of it is incorporating encryption into a FAT file system. The goal of the project is not the encryption, so I'm free to use open-source pre-done libraries. Ideally what I'm after is a C library which uses RSA, that already has the methods for computing keys and encrypting/decrypting files. You might want to check out NaCl (pronounced as "salt"), especially since this is for an embedded system. It has CPU-specific tunings and doesn't require any dynamic memory allocation. As for licensing, the page (linked above) says "All of the NaCl software is in the public