embedded

Converting to ASCII in C

 ̄綄美尐妖づ 提交于 2019-12-19 02:02:51
问题 Using a microcontroller (PIC18F4580), I need to collect data and send it to an SD card for later analysis. The data it collects will have values between 0 and 1023, or 0x0 and 0x3FF. So what I need to do is convert 1023 into a base 10 string of literal ASCII values (0x31, 0x30, 0x32, 0x33, ...). My problem is that the only way I can think of to split the digits apart requires a lot of division. char temp[4]; temp[0] = 1023 % 10; temp[1] = (1023 % 100) / 10; temp[2] = (1023 % 1000) / 100; temp

Calculate atan2 without std functions or C99

自闭症网瘾萝莉.ら 提交于 2019-12-18 17:27:52
问题 I am calculating angles from a 3-axis accelerometer, but my compiler doesn't have a atan or atan2 function. It has a reserved memory slot, but it calls a function i can't find in any files. My compiler is Keil µVision 4 running the ARMCC compiler. The compiles has the file math.h, but the function is extern and doesn't exist: extern _ARMABI double atan2(double /*y*/, double /*x*/); Is there a lib or function I can include that has the function arctan implemented? Or is there an alternative

Calculate atan2 without std functions or C99

℡╲_俬逩灬. 提交于 2019-12-18 17:27:09
问题 I am calculating angles from a 3-axis accelerometer, but my compiler doesn't have a atan or atan2 function. It has a reserved memory slot, but it calls a function i can't find in any files. My compiler is Keil µVision 4 running the ARMCC compiler. The compiles has the file math.h, but the function is extern and doesn't exist: extern _ARMABI double atan2(double /*y*/, double /*x*/); Is there a lib or function I can include that has the function arctan implemented? Or is there an alternative

Scripting Language in a Sandbox for a C#/.NET Application

亡梦爱人 提交于 2019-12-18 16:53:11
问题 [This question is similar to this one, but I am also interested in the possibility of a sandbox.] I am considering embedding a scripting language in my C#/.NET application and then exposing some of my application's API to the scripts. There seem to be multiple good options for this (Lua, Boo, IronPython, etc.), but are there easy options for restricting the scripting language's built-in functions from being used? For example, I do not want the scripts to be able to perform I/O except through

What' s the difference between <= and := in VHDL

依然范特西╮ 提交于 2019-12-18 15:32:17
问题 Currently, I am learning some FPGA design techniques using VHDL, my problem is whether we can use := and <= interchangeably in VHDL or not, though I've seen the use of := in constants declarations and <= in assignments? Thanks in advance! 回答1: The rules are a little more complex than this, but basically: you use <= to do signal assignment, which takes effect on the next delta cycle. You use := to do variable assignment, which takes place immediately. So if you have a signal, you always use <=

How do I get Qt SDK configured properly with Yocto project?

不打扰是莪最后的温柔 提交于 2019-12-18 13:36:55
问题 I'm new to Yocto Project. The initial idea is to create a custom image based on core-image-full-cmdline (this is with no windowing system) and generate a Qt5 SDK against this image. So my target to be able to run Qt applications needs to have some headers & libraries installed, isn't ? What I must specify on my image recipe ? Doing $ bitbake my_image -c populate_sdk will generate my_image with Qt5 support + SDK installer ? As I understood, to get a Qt SDK the steps would be: Download and add

get the physical address of a buffer under Linux

大憨熊 提交于 2019-12-18 13:25:07
问题 I am running Linux kernel 3.3 on Xilinx's Microblaze with full MMU. the task that I am doing requires me to know the following: I need to create a text file (buffer) and locate the physical address of this buffer and I don't want the kernel to write this file into discontinuous regions of memory. the reason I need this because I have a DMA engine that streams data from a preset physical memory address, so I need to force Linux to create the buffer file at that exact memory location, so that

How to force an unused memory read in C that won't be optimized away?

a 夏天 提交于 2019-12-18 12:52:28
问题 Microcontrollers often require a register to be read to clear certain status conditions. Is there a portable way in C to ensure that a read is not optimized away if the data is not used? Is it sufficient that the pointer to the memory mapped register is declared as volatile? In other words, would the following always work on standard compliant compilers? void func(void) { volatile unsigned int *REGISTER = (volatile unsigned int *) 0x12345678; *REGISTER; } I understand that dealing with

How to force an unused memory read in C that won't be optimized away?

烈酒焚心 提交于 2019-12-18 12:52:28
问题 Microcontrollers often require a register to be read to clear certain status conditions. Is there a portable way in C to ensure that a read is not optimized away if the data is not used? Is it sufficient that the pointer to the memory mapped register is declared as volatile? In other words, would the following always work on standard compliant compilers? void func(void) { volatile unsigned int *REGISTER = (volatile unsigned int *) 0x12345678; *REGISTER; } I understand that dealing with

Bitwise transpose of 8 bytes

守給你的承諾、 提交于 2019-12-18 12:17:10
问题 I am looking for an efficient algorithm in C to bitwise-transpose 8 bytes of data. What I mean with this is that if I have 8 bytes like this: 00011100 00111000 00000001 00000000 11000000 00000000 11111111 01010101 I want to get the following 8 bytes: 00001010 00001011 01000010 11000011 11000010 10000011 00000010 00100011 And since I want to use this on an embedded platform, it should be as fast as possible :-) All ideas are much appreciated! 回答1: See Hacker's Delight, Chapter 7-3. 来源: https:/