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

1
vote
1answer
45 views

STM32: Timer interrupt works immediately

This is code for timer in my project on STM32F429: ...
0
votes
3answers
36 views

Delay function using timer/counter 1

i have made a function called _MY_Delay() which use 16bit timer/counter1 in ATMEGA16 , and used this function to blink a LED . the problem is i didn't work and i don't know the reason , here is my ...
2
votes
3answers
258 views

How to calculate phase shift between two square waveforms with Arduino DUE

I have two square wave signals with the same frequency. I want to measure the phase shift between these two signals. There will be a small phase difference between two signals. (0-90 degree) and the ...
1
vote
2answers
36 views

Ethernet Port Listener Throughput Maximisation

We have a distributed sensor network (12 nodes), using Ethernet as the backend protocol. These are networked at 100Mb/s to a single 1Gb/s link using a 16-port switch. I've previously seen Java and C ...
0
votes
1answer
35 views

Receiving a whole string from USART on ATMEGA16?

I am trying to receive a string from USART but failed , i want to receive char by char and store them in an array until the user enter '\n' and finally display the string to LCD , here is my code: ...
0
votes
0answers
20 views

Logic Analyzer doesnt work in Keil uVision 5 with STM32F4 discovery

Logic Analyzer doesnt work in Keil with STM32F4 discovery (STM32F407VG). I am using uVision 5. All my drivers are up to date. The code gets compiled without any errors, however, I cant get the Logic ...
0
votes
0answers
159 views

STM32F205VC: USART framing error?

I'm trying to use USART in my program on STM32F205VC, but instead of sending my data I get some weird chars in PuTTY. I've used a Saleae Logical Analyzer and the result looks like this: This is my ...
1
vote
2answers
108 views

ADC Read function not working properly

I am working on a school project where I need to read a bunch of analog values and convert them to digital with PIC16F1788(datasheet). I wrote the function using C and xc8 compiler. The problem is ...
0
votes
1answer
44 views

Using PSMC instead of CCP

Hi I am building a motor controller and I decided to use PSMC instead of CCP to create my PWM, my decision was based on the fact that I dont have enough CCP ports on my pic 16f1788 for the project. I ...
1
vote
1answer
49 views

Operating frequency of microcontroller PIC18f4550

I am new to PIC Programming, and thought of blinking LEDs as my first project. Now I copied a code from net which blinks two LEDs and its working, the LEDs are blinking. My settings:- I haven't ...
1
vote
1answer
39 views

port masking and ports in pic

i have data at portb on microprocessor (pic), i need to compress three bits rb3,rb4, and rb5, the other pins are various IO on port b, i wish to compress that info held in those three pins on port b, ...
2
votes
1answer
22 views

Clock switching hangs when switching back to original source

MIGRATED TO EE.SE http://electronics.stackexchange.com/q/159634/69868 I am currently working on a project where the clock needs switching between the Primary Oscillator with PLL (POSCPLL) to the FRC ...
0
votes
4answers
143 views

Use of free() in PIC Microcontroller Programming

In my Microcontroller PIC18f4550 code, I am using a function which returns an array, I know, C doesn't allow to return an array so I am just returning the address using pointers. Now after the address ...
0
votes
1answer
8 views

PIC18 EEPROM fails to write

I am working on a project using a PIC18F26K20. I need to store several value in EEPROM, but it does not store any data, all I evers get back is 0xff. Here is the code I am using: ...
1
vote
1answer
40 views

PIC18f4550 Timer setup for 1sec Interrupt

I want to generate Interrupt(on PIC18f4550 using TIMER0) every 1 sec but by using the following code interrupt is generated after every 6 secs. ...
1
vote
2answers
42 views

#pragma statements in PIC18F4550 C programming

I am new to Microcontroller programming and I thought maybe I should try blinking around 24 LEDs as a self project using PIC18F4550. I searched for a simple 1 LED blinking source code on net and what ...
3
votes
2answers
708 views

How to include math.h on a PIC?

I know <math.h> can be a large amount of code to include, but want to test out something using sinf() on a low-cost PIC. ...
0
votes
0answers
22 views

rx62N debugging error

I have created a simple code in HEW(HIgh performance embedded workshop ---- compiler provided by renesas) for rx62N microcontroller and used E1 emulator for the integration of board and my pc. Now ...
1
vote
3answers
109 views

How to split a floating point number into individual digits?

I am helping a friend with a small electronics project using a PIC microcontroller 16F877 (A) which I am programming with mikroC. I have run into a problem which is that I have a floating point ...
1
vote
1answer
57 views

PWM LED using TIM1 on STM32

I need to PWM my LED on STM32F3 Discovery which is on PE8. I have found code which is using PWM on PA8 and PC8 (one using TIM1) but unfortunately I can't change it to PE8. How to do it? Or maybe you ...
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
69 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
43 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
27 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
57 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
500 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
131 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 ...
0
votes
1answer
42 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
45 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
51 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
55 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
65 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
93 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
82 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
49 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
110 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
34 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
41 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
85 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, ...
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
82 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
50 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
124 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
55 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
42 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
48 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
83 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
57 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: ...