Skip to main content
22 votes

Why doesn't the switch command in this code work?

I didn't inspect the whole code but you forgot the "break" statement for each "case" : without it your code will perpetually exit the switch statement by executing "case 9&...
Genorme's user avatar
  • 711
14 votes
Accepted

"Not enough RAM " error in PIC16F877a

The PIC16f877a only has 368 bytes of memory, meaning that the 8x8 array is already in danger of exhausting available memory (either 128 or 256 bytes depending on sizeof(int)) given a requirement for ...
nanofarad's user avatar
  • 20.7k
7 votes
Accepted

Why does my ADC reading not increase when the supply voltage decreases?

If you are using VCC as the ADC reference, and using the same VCC as potentiometer reference, then pot output and ADC measurements are both proportional to VCC so the ADC reading stays exactly the ...
Justme's user avatar
  • 172k
5 votes
Accepted

Setting PORTA of a PIC16F877a as digital

You are setting ADCON1 incorrectly. Have a look in the example assembly code for PORTA initialisation in the datasheet: This ...
awjlogan's user avatar
  • 7,999
5 votes

PIC16F877 pin functions order in pin name

There is no "order of functions" for pins. Pins that are configurable usually have a "default" configuration, and then you can use the control registers to select an alternate function. So in your ...
Ron Beyer's user avatar
  • 2,598
4 votes
Accepted

Simple LED Blinking project - PIC16F877A microController problem

I have found a solution: I closed MPLAB IPE completely. Then from project properties of MPLABX IDE, I selected the needed power and selected option to power the target from PICkit3. Then "made" the ...
RukshanJS's user avatar
  • 149
3 votes
Accepted

Does interrupt service routine in PIC16F877A work with other self-defined variables?

I believe what you are asking about is the scope of variables in the interrupt service routine (ISR). If CurrentMeasurementReady a declared inside the ISR then it’s scope will be limited to that ...
Bryan's user avatar
  • 2,275
3 votes

Why doesn't the switch command in this code work?

As pointed in the other answer, the missing break in the switch cause the code for case 9 to be executed for all inputs from 0 to 9. Also, the whole switch is equivalent to ...
fgrieu's user avatar
  • 1,690
3 votes
Accepted

PIC16F877 pin functions order in pin name

Seems that in general, Microchip I/O ports default to analog input where analog-to-digital converters are available on-chip. This PIC16F877 seems no exception. The configuration of I/O pin function is ...
glen_geek's user avatar
  • 27.6k
2 votes
Accepted

About PIC programming

The compiler doesn't know what the variables TRISABITS etc are, which means you didn't tell the compiler about them. This is usually done by including the ...
Hein Wessels's user avatar
2 votes
Accepted

While loop instructions in pic disassemby not clear

Caveats: It has been more than a decade since I routinely wrote PIC assembly code (and used their C compiler -- not sure if my license is any good anymore, either.) You also didn't say which compiler ...
jonk's user avatar
  • 78.7k
2 votes

MPLAB X __delay_ms() hangs on PIC16F77A

i.e. The code above should ultimately turn the LED on, but it stays off. – It doesn't. the PIC probably reset after reaching the end and re-enter the main method. If you want to stop after the last ...
Damien's user avatar
  • 8,144
2 votes

Interrupt works only once - PIC16F877a

Many problems. You need to de-bounce the button. This is mentioned in any embedded beginner learning material. You should never connect a button directly to an interrupt-triggered pin without taking ...
Lundin's user avatar
  • 22.3k
2 votes

Interrupt works only once - PIC16F877a

There are some low level problems with your code that have to be handled first. These problems have the potential to break your code even if the logic would otherwise seem correct. Variables that are ...
Unimportant's user avatar
  • 5,103
2 votes
Accepted

How to display my date in the 2nd line of the LCD?

Using these commands sets the configuration and positions the cursor. ...
D.A.S.'s user avatar
  • 148k
1 vote

SPWM generation on PIC16F873A is not stable; SPWM shape changes although duty cycle is the same for all

It looks like it might be missed interrupts. This family of PICs require 4 oscillator cycles per instruction cycle, so you are only running at 5 MIPS. It appears that you are trying to interrupt at ...
John Birckhead's user avatar
1 vote
Accepted

Is my ACS712 sensor showing normal characteristic?

I considered suggestion above that current sensor may have experience interference from nearby magnetic field. Apart from buying the shielding for testing purpose, I using a cheap solution like emf ...
chuackt's user avatar
  • 609
1 vote

Why my LCD not display anything?

As mentioned by brhans, the Ms delay only reading integer number. After I change the delay to integer number, the display working correctly.
chuackt's user avatar
  • 609
1 vote

Designing a frequency detection circuit

Sure. As a start, you need to explore something called Software Defined Radio (SDR). Get a Realtek RTL2832 dongle (Ebay, $10) and set up a Linux system to plug it into. Then install GNURadio and run a ...
Keith E. Fleming's user avatar
1 vote

pic16f877a problem in timers with proteus simulation

The code posted sets TIMER1 to be clocked from the FOSC/4 source and to assert an interrupt after 65536 clocks. The interrupt handler toggles the state of RB0. With a 16MHz oscillator the TIMER1 ...
Dan1138's user avatar
  • 1,389
1 vote

Buzzer circuit problem in Proteus

A passive piezoelectric buzzer is a capacitor. It will never work on DC voltage. Neither 5V nor 24V. The AC voltage must be controlled from two outputs by push-pull control. Or do the same with an ...
csabahu's user avatar
  • 2,491
1 vote

Problem in simple LED Blinker Circuit using PIC16F877A

Leave VDD unconnected from the programming header and connect the microcontroller VDD pins to your power supply. You are now shorting the power supplied from pickit and your own circuit. When the ...
Ralph's user avatar
  • 3,704
1 vote

PIC16F877A I2C MSSP not sending data

So fair warning, I've never handled any PIC's before. That being said, the I2C section of the datasheet for PIC16F87XA runs through an Master I2C transmission sequence pretty clearly. The upshot: ...
Chris Knudsen's user avatar
1 vote

PIC16F877A External Crystal giving 60Hz

TRISC=0xFF sets the pins on PORTC to float. There may be other issues but that's a killer. TRIS = Tri-State (ie. make it float) is the way to remember.
Spehro 'speff' Pefhany's user avatar
1 vote

About PIC programming

use MPLABx + xc8 compiler (both are for free). Know include xc.h header in every source file. That should work.
Mike's user avatar
  • 2,206
1 vote

Getting different values while connecting LM35 with PIC16F877A

Figure 1. The ADC voltage reference selection. The conversion of an analog input signal results in a corresponding 10-bit digital number. That part, I presume you understand. The ADC converts ...
Transistor's user avatar
  • 180k
1 vote

Programming PIC16F877a using PICKIT3

Power the PIC from the same power supply as the Arduino. Remove the Vdd connection to the PIC from the PICKIT3. It may also help to add a 10k resistor from PGM on the PIC to ground. Make sure you have ...
Glenn W9IQ's user avatar
  • 5,594

Only top scored, non community-wiki answers of a minimum length are eligible