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 ...
16
votes
10answers
4k views
Programming languages for electronics engineers
I am an Electronics and Communications Engineering student, before I got to college, I have been interested in programming and computer applications. I had focused on designing Windows applications ...
4
votes
4answers
635 views
ADC registers setup using spi communication
I'm new to microcontrollers - I'm trying to read external ADC values from an AD7798 ADC using SPI communication.
Initially I have to setup some ADC registers - some registers are not configured. To ...
15
votes
8answers
6k views
Fast and memory efficient moving average calculation
I'm looking for a time and memory efficient solution to calculate a moving average in C. I need to avoid dividing because I'm on a PIC 16 which has no dedicated division unit.
At the moment, I just ...
4
votes
4answers
1k views
Problems communicating with I²C RTC
I'm using PIC18F4680 to work with PCF8583P RTC using C18 compiler (and compiler's library functions for hardware \$I^2C\$) and I can't figure out how to read data from it or to determine if written ...
16
votes
2answers
910 views
C coding design - function pointers?
I have a PIC18F46K22 and program it with the XC8 compiler. In the end, I'll have a system like a pc with stdin and stdout. So in ...
8
votes
5answers
3k views
Start off with embedded C with ATmega32 (ATmega AVR series)
I have a ATmega32 board laying around and I figure it would be perfect to start off with microcontrollers. I once did some babbling in embedded C (thats when I got this board) but the flow was stopped ...
4
votes
3answers
5k views
How do I modulate PWM frequency in realtime with a Microchip dsPIC?
I'm trying to change the PWM output frequency roughly once a millisecond using a dsPIC33FJ256GP710, and I'm having mixed results. I first tried this:
...
3
votes
1answer
666 views
PIC18F4520 ADC Conversion in MC18
I have a dilemma.
I need to read ADC values from PIC18F4520. My configuration, and code, is as follows:
...
4
votes
4answers
438 views
Implementing an I2C buffer in C
I'm implementing a read-only I2C slave on a PIC18F4620. I have made a -working- ISR handler for the MSSP module:
...
1
vote
3answers
689 views
Invensense IMU3000 with PIC
Has anybody experienced using the Invensense IMU3000 gyroscope with some microcontroller?
The hardware comes with a really good library integrating full control of its features. This library is ...
0
votes
2answers
277 views
LED Breathing Effect
Please consider the following code:
for(;;)
{
int i=0;
TPM1C2VL =~ (i<<1); // Channel Value(Lower)Register.
TPM1C2VH +=TPM1C2VL;
}
ALTERED CODE
...
8
votes
1answer
350 views
What is slew rate for I2C?
I'm configuring I2C on a PIC18 using the built-in functions of the C18 compiler as described in section 2.4 of the documentation:
...
8
votes
5answers
723 views
What's wrong with this casting in C code for AVR?
I defined two variables:
uint8_t a[2];
uint16_t b;
Next I want to use a as variable of type ...
5
votes
5answers
485 views
Integer to ASCII in C18
I'm writing code for a PIC18F46K22 using the C18 compiler. I want to write the value of an integer \$n\$ in ASCII over the USART to my PC.
For \$n<10\$, it's easy:
...
3
votes
1answer
85 views
Integers >9999 in PIC C18
In this answer, I made a function to convert an integer to an ASCII string:
...