embedded

How can I use the format! macro in a no_std environment?

喜你入骨 提交于 2019-12-01 16:28:33
问题 How could I implement the following example without using std? let text = format!("example {:.1} test {:x} words {}", num1, num2, num3); text has type &str and num1 , num2 and num3 have any numeric type. I've tried using numtoa and itoa/dtoa for displaying numbers but numtoa does not support floats and itoa does not support no_std . I feel like displaying a number in a string is fairly common and that I'm probably missing something obvious. 回答1: In general, you don't . format! allocates a

Safely detect, if function is called from an ISR?

北战南征 提交于 2019-12-01 15:46:39
I'm developing software for an ARM Cortex M3 (NXP LPC1769) microncontroller. At the moment I'm searching for a mechansim to detect if my function is called within an ISR. I asume that I have to check a register. Based on this information I would like to call difficult functions. I already checked the reference manual, if there is a register containing the necessary information. For example I tried to detect if I'm called from an ISR (I used SysTick-ISR) based on the "Interrupt Active Bit Register" (IABR) register. This register should be != 0 if an ISR is active. But the value was 0x00000000.

Pointer made from an integer in C on an embedded platform

北城余情 提交于 2019-12-01 15:10:15
问题 I came across the follow line of code: #define ADCA (*(volatile ADC_t*)0x200) It is for embedded C code for an AVR microcontroller. ADC_t is a union. I know that (volatile ADC_t*)0x200 its a pointer to an absolute memory address but I am still not quite sure what the first * means. 回答1: That first * dereferences the pointer. In other words ADCA is the contents of the memory at 0x200 . 来源: https://stackoverflow.com/questions/7522351/pointer-made-from-an-integer-in-c-on-an-embedded-platform

What does ((Port *)0x41004400UL) mean here?

本秂侑毒 提交于 2019-12-01 14:45:59
I'm working on a developing board that has a 32-bit ARM based microntroller on it (namely the board is Atmel SAM D21J18A). I'm still at the learning phase and I have a lot to go, but I'm really into embedded systems. I have some background in C. However, it's obviously not enough. I was looking at the codes of an example project by Atmel, and I didn't really get some parts of it. Here is one of them: #define PORT ((Port *)0x41004400UL) /**< \brief (PORT) APB Base Address */ Port is defined as: typedef struct { PortGroup Group[2]; /**< \brief Offset: 0x00 PortGroup groups [GROUPS] */ } Port;

Arduino interrupt alternatives

假装没事ソ 提交于 2019-12-01 14:10:25
From what I've read, the solution to my problem is to use an interrupt, but if I understand them correctly, I can't use a delay in the routine that gets called by the interrupt. I've got a large pushbutton LED switch. I want it to have a heartbeat while sitting idle, but once it's pushed, stay green and execute code. I can break the heartbeat() if I push the button enough times (I assume getting the state change at just the right time as it finishes a loop of the heartbeat ), but I'm stuck on how to make it work on the first click. Is there an alternative way to do what I'm attempting? void

How do you call an assembly function from C program?

不打扰是莪最后的温柔 提交于 2019-12-01 13:36:36
I am very new to Microcontroller programming particularly PIC18F87J11 , and I am using MPLAB C18 compiler. I was reading the datasheet for various topics such as saving to memory or working with timers. I noticed the examples are written in assembly language, but I have minimum experience with it. Is there a way to use the power of Assembly and C together in my project? I do not understand assembly that good or else I would try to convert the code to C, in this case, I rather just use the assembly code with few changes. Now can someone show me an example of how you would use an assembly

Arduino interrupt alternatives

此生再无相见时 提交于 2019-12-01 12:31:35
问题 From what I've read, the solution to my problem is to use an interrupt, but if I understand them correctly, I can't use a delay in the routine that gets called by the interrupt. I've got a large pushbutton LED switch. I want it to have a heartbeat while sitting idle, but once it's pushed, stay green and execute code. I can break the heartbeat() if I push the button enough times (I assume getting the state change at just the right time as it finishes a loop of the heartbeat ), but I'm stuck on

How do we trouble shoot a long-running NETMF program that stops in production?

一世执手 提交于 2019-12-01 12:28:17
Situtation I have a FEZ Cobra II NET running test code. It sends data every second to a server on the LAN. The server writes the data to a text file. After 27 hours and 97,200 successful sends, the Cobra stops sending. Clearly I am not going to debug for 27 hours, and I am not sure how else to trouble shoot, because standard software trouble shooting approaches do not apply. Question If I were to write to log errors on the Cobra, how would I access them? Does NETMF have application logs? How can we access them? Is there an event viewer? What other trouble shooting / debugging steps are viable

Android 4.0+ Bluetooth connection error to an embedded device: “Permission Denied”

醉酒当歌 提交于 2019-12-01 12:18:55
I have the following setup: An Android device uses a 'Client' socket to connect to a remote embedded device, The Android application uses the following code snippet to connect to the embedded device. On the embedded device uses MindTree BT stack, where server serial socket is prepared according to some properties in the device, which the Android application is familiar with, the connection defined on the embedded device, is not secured!! The combination of both applications works on: 2 LG phones different models (version code < 10 uses the "Normal method" ) 2 HTC's different models (version

What does ((Port *)0x41004400UL) mean here?

寵の児 提交于 2019-12-01 12:12:44
问题 I'm working on a developing board that has a 32-bit ARM based microntroller on it (namely the board is Atmel SAM D21J18A). I'm still at the learning phase and I have a lot to go, but I'm really into embedded systems. I have some background in C. However, it's obviously not enough. I was looking at the codes of an example project by Atmel, and I didn't really get some parts of it. Here is one of them: #define PORT ((Port *)0x41004400UL) /**< \brief (PORT) APB Base Address */ Port is defined as