Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem 7Seg with a PIC16F877A

Status
Not open for further replies.

SmoZy

Newbie level 2
Joined
Apr 11, 2014
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
7
hello i have a problem i have :

PIC16F877A
7seg Display

i have a problem :'( a random seg display very very very quickly ( PIC = 500Hz ) ----> https://prntscr.com/391z7f


my code :

Code:
			//  Afficheur 7 segments\\
			//  Thomas Lounis 		\\
			//  1 ere S3 			\\            
			//  10/04/2014 			\\
			//  v 1.0 				\\ 
			//  PIC16F877A 			\\





#include <htc.h>
#include <stdio.h>
#include <time.h>

// initialise les differents nom au port
#define seg_a RB0
#define seg_b RB1
#define seg_c RB2
#define seg_d RB3
#define seg_e RB4
#define seg_f RB5
#define seg_g RB6

void main(void)
 {
   
   CMCON = 0x07; // annule les comparateurs
	 TRISB = 0;
	 seg_a = 0; 
		 seg_b = 0;
		 seg_c = 0;
		 seg_d = 0;
		 seg_e = 0;
		 seg_f = 0;
		 seg_g = 0;
	 while (1)
		 
	 {
		 
		 seg_a = 1; 
		 seg_b = 1;
		 seg_c = 1;
		 seg_d = 1;
		 seg_e = 1;
		 seg_f = 1;
		 seg_g = 1;
		
		 
		 
	 }
		 
 }


thanks i just want all my seg is ON
 
Last edited:

What is the current circuit response to this code? Depending on the compiler, it might be better to call TRISB = 0x00 to make sure it is setting all the ports. Remove the CMCON set for now since your not using the comparators. ANy compiler errors? What are the configuration bits set as? Is this on hardware or simulation?
 

The outputs on PORTB should always be high while it is in the loop. The code is correct. I suspect the problem is the watchdog timer is running and resetting the PIC every 20mS (~50Hz) or so. Each time it resets the PIC it will flash the segments.

Try either turning the WDT off or including a WDT reset inside the while(1) loop.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top