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.

[PIC] Pic16f690 interfacing with two 7-segment, using a 7447 delay with timer 0

Status
Not open for further replies.

hirenn

Full Member level 1
Full Member level 1
Joined
Jul 12, 2014
Messages
96
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
703
Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

Hi Everyone

i'm using PIC16f690 interface with two seven segment by 7447

im making 0 to 99 counter by using timer 0 of pic controller

i write a code but it shows only ''0'' on my both 7 segment...

can anybody please help me to figure out the problem

Thanks


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <htc.h>                          // hi tech compiler for pic16
#define _XTAL _FREQ 4000000       // 4 Mhz freq
int overflow = 0;                       // counter variable for 0 to 99
 
void interrupt ISR(void)           // timer interrupt
{
   if(T0IF)
   {
      overflow++;
      T0IF=0;
      }
   }
 
void timer0()
{
   PSA = 0;
   T0CS = 0;
   
   PS1 =1;                          //prescaler 1:256
   PS2 =1;
   PS0 = 1;
   T0IE = 1;
   T0IF=0;
   GIE = 1;                         // global interrupt enable
   
   }
void main(void)
 {
    unsigned short second=0;
    unsigned short x,y=0;             // for display on segment
    TRISC = 0;
    TRISB7 = 1;
    ANSEL = 0x00;
    ANSELH = 0x00;
    TMR0 = 0;
    timer0();                       //timer0 function
   while (1)
   {
      if(overflow==15)
      {
     second++;
     overflow = 0;
      }
 
     if(second>99) 
     {
        second =0;
        }
        x = second/10;
        y = second%10;
        PORTC = (y<<4)+x; // PORTC connected with 7 segment via 7447
      }
 }

 
Last edited by a moderator:

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

Zip and post the circuit either in image format or as Proteus file.
 

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

Thanks for reply
My circuit is below Screenshot_2016-02-14-23-34-00-1.png
 

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

What is the use of using 2 PIC ports for 7447 ? Instead of that you can use 2x 4 pin BCD displays. Please use the 3 control lines of 7447 and connect the data lines of the two 7447 to same PIC 4 pins.

- - - Updated - - -

These should be replaced

Code:
x = second/10;
        y = second%10;
        PORTC = (y<<4)+x;

by

Code:
PORTC = Dec2Bcd(second);

See if your compiler has Dec2Bcd() conversion routine. If not, google for it. It is also available here in this forum.
 

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

The variable "overflow" is not declared as volatile. Try with,
volatile int overflow = 0;
 

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

First you need to make sure that the hardware is working fine. Just touch with a wire line A or B or C or D to 5V and see whether the display is working as intended.

If the hardware is fine, you need to worry about the software. The output pins are producing pulses. In that case, start with a simple program that toggles only one line (say A or B).

Once you are successful, you need to expand your program. That should be easy,
 

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

Hi ahsan_i_h

i use volatile int overflow = 0; but no luck...

is my timer0 and timer interrupt are correct????
if i use same circuit than what should be error in my code??
 

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

TMR0 is not reloaded in ISR or during initialization.
 

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

i have already use prescalar , is it imp to use reload??
 

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

Have you generated 1 sec delay using Timer0 ? If yes, explain how your Timer0 code works. I assume you count at 1 Hz.
 

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

Are you want to use a counter...??? then what is the use of RB7 in program and circuit. Also your code seems to be good, but what about the configuration bits you used...???
In proteus have you set the configuration bits correctly?
Your program on startup will continue to increment. so introduce some more delay (in ms) to see the display update.
 
Last edited:

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

Hi kanni1303
Thanks for reply
RB7 pin is for reset counter to 00
I dont know how to configure pic bits in proteus...
Have you any link or doc for this?
If than kindly guide me please
Thanks again
 

Re: Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0

double click on the PIC then properties dialogue box will open, under Program Configuration Word type the required config word.
I tested your code in program itself with following configuration and it was working,
either use the code in your program or use 0xFCF7 in proteus.

Code:
// CONFIG 0xFCF7
#pragma config FOSC = EXTRCCLK  // Oscillator Selection bits (RC oscillator: CLKOUT function on RA4/OSC2/CLKOUT pin, RC on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON       // MCLR Pin Function Select bit (MCLR pin function is MCLR)
#pragma config CP = OFF         // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF      // Brown-out Reset Selection bits (BOR disabled)
#pragma config IESO = ON        // Internal External Switchover bit (Internal External Switchover mode is enabled)
#pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)

For more information refer to following notes https://ww1.microchip.com/downloads/en/DeviceDoc/31027a.pdf or google it for more simpler notes
 

Attachments

  • Prop.png
    Prop.png
    121.7 KB · Views: 134
  • Like
Reactions: hirenn

    hirenn

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top