The PIC18 series 8 bit microcontrollers manufactured by Microchip Technology.
Questions tagged [pic18]
230 questions
2
votes
2 answers
Setting up a C project with multiple source files in MPLAB
I'm using the MPLAB IDE and the XC8 compiler for a C project for PIC18 devices. I'm building a project with multiple source files and don't know how to make the structure.
In the project, I have the following things:
A file main.c where the main…
user1544337
2
votes
2 answers
Conflicting declarations in XC8 when using extern struct
I have a variable that is a struct, defined in a .c file:
struct {
int write_cursor;
int read_cursor;
message messages[10];
} out_messages = {0, 0};
To make it available in other files I have an .h file with:
extern struct {
int…

AndreKR
- 32,613
- 18
- 106
- 168
2
votes
0 answers
PIC18F45K22 EUSART1 receive and show on hyper terminal
#include
#include
char uart_rd;
void main(void)
{
ANSELC = 0;
Open1USART(USART_TX_INT_ON & // disables transmission interrupt
USART_RX_INT_OFF &// disables reception interrupt …

akumar
- 49
- 1
- 9
2
votes
1 answer
Alternative ZigBee Stack
Is there any stack that can be an alternative for the Microchip ZigBee Stack? I have a PIC18F27J53 microcontroller and MRF24J40MB Transceiver. I tried to read and understand the examples included in the Microchip ZigBee Stack but I have no luck. I…

edmandie
- 71
- 1
- 4
2
votes
1 answer
What does the Timer1 RD16 bit do on PIC18 microcontrollers?
I'm really confused. The manual says:
RD16: 16-bit Read/Write Mode Enable bit
1= Enables register Read/Write of Timer1 in one 16-bit operation
0= Enables register Read/Write of Timer1 in two 8-bit operations
However, there doesn't actually seem to…

Nate
- 26,164
- 34
- 130
- 214
2
votes
1 answer
ADC Set up for pic18f1xk22 in C
Beginner trying to learn ADC setup, but unfortunately most examples online are for other pic18 models, and I don't have the adc.h definition as a resource. (Or else not for C code.) Don't want to be spoon-fed an answer really, but if anyone could…

jos
- 431
- 2
- 9
2
votes
0 answers
Microchip C18 naked function
Someone knows a way to declare a naked function on C18 compiler?
By naked function I mean function without any epilogue and prologue.
in gcc I use:
__attribute__((naked)) int func(int par1)
Maybe a #pragma or some trick to have the same…

Gustavo Vargas
- 2,497
- 2
- 24
- 32
2
votes
3 answers
Reading state of input pins on a PIC18
I have been able to get outputs working on my PIC and can make a bunch of LEDs dance on and off as I set various output latches high/low. However, I'm having a lot o difficulty reading in the state of a pin.
See the code below. I set up my config,…

Ozzah
- 10,631
- 16
- 77
- 116
1
vote
2 answers
Why won't this PIC code light up my LEDs?
The following code won't set any of the pins high on my PIC18F14K50, yet it couldn't be simpler!
#include
#include
void main(void)
{
// Set ALL pins to output:
TRISA = 0;
TRISB = 0;
TRISC = 0;
// Set ALL pins to high:
…

Ozzah
- 10,631
- 16
- 77
- 116
1
vote
3 answers
C performance on a PIC board global variables vs. method local
All,
I have C functions that are called many times a second as they are part of a control loop on a PIC18 board. These functions have variables that only need method scope, but I was wondering what if any overhead there was to constantly allocating…

schmouder
- 105
- 2
- 7
1
vote
1 answer
How to set up prescaler on ISR to a certain interval in microseconds?
I have a PIC18F87J11 device and I'm supposed to create:
1) a high-priority ISR that's supposed to be triggered every 100ms
2) a low-priority ISR that's supposed to be triggered every 10ms
I have a basic knowledge about configuring a pre-scaler, in…

cypher
- 6,822
- 4
- 31
- 48
1
vote
0 answers
Continuously changing PWM with ADC on PIC18F452
I am writing code for generating continuously generated PWM with a potentiometer.The code is given below. The code is working fine, but in some scenarios, it stops working.
I get a changing PWM when I give 0–3 volts from the potentiometer. But when…

Zerox
- 15
- 5
1
vote
1 answer
PIC18f4550 external interrupts is not working
while using interrupts in pic18f4550, I get stuck in external interrupts, and the push button (RB0) is not Inverting (Toggle) the value at PORTD, I used timer0 interrupts which work perfectly, but I can't figure out what the issue is it is with this…

Aizaz
- 13
- 3
1
vote
1 answer
Problem with PIC18F45K50's ANSELE register
I am trying to make a code for PIC18F45K50, I am trying to use PORTE as digital input, that means I have to clear ANSELE register which controls this pin behavior
Working on MPLABX 3.30 i tried this line of code:
clrf ANSELE
to clear the register,…
1
vote
0 answers
crash when clearing uint8_t on pic18f67k22
I'm adding a clock to my program, but for some reason I cannot lower the value of my "sec" variable.
I have a millisecond timer that raises a flag every ms. So, every 1000 ms I clear the ms variable; this happens without a problem.
Now every 10 (for…

Wesley Kienhuis
- 41
- 5