C is an imperative (procedural) systems implementation language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C ...

learn more… | top users | synonyms

0
votes
1answer
5 views

interfacing ultrasonic range sensor(HCSR-04) with ATmega32?

I am a newbie in using the sonar sensor HCSR-04 with AVR ATmega 32a. I have written some code to help me understand the concept of how the sensor works, but the device isn't giving any results even ...
7
votes
4answers
1k views

My first STM32 code - please criticize me

I have just wrote my first code on STM32 - blinking LED. It combines a fragments from different sources; please criticize me so I can learn how to write proper code and don't learn stupid habits. ...
4
votes
3answers
46 views

interrupt using Timer0 on PIC18f

Im looking for a little help and advice on my code. Im using C18 in the MPLab environment, PIC18f4520 with Fosc @ 4MHz, and usnig timer0 in 16 bit mode to count to overflow, set the overflow bit and ...
1
vote
0answers
30 views

Strange behaviour using PWM on CortexM3

I have a board with the ATSAM3S2BA-AU, which is a Cortex M3 uC. I need to use 2 PWM channel , here how I've done it : ...
0
votes
0answers
22 views

Is source code compatible between DE2 and DE2-115?

I have 2 FPGAs: Altera DE2 and DE2-115. I was reading that source code is compatible between different computers and different cores. I have written a C program for use with the Micrium ucos rtos with ...
2
votes
1answer
35 views

Using different putch() function in a library

I'm writing a C library for PIC18 microcontrollers that will communicate with the ESP8266 chip over the UART bus. I would like to use the printf() function to send ...
5
votes
3answers
410 views

How to read whole data sent to USART with interrupt?

I am currently able to read byte by byte from USART with this code ...
1
vote
1answer
58 views

PIC12F683 or PIC16F688 assembly or C blinking LED example with XC8 compiler, MPASM or gputils

Hello I am new to PIC programming and I finally have got my dev environment working, I downloaded the XC8 compiler from microchip and also as backup I downloaded the gputils assembler. I have not been ...
-5
votes
0answers
43 views

FPGA to C Variable Transfer [closed]

Is there a way to actively send data to a computer program written in C in order to utilize that data within the program?
0
votes
1answer
34 views

STM32F4 - counting DMA wraps

I am using DMA on an STM32F4 Discovery board to push values from an array into a peripheral. This needs to be done repeatedly, so I am using the circular DMA mode: ...
0
votes
0answers
33 views

Bootloader for AT32UC3C264C

Thank you in advance. I am trying to program a bootloader for my AT32UC3C264C chip. I want to update my firmware using bootloader. I haven't have experience with bootloader before but I did some ...
-1
votes
1answer
40 views

STM32F205 - can i use a timer to generate a low pulse of specified length

I want a pin to be high by default and then generate two 125-250 µs pulses with 0.1 µs resolution using a command. I was thinking about using TIM1 in one-pulse mode but I don't see a way to invert the ...
0
votes
1answer
44 views

How float to binary conversion works

I was looking for solution how convert float value to binary in STM32 and I found this: float foo = 1.23; uint32_t bar; bar = *((uint32_t *)&foo); My ...
0
votes
3answers
63 views

Code advice with minimum clock cycles

My original question was: I've a 8 bit data with only 3 bit used, for example: 0110 0001 Where 0 indicate unused bit that are always set to 0 and 1 indicate bits that change. I ...
1
vote
1answer
84 views

Blinking an LED as a function of signal frequency

I wrote a function for interacting with my 'PIC16F1788'. The code sends pulses out the 'RC4' port at a specific frequency, to make an LED blink according to that frequency. So the LED will blink ...
1
vote
1answer
59 views

float to short conversion error in c

I implemented dc motor speed control project but there is one problem which i am not able to figure out .The problem is that my pid output which is float when assigned to short data type gives ...
2
votes
1answer
40 views

Frequency measurement using PIC

I am trying to write a program that measures the frequency of a signal. So I think a way to do it is to set the timer0 interrupt at every rising edge then record that value and subtract two successive ...
1
vote
1answer
101 views

Atmel printf formatting doesn't work, no formatting does work

We are running an Atmel AVR32 chip on our board, and recently discovered that printf with format/conversion specifiers doesn't work. A regular ...
0
votes
1answer
32 views

Output of TMR0 register in pic16f877A

I wrote a simple frequency counter program in which TMR0 is 500ms timer and TMR1 as counter. Everything is working fine but what i din't understand is that TMR1 register output is hexadecimal or is ...
0
votes
0answers
32 views

implemented feedback loop to count pulses but loop doesn't work

I am implementing feedback loop which count number of pulses from optical encoder and convert it to rpm(speed). But i noticed that number of pulse count remains same irrrespect of the motor speed. I ...
1
vote
1answer
81 views

Do global variables consume more power than local variables in embedded systems?

Today my colleague from work said that access to global variables on microcontrollers consumes more power than access to local variables, unfortunately she did not explain that. At the beginning, ...
-2
votes
0answers
62 views

Counter working in Proteus despite misconfiguration - how is it possible?

I wrote a simple code in which TMR0 is working as a counter. It simply counts the pulses supplied from a square wave generator. By mistake I set the ...
0
votes
0answers
25 views

how to write program that microcontroller pin as input as well as output at different time..? [duplicate]

Can I program the 8051 uc pin as input and output..? I want to get data from one pin and send some data to same pin as output???
-1
votes
1answer
66 views

frequency counter code error in pic

Below is my code to count the pulses at RC0 pin of pic16f877A . I applied a square wave at rc0 to count pulses. i used TMR0 as 500ms timer and TMR1 as counter . but the problem is that tmr1 doesn't ...
0
votes
1answer
39 views

Atme ICE basic connection

I got Atmel ICE basic, 6pin wire and atmega 1248, how I should connect the pins. I tried to look from data sheet, but I cant sent the code in atmega. ...
2
votes
2answers
121 views

Writing one program for different microcontrollers

I got 2 totally different microcontrollers (one is 16-bit MSP and another 32-bit nordic). They are supposed to do the same task and I thought that maybe it would be posible to write one program in C ...
-1
votes
1answer
45 views

Functions in Mikroc [closed]

Below is my code it gives error as "all functions and variables not defined" Please help I wrote a program for speed control of dc motor for pic18f8722 In Mikroc Please help ...
-3
votes
1answer
38 views

Unable to connect UART/USART2 in STM32F407ZG

When I try to connect to PC using UART/USART2 on platform STM32F407ZG is not working, Here is the following code which I used, ...
0
votes
0answers
40 views

USB to RS485 converter: Auto enable control

I have been trying to program infineon mcu via usb to rs485 converter. Procedure to check mcu is working fine: Query command sent using hercules : 0x80 Response sent by mcu : 0x55 (correct response) ...
2
votes
1answer
80 views

AVR GCC: How do I improve code optimization

I tried to compile he following C code: period = TCNT0L; period |= ((unsigned int)TCNT0H<<8); The assembler code I'm getting is the following: ...
2
votes
2answers
48 views

How to automatically allocate a page of flash for in-application storage of settings

I've been using the LPC8xx range of Cortex-M0+ MCUs quite successfully. One difficiency: these don't have inbuilt EEPROM (to preserve settings across power cycles etc). However there is a work-around: ...
0
votes
1answer
74 views

How to communicate 'rawly' with an HD44780 compatible LCD?

I have a HD44780 compatible lcd display (QC1602A). I did a lot of research and found some helpful things, but none of then seemed to really have worked. I'm not using any lcd library (C), only the ...
3
votes
1answer
52 views

STM32 Semihosting - SIGTRAP received when printf called

Have followed this guide here (http://www.wolinlabs.com/blog/stm32f4.semihosting.html) to get semihosting on the STM32F103 working. Basically my goal is to get printf working over JTAG (ST-Link/v2). ...
0
votes
1answer
36 views

MPLABX macro expansion

I am using MPLABX v2.25 and XC32 compiler v1.33 on a Mac. Maybe I am not fluent with the use of the preprocessor, but the macro expansion window in MPLABX seems to produce rather unexpected results. ...
2
votes
1answer
94 views

What benefits are there to programming an MSP430 in C/C++ over Energia?

I'll start by saying I'm new to micro-controller programming. I've had some (ca. 30 years) experience programming, and some of that was writing C/C++ but those days are long behind me now. Since I'm ...
1
vote
0answers
39 views

Is there a way to disable an UART terminal? [closed]

I have an embedded PC running Linux (master) and communicating with an external board (slave) through an UART terminal. Only 3-wires are used: RX, TX and ground. The power of the slave board is also ...
0
votes
1answer
69 views

need help making a c program that reads flow meter

For the past week, i've just started my first ever project to make a C program for a PIC16F877A under MikroC, where I would get pulses in from the flow meter and calculate the flow rate, then output ...
0
votes
1answer
67 views

Help understand a simple C code for an atmega16 project [closed]

I just got started with AVR , and I am building a Lan tester for a project My hardware part is done, basically for the send pins I used port A , from A0 to A7 and for the Receiver port C when the ...
0
votes
0answers
89 views

CAN bus on STM32F429 receiving messages

I am using the STM32F429 HAL CUBE for a CAN bus implementaion. I am able to transmit some CAN bus messages, but my receive function is not working. Is it compulsory for receiving messages to write a ...
8
votes
4answers
2k views

Why GCC compiler omitting some code?

I can not understand why GCC compiler cutting out part of my code while it preserve absolutely the same one in the neighborhood? The C code: ...
0
votes
1answer
90 views

Arduino ECG sputtering out totally random values

Hello StackExchange community, I have encountered a problem in my ECG/EKG design. I am trying to create the ECG using Arduino as a microcontroller to send/retrieve heart rate measurements via ...
-4
votes
1answer
46 views
0
votes
0answers
27 views

DS2401 initialization and usage

I have never worked with OneWire before and I am now trying to make the DS2401 Serial Number work, but without luck. Of course I started by reading the datasheets for the Serial, but I did not really ...
0
votes
3answers
72 views

LCD not working!

I am using a PCI1602F-B from Powertip as an LCD and an ATmega8 to communicate with it. Connection: -PORT D of ATmega8 with data-bus of LCD -PORT B0 of ATmega8 with Rs pin -PORT B1 of ATmega8 ...
2
votes
1answer
95 views

Is printf debugging over USB with STM32 possible?

I've been doing a lot of searching to try find some examples for printf debugging over USB for the STM32 (specifically stm32f1x). I have found a few examples for UART/USART however I can't find any ...
2
votes
0answers
91 views

How can I log information from code in IAR Embedded Workbench to a log file?

I'm trying to develop an application for the NXP LPC1788 microcontroller and I would like to be able to log formatted strings at arbitrary points within the source code to a log file in a way that has ...
1
vote
0answers
64 views

CRC32 on SAM D20 (Cortex M0+)

I've been having a hard time debugging the DSU module on a SAM D20 (datasheet). I mean to utilize it to calculate CRC32 for a program I'm uploading through a custom bootloader (bootloader not mine). ...
1
vote
1answer
79 views

'undefined reference to' errors trying to compile with Make

I had a working Makefile that successfully compiled and built a basic program to toggle and LED on my stm32-h103 board. I have since attempted to add and use FreeRTOS in my program. I have added in ...