microcontroller

Serializing object to byte-array in C++

假装没事ソ 提交于 2019-12-01 18:30:17
I am working on an embedded device (microcontroller), and I want to save objects to permanent storage (an EEPROM). Most of the serialization solutions I can find, use the file-system in some way, but my target has no file-system. Therefore my question is, how can I serialize an object to a byte-array so I can save that byte-array to an EEPROM afterwards? Here is an example of what i am trying to do: class Person{ //Constructor, getters and setters are omitted void save(){ char buffer[sizeof(Person)]; serialize(buffer); EEPROM::Save(buffer, sizeof(Person)); } void load(){ char buffer[sizeof

Can't save baud rate settings?

落爺英雄遲暮 提交于 2019-12-01 18:04:11
The GSM modem I have is set to 115200 baud-rate by default. I have PIC18 Microcontroller connected to it with 19200 baud-rate. I changed the modem baud-rate to 19200 then saved the settings but every time I reset the modem, the baud-rate changes back to 115200. These are the following commands I used. Change baudrate AT+IPR=19200 Then I reopened the hyper-terminal (Putty) with 19200 baud-rate to save the current settings. Save settings AT&W But upon reset of the modem, the baud-rate changes back to 115200. I am using M6000 GSM/GPS Module(Tk115 Gps Tracker) but there isn't a lot of support for

Can't save baud rate settings?

别等时光非礼了梦想. 提交于 2019-12-01 17:38:22
问题 The GSM modem I have is set to 115200 baud-rate by default. I have PIC18 Microcontroller connected to it with 19200 baud-rate. I changed the modem baud-rate to 19200 then saved the settings but every time I reset the modem, the baud-rate changes back to 115200. These are the following commands I used. Change baudrate AT+IPR=19200 Then I reopened the hyper-terminal (Putty) with 19200 baud-rate to save the current settings. Save settings AT&W But upon reset of the modem, the baud-rate changes

How to make printf work on STM32F103?

时光毁灭记忆、已成空白 提交于 2019-12-01 14:14:53
I am new to the world of STM32F103. I have a demo code for STM32F103 and I am using arm-none-eabi to compile it. I tried what I could find on Google, but nothing worked so far. I have already spent three days on the problem. Anyone can give me a demo code for printf which works well? Part of my makefile: CFLAG = -mcpu=$(CPU) -mthumb -Wall -fdump-rtl-expand -specs=nano.specs --specs=rdimon.specs -Wl,--start-group -lgcc -lc -lm -lrdimon -Wl,--end-group LDFLAG = -mcpu=$(CPU) -T ./stm32_flash.ld -specs=nano.specs --specs=rdimon.specs -Wl,--start-group -lgcc -lc -lm -lrdimon -Wl,--end-group SamR

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 to make printf work on STM32F103?

故事扮演 提交于 2019-12-01 12:06:21
问题 I am new to the world of STM32F103. I have a demo code for STM32F103 and I am using arm-none-eabi to compile it. I tried what I could find on Google, but nothing worked so far. I have already spent three days on the problem. Anyone can give me a demo code for printf which works well? Part of my makefile: CFLAG = -mcpu=$(CPU) -mthumb -Wall -fdump-rtl-expand -specs=nano.specs --specs=rdimon.specs -Wl,--start-group -lgcc -lc -lm -lrdimon -Wl,--end-group LDFLAG = -mcpu=$(CPU) -T ./stm32_flash.ld

How do you call an assembly function from C program?

亡梦爱人 提交于 2019-12-01 11:42:44
问题 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

TraceBack (most recent call last), and GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM) errors

北慕城南 提交于 2019-12-01 06:57:39
I have been struggling with a script that will turn a Pi's BCM pins 17, 27, and 10 on for 1 second then off for 1 second sequentially 100ish times. When I run the script LED1 will turn on and then it turns off and the program shuts down with this error: Traceback (most recent call last): File "LedBlink.py", line 47, in <module> LED2Blink() File "LedBlink.py", line 27, in LED2Blink GPIO.setup(LED2, GPIO.OUT) RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM) import RPi.GPIO as GPIO import time LED1 = 17 LED2 = 27 LED3 = 10 GPIO.setmode(GPIO.BCM)