embedded

Why are global variables bad, in a single threaded, non-os, embedded application

前提是你 提交于 2019-11-27 07:14:52
Most of the objections I see to using global variables make sense since they refer to issues of multiple threads, thread safety, etc. But in a small, single threaded, non-OS, case, what objections do you have? In my case, I'm writing my embedded system in "C", if it matters. I'm also the only developer on the product. Why would eliminating global variables make my code better? (After reading several responses, I realize I also should have pointed out that this system has no dynamic memory allocation (e.g. malloc). All the memory is statically allocated at compile time.) It wouldn't. The two

Reason to use the carry bit and the overflow bit

て烟熏妆下的殇ゞ 提交于 2019-11-27 07:11:25
问题 I am taking an Introduction to Embedded Systems Class. As I was reading, I encountered an interesting question on the implementations of the carry bit and overflow bit. I know what a carry bit and overflow bit is, however I cannot think of a situation in where someone would use a carry bit. One reason i thought was to align memory. Can someone shed light on this issue please? Thanks! 回答1: The carry flag is useful for efficiently performing arithmetic and logical operations on data that is

How to pause a pthread ANY TIME I want?

走远了吗. 提交于 2019-11-27 07:08:31
问题 recently I set out to port ucos-ii to Ubuntu PC. As we know, it's not possible to simulate the "process" in the ucos-ii by simply adding a flag in "while" loop in the pthread's call-back function to perform pause and resume(like the solution below). Because the "process" in ucos-ii can be paused or resumed at any time! How to sleep or pause a PThread in c on Linux I have found one solution on the web-site below, but it can't be built because it's out of date. It uses the process in Linux to

implementation of rand()

喜夏-厌秋 提交于 2019-11-27 06:46:00
I am writing some embedded code in C and need to use the rand() function. Unfortunately, rand() is not supported in the library for the controller. I need a simple implementation that is fast, but more importantly has little space overhead, that produces relatively high-quality random numbers. Does anyone know which algorithm to use or sample code? EDIT: It's for image processing, so "relatively high quality" means decent cycle length and good uniform properties. Check out this collection of random number generators from George Marsaglia. He's a leading expert in random number generation, so I

Are ARM instructuons SWI and SVC exactly same thing?

♀尐吖头ヾ 提交于 2019-11-27 06:38:06
问题 ARM assembly has SWI and SVC instructions for entering into 'supervisor mode'. What confuses me is, why there are two of them? Here it is said that SVC was formerly SWI. Does it mean that basically they changed the mnemonic? Are they the same thing? Can I use them interchangeably? Does one of them exist before an architecture, and other after? 回答1: Yes, SWI and SVC are same thing, it is just a name change. Previously, the SVC instruction was called SWI, Software Interrupt. The opcode for SVC

Direct Memory Access in Linux

独自空忆成欢 提交于 2019-11-27 06:19:18
I'm trying to access physical memory directly for an embedded Linux project, but I'm not sure how I can best designate memory for my use. If I boot my device regularly, and access /dev/mem, I can easily read and write to just about anywhere I want. However, in this, I'm accessing memory that can easily be allocated to any process; which I don't want to do My code for /dev/mem is (all error checking, etc. removed): mem_fd = open("/dev/mem", O_RDWR)); mem_p = malloc(SIZE + (PAGE_SIZE - 1)); if ((unsigned long) mem_p % PAGE_SIZE) { mem_p += PAGE_SIZE - ((unsigned long) mem_p % PAGE_SIZE); } mem_p

Cross-compiling mono for proprietary ARM device

久未见 提交于 2019-11-27 06:18:51
问题 Currently at work, we are developing software for some arm-elf little endian devices. We are currently doing this in plain C, which is a pain. Luckily for us the company who creates the devices provide c++ support, unfortunatly that same company has messed up the c++ libraries so the project fails at linker-stage of compilation, yay! So lately i've been looking at alternatives, and the most interesting alternative is mono. I can see that compiling mono for arm is mostly done in scratchbox,

Embedded C++ : to use STL or not?

旧巷老猫 提交于 2019-11-27 06:07:29
I have always been an embedded software engineer, but usually at Layer 3 or 2 of the OSI stack. I am not really a hardware guy. I have generally always done telecoms products, usually hand/cell-phones, which generally means something like an ARM 7 processor. Now I find myself in a more generic embedded world, in a small start-up, where I might move to "not so powerful" processors (there's the subjective bit) - I cannot predict which. I have read quite a bit about debate about using STL in C++ in embedded systems and there is no clear cut answer. There are some small worries about portability,

Is there any reason to use C instead of C++ for embedded development?

别说谁变了你拦得住时间么 提交于 2019-11-27 05:57:43
Question I have two compilers on my hardware C++ and C89 I'm thinking about using C++ with classes but without polymorphism (to avoid vtables). The main reasons I’d like to use C++ are: I prefer to use “inline” functions instead of macro definitions. I’d like to use namespaces as I prefixes clutter the code. I see C++ a bit type safer mainly because of templates, and verbose casting. I really like overloaded functions and constructors (used for automatic casting). Do you see any reason to stick with C89 when developing for very limited hardware (4kb of RAM)? Conclusion Thank you for your

Why do we need a bootloader in an embedded device?

本秂侑毒 提交于 2019-11-27 05:18:36
问题 I'm working with ELinux kernel on ARM cortex-A8. I know how the bootloader works and what job it's doing. But i've got a question - why do we need bootloader, why was the bootloader born ? Why we can't directly load the kernel into RAM from flash memory without bootloader? If we load it what will happen? In fact, processor will not support it, but why are we following the procedure? 回答1: A boot loader is a computer program that loads the main operating system or runtime environment for the