Tagged Questions
0
votes
2answers
246 views
Creating a lookup table in a microcontroller using in C
How can I create a lookup table in a microcontroller using C? I have one input and one output and want to implement a lookup table in C.
1
vote
1answer
44 views
Difference between SMPEND and SMPMID
I'm interfacing an SPI chip with a PIC18 device, programmed with a C program compiled with the XC8 compiler, using libraries from plib.h. In the docs, I read:
...
0
votes
1answer
52 views
PIC32 Issue with using JTAG Pins as Analog Inputs
I'm trying to read in a value using a few analog pins on a PIC32 (MX775F512H), including RB12-- part of the JTAG pins on the device. The device the board is reading from works great, but the board ...
2
votes
2answers
130 views
ExternalDifferential ADC Values for PIC
I have a temperature sensor design that I'm using as a reference. It takes 2 RTD sensors and reads their values with a Dual Channel 16-bit Differential ADC. The ADC interfaces through the SPI bus.
...
2
votes
1answer
83 views
Bit Banging UART
My full code is located here.
Basically, I'm transmitting to an Arduino, and I'm not receiving the correct value (you'll notice I'm trying to send d'22'). Here's the method where I actually bit bang ...
2
votes
2answers
78 views
Char array at an int in C18
In Jal, it's possible to do something like this:
var word the_var = 0x1234
var byte the_array[2] at the_var;
Now you can easily access the bytes of the word ...
1
vote
2answers
87 views
Receive bytes from UART camera
I am using a dsPIC33E MUC to interface an UART camera(VGA) at 115.2Kbps. The purpose is to save an image to a SD card.
The program I wrote works well except that it's inside a loop checking if the ...
5
votes
1answer
164 views
Serial Communication over 1 Pin?
Okay guys, I'm in a bit of a pickle here. I have the following circuit:
As you can see, pin 3 is my only output. I've actually already had this board printed, so there's not much room for ...
3
votes
4answers
259 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:
...
7
votes
1answer
102 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:
...
1
vote
1answer
41 views
Get bytes from a short long in C18
I'm using the C18 compiler and need to get the three bytes of a short long from MSB to LSB. I'd say I could use this:
...
4
votes
1answer
95 views
Which SPI mode to use?
I'm interfacing a 23LC1024 SPI Serial SRAM with a PIC18, using the C18 compiler and the built-in functions from <spi.h> as described in the Compiler ...
1
vote
4answers
162 views
Different ASCII Characters in RS 232
I'm working on the UART communication of PIC18F4520. I have tried simulating the code on ISIS proteus and then also checked the real time result. One thing I am quite confused about is that the ...
7
votes
2answers
75 views
Detecting overflow with C18
I'm implementing a calculator in a microcontroller which is controlled over the serial port. For example, I'd send 1234*5678= and it would reply with ...
3
votes
1answer
66 views
Integers >9999 in PIC C18
In this answer, I made a function to convert an integer to an ASCII string:
...
5
votes
5answers
246 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:
...
0
votes
2answers
79 views
Read from UART seems to overwrite while in buffer
I am reading sending data to a PIC32MX7xx using UART. The data frames are all 6 bytes long, no exception.
The problem I am facing is that when there are 6 bytes waiting to be read and I send another ...
1
vote
3answers
128 views
Controlling 8-bit DAC Output over I2C— decimal to binary char conversion help
Clarifying my question a bit. We're using a PIC32 board with an MCP4706 8-bit DAC, controlled over I2C. If we write a binary value (e.g. 0b00000100) to the DAC, it outputs as expected. However, ...
0
votes
1answer
55 views
PIC24H delta time calculation
Hello I'm making a project for my intro embedded software class and I need to make use of a timer in a program. If I'm not mistaken this code should be looping the while for at least 500 ...
0
votes
1answer
59 views
PIC24H POT input to control LED blink delay not linear
Hello I'm using the PIC24H microprocessor and I wrote a simple program that takes input from a POT using analog input which is then set to a modulus value of delay. It does seem to set the delay, but ...
3
votes
1answer
73 views
Difference between USART's synchronous and asynchronous mode
I'm writing software to initialise the EUSART1 module for RS232 on a PIC18F46K22. I'm using the usart.h library, built-in in the C18 compiler. There is some reference in MPLAB C18 C Compiler Libraries ...
-2
votes
1answer
66 views
spidev_test.c analysis [closed]
I'm trying to connect a Raspberry Pi with a PIC32 through SPI. For RPi I'm using the spidev_test.c code (I'm modifying it to suit my needs) but... because I'm a novice in programming hardware, I'm ...
2
votes
1answer
80 views
PIC18 - problems getting inline assembler routine to work
(EDIT: Added C18 disassembly code)
I need to optimize a function written in C for a PIC18f4585. I am using C18 to compile.
The function I am trying to re-write in assembly is:
...
1
vote
2answers
93 views
I2C with PIC32 and MCP4706 Not Working
We're working on a battery charger for an electric bicycle at the moment, but prototyping with a PIC32MX695F512H kit board and an MCP4706 DAC soldered onto a breakout board, programmed using a ...
0
votes
2answers
166 views
PIC18 Robot - Travelling exact distance straight using two wheel encoders problems
(EDIT: Added TMR0 & TMR1 set-up code)
I have a small robot vehicle controlled by a PIC18f4585. It has two wheels (ball bearing on the front) as well as two rotary encoders. The following ...
2
votes
3answers
158 views
Why pic18fxxx microcontrollers is better for C language
Pic18fxxx family has a lot advantages and improvements from the pic16fxxx family of microcontrollers. What is the particular feature that make them better for C programming than the pic16fxxx devices? ...
5
votes
1answer
408 views
Interrupt Service Routine in C - function at specific address
I need to add an Interrupt Service Routine (ISR) to existing code in C for a PIC18F4620 and a PIC18F46K22. As you can see in section 9 (of both datasheets), these devices have multiple interrupt ...
1
vote
1answer
225 views
How to change the frequency of PIC internal oscillator?
Internal oscillator of PIC16f884 doesn't change frequency in the following code:
...
1
vote
0answers
153 views
PIC32 read feedback from UART
I'm using a PIC32MX795F512H to set up a Roving RN-131 wifi module using UART.
I can communicate with the device but I want some feedback whether my commands are processed or not.
I basically need to ...
1
vote
2answers
294 views
PIC24 - multiple PWM duty cycle changes
Apologies in advance due to my lack of experience with embedded C.
I am working on a PIC24FJ64GA004 project in which a 16-bit PWM value need to be changed multiple times. I am using MPLAB IDE and ...
1
vote
1answer
185 views
How to get two buttons to work with the 16f628a - C, Hi-tech comp, mplabx
I'm just began exploring my new hobby - mcu electronics. I have bought an 16f628a after reading some forumposts suggestion that is a good mcu for beginners.
I have download mplabX, the hi-tech ...
1
vote
1answer
193 views
EEPROM and CONFIG macros on PIC with HI-TECH compiler
I have seen 2 lines of source code that I can't find documented anywhere. They are:
...
15
votes
2answers
732 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 ...
3
votes
3answers
200 views
Can I pass a bit register as a function argument in Hi-Tech C compiler for PIC16?
Is there a way to pass a bit from a PIC's register as a function parameter?
Taking, for example, the PIC16F887, its registers (SFRs) and individual bits are defined as fallows in the corresponding ...
2
votes
3answers
808 views
Starting with I2C on PIC18s
For a project I'd like three PICs (two slaves PIC18F4620, one master PIC18F46K22) to communicate over the I2C bus. Later on, more slaves may be added (like EEPROM, SRAM, ...). I'm writing the code for ...
2
votes
2answers
312 views
Software PWM on a PIC10F202 (looped fading LED)
I'm currently trying my best to code a software solution for PWM on a PIC20F202 but I have one issue. I'm trying a looped fade out and fade with a LED and it's doing fine and very smoothly but on ...
0
votes
2answers
566 views
PIC: Global variable not modified inside interrupt handler
I have an interrupt handler for my PIC 16 that should modify a global variable. The global variable is then read by main() in an infinite loop.
For some reason, it ...
4
votes
2answers
312 views
PIC24 Internal Oscillator and Instruction cycles
I have some relative experience on AVR but just minimum with PICs. In order to start a project I've just wanted to verify that I was able to get the internal oscillator working at the right ...
2
votes
0answers
239 views
How do I modulate PWM frequency in realtime with a Microchip dsPIC (or PIC24)? [closed]
This question is a direct continuation of the question/answer found at the link below. Skip to the last answer/comments given, as this is where my question begins (I don't have enough rep. points to ...
1
vote
3answers
471 views
PIC18f4520 programming error
I am trying to run a program on PIC18F4520 using PicKit3 & MPLAB IDE. But I am getting an error:
PK3Err0040: The target device is not ready for debugging.
Please check your configuration bit ...
2
votes
1answer
275 views
c18 assembly inside function problem. unidentified label (bit names)
Here is the data_write function I'm looking at. I've been told that this method (from the textbook) is not good and I should be using the C method (that is currently commented out). When the Cbits ...
2
votes
3answers
501 views
c18 coding advice / braces error / function declaration help
I have almost NO experience coding so please excuse the crude style and verbose commenting. I am trying to sample from 4 sensors (1 every 15 minutes). I thought it would be more efficient to have the ...
4
votes
1answer
2k views
Timer Interrupt being called everytime - Pic16F877A and CCS PIC C
I am currently trying the following example
...
3
votes
2answers
623 views
Increasing the Watch Dog Timeout PIC 16F877A - CCS PIC C
I have been trying to look around for an example on how to increase the watchdog timer but unfortunately I cant find any. The only example that is included in the example uses ...
5
votes
4answers
742 views
How to Wire a PIC Microcontroller?
I'm completely new to the world of PIC Microcontrollers and electrical engineering so please go easy :)
Anyway, I managed to program my PIC 16f627 to turn on three LEDs when push button (trigger ...
1
vote
2answers
601 views
How to use the SET_TRIS_B function in PIC C
Suppose I want the following settings
B7 B6 B5 B4 B3 B2 B1 B0
0 0 0 0 0 1 0 1
I want B0 and B2 to be input and the rest to be output so I did the ...
2
votes
1answer
803 views
How to use interrupts in micro C
I am making a robot which can follow lines, avoid obsercals and follow arrows. I wrote code for line following and arrow following but I don't know how to implement interrupts with more than two ...
1
vote
2answers
266 views
PIC16F SSPADD Causing SCL To Go Low Early
I am not able to communicate with my RTC (PCF8563). I am trying to communicate with it using a PIC16F876 over the I2C bus. The code below is all I am doing in my main(). I am unable to receive an ACK ...
6
votes
3answers
267 views
Extraneous loop produced by PIC compiler from MicroChip
We're using the Lite version of the MicroChip PIC compiler so maybe that's the reason, but this simple one-bit shift is generating a loop where none is necessary. Since the shift count is 1 (a ...
6
votes
6answers
1k views
What is the reason my PIC16 multitasking RTOS kernel doesn't work?
I am trying to create a semi-pre-emptive (co-operative) RTOS for PIC x16 microcontrollers. In my previous question, I've learnt that accessing hardware stack pointer is not possible in these cores. I ...
