Posts

Showing posts with the label embedded

Preventing torn reads with an HCS12 microcontroller

Image
Preventing torn reads with an HCS12 microcontroller I'm trying to write an embedded application for an MC9S12VR microcontroller. This is a 16-bit microcontroller but some of the values I deal with are 32 bits wide and while debugging I've captured some anomalous values that seem to be due to torn reads. I'm writing the firmware for this micro in C89 and running it through the Freescale HC12 compiler, and I'm wondering if anyone has any suggestions on how to prevent them on this particular microcontroller assuming that this is the case. Part of my application involves driving a motor and estimating its position and speed based on pulses generated by an encoder (a pulse is generated on every full rotation of the motor). For this to work, I need to configure one of the MCU timers so that I can track the time elapsed between pulses. However, the timer has a clock rate of 3 MHz (after prescaling) and the timer counter register is only 16-bit, so the counter overflows every ~...

'An error occurred while uploading the sketch' Arduino

'An error occurred while uploading the sketch' Arduino I am learning to receive data from the UART pins of the Arduino. I am using a SPEC Gas Sensor for the same. Here is the simplest code I could write. void setup() { Serial.begin(9600); } void loop() { if(Serial.available()>0) { Serial.print(Serial.available()); } } The code verifies but when I try to burn this code in the Arduino Uno, I get the following error after it says that the code uses 5% of the storage space. Sketch uses 1744 bytes (5%) of program storage space. Maximum is 32256 bytes. Global variables use 184 bytes (8%) of dynamic memory, leaving 1864 bytes for local variables. Maximum is 2048 bytes. avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x1e avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x66 avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x7e avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x06 avrdude: stk500_getsync() attempt 5 of 10: n...

How to find system memory addresses? (SPI Flash)

How to find system memory addresses? (SPI Flash) Device use eCos real-time operating system for embedded systems. I'm trying to read the particular areas of SPI flash memory, the communication with device using the command line interface. Flash Device Information: CFI Compliant: no Command Set: Generic SPI Flash Device/Bus Width: x16 Little Word Endian: no Fast Bulk Erase: no Multibyte Write: 256 bytes max Phys base address: 0xbadf1a5 Uncached Virt addr: 0x1badf1a5 Cached Virt addr: 0x2badf1a5 Number of blocks: 129 Total size: 8388608 bytes, 8 Mbytes Current mode: Read Array Device Size: 8388608, Write buffer: 256, Busy bit: Size Device Device Region Block kB Address Offset Offset Region Allocation ----- ---- ---------- ----------- --------- ----------------- 0 32 0x1badf1a5 0 0 Bootloader (32768 bytes) 1 32 0x1bae71a5 32768 ??? {unassigned} 2 64 ...