Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Timer

Status
Not open for further replies.

peterzatko

New Member
I need help with my project. Need to do timer from 0 to 999 / (0,1,2 .... 999 every second) and display it in 3 digit 7 segment LED display Here I have a timer from 0 to 9 every second. I need help because I do not know how to proceed ďalej.PIC 16F887.Program is in mikrobasic.
I know I have to use multiplexing. displays are the common cathode.

loop:

PORTA.0 = 1 / on port RA0 - RA2 outputs are the base of the transistor
PORTD = $ 3F / number 0 on the display
delay_ms (900)
PORTD = $ 06
delay_ms (900)
PORTD = $ 5B
delay_ms (900)
PORTD = $ 4F
delay_ms (900)
PORTD = $ 66
delay_ms (900)
PORTD = $ 6D
delay_ms (900)
PORTD = $ 7D
delay_ms (900)
PORTD = $ 07
delay_ms (900)
PORTD = $ 7F
delay_ms (900)
PORTD = $ 6F
delay_ms (900)

goto loop
 
I have just done something similar but used a MAX7219, as the processor had other things to do.

The delays you are using will probably lead to the seven segment display flashing.

What might help is a loop that just outputs to port D with a variable such as SECONDS.

loop
PORTD = SECONDS;
delay_ms(50); //maybe even faster
goto loop

and just have a timer interupt which fires every second and increases SECONDS by 1

Sorry I dont use basic but hopefully you get the idea.
 
Last edited:
Set up timer0 as an 8 bit, 64:1 pre-scale, interrupts on. and write to each individually. The numbers shouldn't flash but stay constant..

Have an array for the figures 0 = 0x3f..etc..

Then in the interrupt write figure A.. next interrupt.. figure B.. so on... adjust the count in the main loop.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top