239 questions
2
votes
1
answer
113
views
Timer 0 macro constants for Microchip PIC18F8722
I am using MPLAB X IDE version 5.43 to develop an embedded project for a PIC18F8722 microcontroller.
It has a timer TMR0 which can be configured to be 32 bits.
I had lots of statements:
TMR0L = 0;
...
0
votes
0
answers
84
views
issues with "atof" function in MPLAB X IDE v6.25 with XC8 v03.00
I'm working on some code for a PIC microcontroller PIC18F47J53. I'm using MPLAB X IDE v6.25 and the package PIC18F-J_DFP 1.9.170. Both are latest versions.
A year ago, I used exactly the same code, ...
1
vote
2
answers
86
views
I get the error [PIC18] PC=0x0000. $MCLR$ is low. The processor is in reset. [U1] in my simulation
I am making a code in PIC C compiler to turn on and off a LED. However it is not working on my physical board or in the simulation.
Error message is:
[PIC18] PC=0x0000. $MCLR$ is low. The processor ...
1
vote
3
answers
198
views
How to scale a 10 bit analog signal into an 8 bit PWM?
I'm using the PIC18F47-Q18 Curiosity HPC Development Board and the MPLAB X IDE v6.20.
The goal is to store the 10 bit value from the analog output into the 8 bit PWM. Depending on the justification of ...
2
votes
0
answers
119
views
Using the enhanced ccp1 in pic18f does not output PWM
I was implementing a driver for ccp1 peripheral and after implementing it and using proteus for simulation, the enhanced PWM doesn't work while I made sure that the CCP1CON is loaded correctly and ...
0
votes
1
answer
92
views
PIC18F const variable at odd flash address
Is there any way to place a const variable to an odd address of the flash, so that the value is in the HEX file?
It needs to be at a specific flash address, i can not use the SAF Block because its to ...
2
votes
1
answer
113
views
Pic18f47k40 EUSART setup
I am trying to implement Modbus RTU in a device that has a PIC18f47k40 MCU with baudrate of 19200.
I started by setting up eusart1 for sending and receiving.
This is the code in main.c that is ...
-1
votes
1
answer
93
views
How to recognise subtraction in a string in C?
I´m trying to make a simple caltulator using PIC18F46K22 microcontroler and UART. However it works only for adding two numbers, even though the strstr cor comparison and finding the "+" / &...
1
vote
1
answer
180
views
Matrix Keypad Implementation problem: PICSimLab, PICGenios, PIC18F4580
I'm trying to use the matrix keypad in PICSimLab's PICGenios board with PIC18F4580 MCU. The schematic for the board is here. Below is the code.
matrix_keypad.h
#ifndef MATRIX_KEYPAD_H
#define ...
0
votes
1
answer
229
views
Unable to make Bootloader PC jump to application address 0x4000 in Program flash memory
Can someone please help me.
I am using PIC18F26Q10 mcu
bootloader code starts from 0xF00 and application code starts from 0x4000
The below code is what I tried out but the switch doesn't seem to ...
0
votes
1
answer
147
views
DHT11 code from pic18f4550 does not work with pic18f57Q84
I am trying to read the DHT11 on a PIC18f57Q84 and display it to an LCD screen. I found somebody online who did this for a PIC18f4550 and tried to make it work on my PIC18f57Q84 development board. I ...
1
vote
2
answers
234
views
PIC18F4580 isn't turning the LED on in Proteus
I have this code for the MCU (pic18f4580) :
#include <pic18F4580.h>
#pragma config OSC=HS
#pragma config LVP=OFF
#pragma config PBADEN=OFF
#pragma config WDT=OFF
#pragma config MCLRE=ON
#...
0
votes
2
answers
459
views
MPLAB X IDE code for PIC18F452 microcontroller (indirect addressing)
Using Indirect addressing I'm trying to copy the value 77H into RAM memory locations 50H to 55H. The issue I'm running into is a build error where it says FSR and INDF are not previously defined ...
0
votes
1
answer
434
views
I2C is not working, slave is not acknowledging. after receiving address
As a beginner I am trying to send data between two pic18f4550 where master sends and slave receives data and prints data bits on LED(PORTD). But I don't know where the issue is, the slave is not ...
0
votes
0
answers
60
views
Flash LED fine but can't output and monitor using a logic anaylser on RG0
I am using a PIC18F6520 and have managed to write some code that flashs an LED with a deay of 500ms, below is this code.
// CONFIG1H
#pragma config OSC = HS // Oscillator Selection bits (HS ...
0
votes
0
answers
262
views
Toggle an LED using timer 2 with an interrupt for a PIC18F6520
I am trying to get Timer2 to flash an LED, this is not the final operation but I had it flashing an LED without the interrupt so I am continuing with this for now. But I cannot seem to get it working. ...
1
vote
0
answers
101
views
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 ...
-1
votes
1
answer
51
views
Need Help Understanding Some Of The code For Receiving and Decoding an Infrared Receiver
For the most part i can follow this code but i cant seem to grasp how the final 8-bits are constructed, see my comments below:
Original code web page see for more information
while(ir == 1);
...
0
votes
0
answers
81
views
Temperature sensor with fans not working in Proteus
I would like to know why the simulation is going wrong in the Proteus Professional.
Well, on this circuit and code, I tried to make a Temperature sensor with fans following the following conditions:
...
1
vote
1
answer
295
views
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 ...
0
votes
1
answer
119
views
Problem with PIC18F45K50's ANSELE register
I am trying to make code for PIC18F45K50. I am trying to use PORTE as digital input. That means I have to clear the ANSELE register which controls this pin behavior.
Working on MPLAB X 3.30, I tried ...
2
votes
2
answers
157
views
PIC programming which bits are which in TRIS register
I am trying to understand PIC18 code in a format like TRISB &= 0b11100000.
What is the order the individual RB pins appear in? i.e. is this register setting RB0-RB2 as input, or RB5-RB7 as input?
0
votes
0
answers
393
views
Bootloader doesn't change reset vector
I am using MPLAB IDE, MPLAB XC8 v6 Compiler, PIC18F25Q10. We are working with a bootloader project. While in the bootloader phase, it is expected to update the application and jump to a certain ...
2
votes
1
answer
1k
views
MPLAB gives Low power and device failed to connect error when programming pic18f25q10
I am trying to add a simple led application to a PIC18F25Q10 in another circuit using the Curiosity HPC development board. I am using the MCLR, PGD, PGC and GND pins. Although I set the LVP mode to ...
0
votes
1
answer
194
views
I can't even turn on LED on PIC18F4550 using MPASM v5.87. What am I doing wrong?
I can't find any tutorials specific to PIC18F4550 using MPASM.
; PIC18F4550 Configuration Bit Settings
; Assembly source line config statements
#include "p18f4550.inc"
; CONFIG1L
CONFIG ...
-2
votes
1
answer
109
views
Can someone explain "RLCF INTCON,W,C" to me?
I'd like help explaining this assembly statement because I don't quite understand it yet:
RLCF INTCON,W,C
0
votes
0
answers
123
views
Problem while coding in mplab x ide for pic18f
I am using pic18f and coding on mplab v ide. While compiling the code it's showing that 'RD3' is depricated. What should be the solution to it.
0
votes
0
answers
264
views
Undefined/Redefined Error with premade Methods in MPLAB v8.92 when working with a PIC18F4620
this is my first question, so please let me know how I could possibly ask the question better.
I am working with MPLAB v8.92 for an Embedded Systems class. My teacher gave me some pre-written C code ...
-1
votes
3
answers
150
views
Floating-point numbers are not printed
I am trying to create a conversion table using the C programing language. I want to convert the temperature from -250 °F to 250 °C increments of 10. However, I am not getting the Celsius output:
#...
1
vote
0
answers
119
views
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 ...
2
votes
1
answer
249
views
Gated Timer on PIC18 sets TMR3IF flag to late & with Fosc/4 it doesn't set it anyway
I have already spent several nights debugging gated timer on PIC18F26K80. I use MPLAB v4.15 and XC8 v2.32. I want to run a long period timer, so I chose Timer 3 gated by Timer 4. I've read Microchip's ...
0
votes
0
answers
78
views
PIC18F4550 The blinking of my LED won't match the delay
I am using PICKit4 to program a PIC18F4550. I have plugged in a 40MHz Oscillator and here's my code including config bits. The LED stays ON for 12 seconds and off for 12 seconds instead of 5. What am ...
0
votes
1
answer
225
views
Latch register not showing the same value as the port register
I'm writing a program on PIC18F4550 where I have data defined in my memory and want to send it to PORTA character by character. I have done so but the values showing on LATA are not the ones shown in ...
2
votes
1
answer
69
views
Sending TABLAT value to a port gives me the wrong value
I'm trying to write a program on PIC18F4550 where I have data defined in my memory and want to send it to PORTC character by character. I have done so but the values showing on PORTC are not the ones ...
-2
votes
1
answer
76
views
Low frequencies measurement
I am new to the forum.
I am recording the RPM, and show it on 4x seven segments with CCP2. It actually works quite well from about 3.81Hz to about 166Hz, which is enough upwards.
I measure the ...
0
votes
0
answers
80
views
PIC USART second char always read 2 higher
I am using MPLAB XC8 and I try to use the USART module. But I have abnormal problem. Here is my code, I explain after this.
#include <xc.h>
#include "conbits.h"
#include <stdbool.h&...
1
vote
1
answer
731
views
How do I turn a Fitec FS90R servo motor 90 degrees clockwise and anti-clockwise using a PIC18F4550
I have tried varying the duty cycle of the servo motor but it only turns 180 degrees clockwise and anti-clockwise.
0
votes
1
answer
266
views
Program PIC 18LF46K42 Microcontroller
I am using MPLABX to write a simple program for PIC 18LF46K42 Microcontroller that would turn LEDs on and off after a certain delay. The compiler does not recognize "TRISB" and "LATB&...
0
votes
1
answer
513
views
how to combine ADRESH and ADRESL on 12 bit ADC
MICRO: PIC18LF47K42
compiler: XC8
application: MPLABX
I am trying to combine the values in of 12 bit ADC. They go into ADRESH and ADRESL. My ADC is set up for right-justify which does formating as so:
...
2
votes
1
answer
1k
views
Difference between PORT and LAT on an PIC18F
I am currently working on a PIC18F and I wonder what the difference is between a PORT and a LAT because looking at the documentation of the PIC18F they both do the same thing.
-1
votes
1
answer
427
views
How to check While loop "condition" inside its body after each line of code?
Here is an example of my code i can place if condition to check While condition flag and put break after each line of the body but it increase overhead. WHAT SHOULD I DO??????
while(!((kvp < (...
0
votes
1
answer
227
views
Pic18F67K22 will not read program memory above 0x10000
I am writing a boot loader for Pic18F67K22 device. Program data 0x200- 0x1FFFF. Boot code resides in memory location <0x200 and is unaffected by boot load program update. The program 0x200-0x1FFFF ...
1
vote
1
answer
387
views
Nested loop - Can someone explain this loop?
Can someone explain how this type of loop works, I took it from a code that has a total delay of 1 second, I didn't understand the LOOP 2 and 3 function.
DELAY:
MOVLW 0X44
MOVWF C1
...
0
votes
0
answers
110
views
Problem with second digit value on Seven Segment Display for MCU voltmeter
I am building a Voltmeter for a PIC18F using an XC8 compiler on MPLAB and I am having trouble getting my second digit value to update as I rotate my potentiometer. A potentiometer is connected to ...
-1
votes
2
answers
1k
views
create 250ms delay in MikroC
I'm looking to create 250ms delay function with MikroC. In the code below, I don't understand what 165 in the 2nd for section does.
void MSDelay(unsigned int itime); // this is the prototype
void ...
1
vote
1
answer
439
views
PIC18f4550 XC8 compiler: LCD screen stop working when interrupt service routine function is enabled
Background
I am trying to make 16x2 generic LCD display(HD44780) shows some texts on the screen when data is received from HC-05 Bluetooth module via USART interface using PIC184550.
The simplified ...
-1
votes
1
answer
1k
views
UART only receiving FF and FE
I am currently working on transmitting from a PIC18F4620, through a FT232, to CoolTerm. I am currently only receiving FF and FE from the PIC though. I was wondering why this may be the case. The Rx - ...
0
votes
1
answer
284
views
PIC18 UART receiving corrupted bytes from PC
I seem to have issue to receive correct bytes from a PC to a PIC18F27J53.
The PIC UART is set standard, asynchronous, 8bits, 9600, No parity.
The PC is a win 10, I have made a simple UART program, and ...
2
votes
1
answer
91
views
How can i approach this program with creating a Boolean variable instead of cycling through branches?
I am programming a PIC1847q processor on the curiosity HPC board. My task is to design a battlestar galactica cyclon visor using the LEDs on the board. My current code does infact create and replicate ...
0
votes
1
answer
592
views
DAW Instruction capabilites
I know that the DAW instruction adjusts the 8bit result in the WREG after adding two packed BCD numbers but is the DAW instruction capable of adjusting a much higher bit result in WREG ?