1,673 questions
1
vote
1
answer
68
views
PIC-AS locations and debugging for 10F202 with OSCCAL at reset vector?
I am quite new to the PICs and especially with XC8 pic-as and MPLAB-X
I have a ultra minimal project i am working on, and i have some questions regarding the OSCCAL values located at the reset vector, ...
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;
...
2
votes
2
answers
102
views
How to load a value from ROM
I am currently trying to load a value stored in the code area. The C equivalent is
const char val = 25;
char x = val;
All the examples I can find only load values from the data area. If I ...
2
votes
1
answer
147
views
RC-5 IR protocol, out of solution
This is my first post ! I recently bought a Cambridge Audio Azur 651A with no remote, I just want to make sure everything on the remote side works. It uses the Philips RC-5 protocol.
I wrote a very ...
3
votes
2
answers
117
views
PIC16F18877 — HC-SR501 PIR motion sensor always reads low on PORTD pin
I’m working on a PIC16F18877 project where I’m trying to read a digital motion signal from an HC-SR501 PIR sensor.
I’ve run into an issue where my PIR sensor seems to always read LOW (0) on my PIC ...
0
votes
0
answers
75
views
When pressing a certain key to enter password change, the key is set as first digit of new password (pic16f877a)
Change Password function
ChangePassword:
MOVLW 0x01
MOVWF CHANGEMODE
MOVLW b'01000011' ;c
CALL LCDDisplay
MOVLW b'01001000' ;H
CALL LCDDisplay
MOVLW b'01000001' ;A
...
2
votes
1
answer
101
views
ADC_READ for PIC
I made a code using ADC_Read function in MikroC PRO IDE, but the code doesn't build, and the following error message appears:
the variable ADC_Read isn't declared
I'm using a PIC12F675 with an ...
3
votes
2
answers
175
views
Wrong LED turning on using microcontroller PIC16F1829
For this assignment I'm using the PicKit3 microchip PIC16F1829, lesson 8 from the PicKit starter guide.
I wrote the following code for my assignment that turns DS3 on (but for some reason it turns on ...
4
votes
1
answer
161
views
Is a stack overflow on a compiled stack really impossible?
When I have finished a software, I carry out a stack overflow test at the end. Why don't I have to do this with a compiled stack?
Are overflows really completely impossible here or only very rare?
2
votes
0
answers
94
views
Simple CAN message with PIC18F2580
I’m encountering some issues with the CAN BUS module on the PIC18F2580. I should probably mention that I’m new to working with CAN, so I may have overlooked something quite simple.
Currently, I’m ...
0
votes
0
answers
98
views
PIC Assembler, rlf behaving weird
I have a question, when I use this code in MPLAB IDE v8.92, Windows 11, when it arrives to the rlf line it behaves weird either if I use 0 or 1 for "d" in rlf. Values for j and k are 0xFF.
...
1
vote
1
answer
94
views
Why is the stopwatch for PIC32MZ2048EFM144 microcontroller always disabled?
I am using a PIC32MZ2048EFM144 uC. I wanted to know time taken for a routine called adc7768(). When I go to
window->debugging->stopwatch
and try to debug it gets hung. Debug will not happen. ...
1
vote
0
answers
60
views
GPSIM external stimulus issue
I have a simple circuit (with PIC16F628) which repeatedly measures the frequency of a signal connected to Timer1. I use Timer2 as a timing gate. To simulate the 'system', I used GPSIM, but I'm having ...
2
votes
2
answers
77
views
Declare variables in the same address of other variables in XC8
I have the following problem with XC8 compiler
I had an array --> char my_array[8];
but for convenience, I want to declare the variable --> unsigned int cont_up;
at the same address of ...
2
votes
1
answer
76
views
Indirect Addressing P16F877
Suppose i have two numbers n1 & n2, one in bank 0 and the other in bank 2, i want to do a sum operation on them using the indirect addressing approach, here is the code from my lecture which is ...
1
vote
0
answers
63
views
PIC18F25K80 Sleep Mode
I've been working on a project with PIC18F25K80 MCU for a while. My main purpose is to collect some sensor data based on user-defined intervals(like 1min) and since this is a battery-powered ...
1
vote
0
answers
426
views
How to resolve the dependency issue in VectorCAST for Microchip source code
I need to do software testing and validation for the PIC16f15214 source code using VectorCAST.
But when I build the environment it shows the "compiler error" / "can't open the 'XYZ.h' ...
2
votes
1
answer
481
views
Adapting Compilation Chain from MPLAB X IDE to VS Code with MPLAB Plugins
My code builds fine in the MPLAB X IDE (v5.454), but for usability I want to use VS Code with the MPLAB extensions.
My requirements include the use of the xc32 compiler v2.40. The example video does ...
0
votes
1
answer
148
views
Looking for a working function jump table example
I'm struggling to implement a function jump table and hoping someone can help out.
device is PIC16F1503
MPLAB X IDE v6.20 and XC8 v2.46
called functions Function1 and Function2 are in a separately ...
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 ...
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 ...
1
vote
3
answers
124
views
Storing context prior to sleep (PIC)
Wonder if anybody knows the correct C syntax to store context (in my case just one int) before a PIC 24F sleeps and then recover it when woken.
The example code (Microchip app note), which is supposed ...
2
votes
2
answers
105
views
Problem accesing global variables in main.c through .S assembler source file (MPLABxIDE)
My project consists in:
Using a 4 digit 7-segment display to show certain numbers, representing the amount of cash stored in a moneybox. I am using both .c and .S files.
To rotate between the 4 digits ...
2
votes
2
answers
106
views
Union of struct with one element vs union of element mplab pic32
I was looking at a pic 10 include file (p32mk1024gpk064.h) and was wondering why they added a struct with a single element instead of an union between a struct and an uint_32.
typedef union {
struct ...
1
vote
1
answer
751
views
How do I fix this module error when attempting to launch MPLAB-X IPE 6.20 version?
enter image description here
I am receiving this error when trying to launch MPLAB IPE 6.20 after downloading MPLAB IDE 6.20. Does anyone know how I can fix this?
I have uninstalled it and reinstalled ...
0
votes
1
answer
117
views
Upgrading from MPLAB ICD-2 to ICD-3 to move from PIC 18F87J10 to PIC 18F87K22
For my hobby I used to get boards for a particular device, and used to reprogram the microchip PIC 18F87J10 using MPLAB ICD-2 (I run it from my VM VirtualBox running Windows XP). Now the company from ...
0
votes
0
answers
98
views
read a hex string over UART for PIC Microcontrollers in C using mikroC for PIC
I'm using a PIC18F microcontroller with mikroC PRO for PIC.
The PIC micro reads strings over the UART, which Software implemented because there is only one UART, and I need two.
I'm trying to write a ...
-1
votes
1
answer
119
views
Where Can I find PIC32 Library Functions Contents?
I am searching for PIC32 Library Functions' context. For example there is a uart.h library and "void UARTEnable( UART_MODULE id, UART_ENABLE_MODE mode );" in it. When I used that function ...
3
votes
0
answers
94
views
Reserving a block in Flash memory on PIC24FJ128GA306
I am using the PIC24FJ128GA306 microcontroller and trying to reserve a block in flash memory to store persistent data. Here is the code snippet I am using to define and allocate the persistent data:
...
1
vote
1
answer
100
views
CALL command creates call to 0x0 rather than to 800h
This is a large program now so just a bit of the source code below.
**DISASSEMBLED CODE:**
0164 0739 ADDWF 0x39, W 531: addwf Trigger777,0 ;to get proper patch table
0165 0733 ...
0
votes
0
answers
88
views
PIC16F1618 returning ADC values exceeding 10bits
I'm writing my first PIC16F1618 project.
I got stucked in a pretty strange error/behaviour.
This's the repository of the project:
Github repo
The problem is the value resulting from the ADC sampling:
...
1
vote
2
answers
124
views
Analog data operations do not work in PIC12F675, there is not even a reaction on GPIO pins
This Analog data is read and the number 1-5 is shown on the 7 segment common anode display with 7447, but I can't set this number for analog value because I can't show analog values or output I wrote ...
0
votes
1
answer
162
views
Requesting a simple code for PIC10F200 using MPLAB XC8 Compiler [closed]
I can't program this microchip (using a PicKit5, should be no issues), either because its too old or I'm lacking a lot of knowledge.
So the program gets written correctly with no errors, but when I'm ...
0
votes
2
answers
98
views
Converting bit-shift operations to specific binary number format (for a PIC microcontroller)
I am working on several home automation projects with PIC12F675. To maximize portability, I am using bit-shift operations to map GPIOs, like this:
// Hardware Mapping
#define pressure_pin (1<<0)...
0
votes
0
answers
141
views
How to calculator modbus RTU timer period?
I'm using the dsPIC33ck128mc105 and the FreeModbus library.
I need to add Modbus RTU (RS232), but I'm facing a small problem. I understand the timer period calculation as "11 bits / UART baud ...
0
votes
0
answers
62
views
USB pd Max76958 and restarting negotiations with tablet
USB pd Max76958 and restarting negotiation without disconnecting
Hi there, I am in a bit of a pickle and I was hoping someone could help. I am using a maxim max77958 pd control to negotiation power ...
0
votes
2
answers
123
views
Issue with the delay and the toggle on PIC16F84A micro
Task 1: Create a 1 Hz Square Waveform on PORT.A0
Write an assembly language program to create a 1 Hz square waveform on PORT A0.
a) First write your code to toggle PORT A0 without any delay
b) Then ...
0
votes
1
answer
190
views
Writing device driver for rotary encoder on PIC16F [closed]
Building on top of this question Writing Device Drivers for a Microcontroller(any) I am just starting to learn deep inside microcontrollers, more specifically PIC16F690. I already know a whole lot of ...
0
votes
2
answers
143
views
PIC16F877A Assembly, Why does this code never go to the ISR when Timer1 Overflows?
Very new to assembly programing and im trying to make a blinking LED, here is my code:
#include p16f877a.inc
counter equ 0x20
org 0x00
goto main
org 0x04
goto ISR
main
bsf INTCON, ...
0
votes
1
answer
335
views
MPLAB 8 and MPLAB X Checksums
I have a project that was built in MPLAB 8 using the Hi Tech C compiler. When I load it into MPLAB 8 to program a device I get a checksum (I use Unprotected checksum), then when I load it into MPLAB X ...
1
vote
1
answer
115
views
C sscanf not capturing the second argument
Using MPLAB to code for PIC16 in C using the XC8 compiler.
I am trying to capture some baud rate settings from a string, for example "115200,8,N,1".
For the purpose of my application, I have ...
0
votes
1
answer
210
views
MPLAB XC8 compiler - too many instructions in disassembly view PIC10F200
I am trying to compile this code in order to generate a PWM signal 15us HIGH and 9us LOW.
#include <xc.h>
void g()
{
for(char val=0; val<20; val++)
{
GPIO = 0xFF;
NOP()...
-1
votes
1
answer
165
views
What is the difference between these 2 programs, one in C and the other in PIC assembly?
I have written/copied/modified an I2C client written in C which works. When I translate it to assembly language it fails. Where am I going wrong?
The master/slave design is very simple. Master ...
0
votes
1
answer
41
views
Can't call second function (PIC XC16)
I'm using MPLABX XC16 on a PIC24F16KA102 and attempting to migrate from a PIC16 and mpasm.
A simple loop which sequences some LEDs should test a switch between each LED on/off and then branch out to ...
0
votes
1
answer
775
views
I2C LCD1602 interfacing with PIC16F877A
My partner and I are currently building out an interface code set for a PIC16F877A microcontroller and a LCD1602 I2C screen
We can onboard everything perfectly fine however nothing shows on the screen....
0
votes
2
answers
239
views
What is wrong with my SPI configuration/programming?
I'm trying to get 2 MCUs to communicate using one-way SPI, i.e. Master sends to Slave. The master code appears to block after writing to the output buffer at the point where I am testing for the BF ...
-1
votes
1
answer
95
views
Symbol not previously defined (TRISA)
list P=16f54
#include <p16f54.inc>
; CONFIG
; __config 0xFFFB
__CONFIG _OSC_RC & _WDT_OFF & _CP_OFF
org 1FFH
GOTO Start ; go to beginning of program
...
0
votes
1
answer
733
views
How to Enable UART Interrupt For PIC32MX?
I was trying to create a UART driver for the PIC32MX320F128H, when I noticed that any time the UART IRQ occured, it would crash the system.
The Debugger told me that the program was halting at these ...
0
votes
2
answers
109
views
problem when separating an integer and displaying it on a 7-segment display
I am simulating a project in Proteus where I show a three-digit number (456) on a 7-segment display, but instead of showing 456 it shows 006.......... the calculations are well done but I can't figure ...
1
vote
1
answer
272
views
No source code lines were found at current PC 0xc7. Use Program memory view to see instruction code disassembly
I'm new to assembly language and I wrote a simple program to learn. I run into a problem of program counter (I believe) with a "goto" instruction. I use a PIC 10f202 and I use MPLAB v.6.15 ...