embedded

Embedded C: Registers Access

我怕爱的太早我们不能终老 提交于 2019-12-13 13:16:07
问题 Suppose we want to write at address say 0xc000 , we can define a macro in C as: #define LCDCW1_ADDR 0xc000 #define READ_LCDCW1() (*(volatile uint32_t *)LCDCW1_ADDR) #define WRITE_LCDCW1(val) ((*(volatile uint32_t *)LCDCW1_ADDR) = (val)) My question is that when using any micro-controller, consider an example MSP430, P1OUT register address is 0x0021. But when we use P1OUT=0xFFFF; // it assigns P1OUT a value 0xFFFF. My question is how does it write to that address e.g. in this case 0x0021. The

Sparc Function compilation alignment

半城伤御伤魂 提交于 2019-12-13 12:50:37
问题 I want my program such that each function in the binary has some space left after it ends. So that later if some minor change is required only that function is changed with the extra space acting as room for accounting the minor change. -falign-function can do the job but it will not give consistent space. Is there anyway to do it? Or better way to do it? 回答1: You could use an inline assembly statement to add a series of nops at the start (or end) of each function. Then later when you need to

Optimizing of game objects placement in a 2D Game

拜拜、爱过 提交于 2019-12-13 12:36:30
问题 I'm cloning a centipede game, but for now I'm writing it on a PC. I would like to spread the mushrooms over the screen in a random position, but they shouldn't overlap with each others. The worst case for doing that is an O(N^3) algorithm where you check for one mushroom for each other mushrooms and then check the distance or intersection, then take another best random position. A Pseudo code is here using Actionscript: for (var i:int = 0; i < m_bricks.length - 1; i++) { for (var j:int = 1; j

How to correctly nandwrite a nanddump'ed dump with oob?

拈花ヽ惹草 提交于 2019-12-13 12:32:03
问题 I am struggling on flashing a previous ROM dump of an embedded device in Linux. My previous dump contains oob data. I wrote it with nandwrite -n -N -o /dev/mtd0 backup.bin , and then take a ROM dump again. By comparing the old and new ROM dump, I see some un-explainable situation: the last 24 bytes of the oob (ecc bytes) of any empty blocks (filled with 0xFF) is ought to be 0xFF also, but those in the new ROM dump is filled with 0x00, causing later write failures. oob ought to be: FFFFFFFF

Put gcc libs .data in specific section?

牧云@^-^@ 提交于 2019-12-13 12:31:25
问题 I'm trying to switch to the GNU GCC compiler for our embedded system, but I'm having trouble linking the project as the memory layout of our chip is split: RAM section 1: 0x10000-0x12FFF RAM section 2: 0x18000-0x1BFFF The data from our project can fit in section 1, but the data linked from the gcc libs doesn't. Map file extract: .data 0x00012974 0x3c4 c:/tools/gnucr16_v1.1.3-elf/cr16-elf/bin/../lib/gcc/cr16-elf/4.5.1-GNUCR16_v1.1.3/../../../../cr16-elf/lib\libc.a(lib_a-impure.o) 0x00012974

busybox in embedded linux shows “applet not found”

情到浓时终转凉″ 提交于 2019-12-13 11:50:21
问题 I compiled busybox myself,and I put it in our embedded linux. But I have some questions. Question 1:When I try to use some command such as gzip,it prints "gzip: applet not found".While I checked the menuconfig of busybox,I make sure that I've selected "gzip". Question 2:I used to work with VIM,but busybox just provide VI.So I make a link VIM to VI,but when I typed vim and run it,it also show "vim: applet not found". Anybody can help me with this problem that "applet not found"? Thank you very

How to illustrate an interrupt-driven process?

谁说胖子不能爱 提交于 2019-12-13 11:42:27
问题 This question is related to diagraming a software process. As an electrical engineer, much of the software I do is for embedded micro-controllers. In school, we learned to illustrate our algorithm using a flowchart. However, nowadays, many of my embedded projects are heavily interrupt-driven where the main process runs some basic algorithm a variety of interrupt sources provide its stimulus. So, my question is, what are some diagramming techniques that I can use to illustrate my process such

State Machine with no function pointer

徘徊边缘 提交于 2019-12-13 11:35:24
问题 I have implemented a complex state machine with numerous state transitions for a safety SIL 4 system. The back bone for this implementation was done using function pointers. When all was sailing smoothly, the V&V opposed the use of function pointers in a SIL 4 system. Reference- Rule 9 NASA.Misra C 2004 however doesnt say that function pointers cant be used. Is there any other way to implement complex state machines without any function pointers? 回答1: First of all, that NASA document is not

String to double function returning infinity result in embedded compiler

ε祈祈猫儿з 提交于 2019-12-13 10:02:33
问题 I'm trying to perform string to double conversion. In gnu c compiler I'm getting correct values. But if I use it in my embedded compiler (renesas CS+) it is giving undefined behavior like returning infinity result. Here is my code: double str_to_double_func(char a[]) { char str[30] = {'0'}; int loop ; double result; int len ; int pos,n; for(loop = 0;a[loop]!='\0';loop++) { str[loop] = a[loop]; } str[loop] = '\0'; pos = 0; len = sizeof(str)-1; for (n = 0; n < len; n++) { if (str[n] == '.') {

Is this expression correct in C preprocessor [closed]

蓝咒 提交于 2019-12-13 09:55:37
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I want to do the following arithmetic functions in a C pre-processor include statement when I send in the variable x . #define calc_addr_data_reg (x) ( base_offset + ((x/7) * 0x20) + data_reg_offset) How would I