If I could get help with this I would greatly appreciate it. I'm using a PIC16F84A (I don't doubt its easier to use a different PIC for this project, but this is the PIC I am using).
Basically, I am using 4 digits. "seven-segment-LED"'s. They are common-cathode.
Two digits are for minutes and two are for seconds,obviously.
So I want to be able to have it countdown from any chosen time from 99 minutes . And I Do want to have zero's showing. for example if the count is set at 45 seconds, then the minutes show 00.
I am not a student. I have and am trying to learn electronics myself. I am a slow learner.
I've been working a while now and just seem to be stuck at writing the assembly code. (I think thats the correct term).
So if I am correct in what I know, then the first digit is connected to RA0, (by the common-cathode line), the tens of seconds digit is connected to RA1, the ones for the minutes digit is connected to the RA3 , and the tens of minutes digit is connected to the RA4.
And if I am not mistaken, when writing assembly , the digits from the RA0-RA3 would be "ones,tens,hundreds,thousandths."
I am going to have the segments connect to RBO-RB6.
I won't be using transistors, i just will have the common-cathode lines directly into the pin's.
Because I have not worked with transistors before.
Though I have ordered 4 "2N2222A NPN
General Purpose RF" from www.bitsbox.co.uk .
The common-cathode digits I am using are the "0.56" as shown here http://www.bitsbox.co.uk/optos.html
From what I understand, I can place a push button at pin 4.
yet am uncertain what to do for buttons.If one or two is needed.
I have ordered 3 different kinds of oscillators as well. and by the way, the PIC16F84A I'm using is the -04 , which I believe means the highest used is the 4MHz.
I have two 4MHz crystal oscillators , one is called "HC49/U style can." the other is "low profile can." and a third one I ordered is a "4.19 MHz Ceramic Resonator".
I am uncertain which one to use . (and how to connect them).
I will be using 6volts DC. obviously four AA batteries.
I'm using MPLAB the recent one. And I am using a JDM Programmer with winpic800.
I have MPLAB at this right now (which is what was there the moment I opened this project using project wizard) :
;**********************************************************************
; *
; This file is a basic code template for assembly code generation *
; on the PIC16F84A. This file contains the basic code *
; building blocks to build upon. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler (Document DS33014). *
; *
; Refer to the respective PIC data sheet for additional *
; information on the instruction set. *
; *
;**********************************************************************
; *
; Filename: xxx.asm *
; Date: *
; File Version: *
; *
; Author: *
; Company: *
; *
; *
;**********************************************************************
; *
; Files required: P16F84A.INC *
; *
; *
; *
;**********************************************************************
; *
; Notes: *
; *
; *
; *
; *
;**********************************************************************
list p=16F84A ; list directive to define processor
#include <p16F84a.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;***** VARIABLE DEFINITIONS
w_temp EQU 0x0C ; variable used for context saving
status_temp EQU 0x0D ; variable used for context saving
;**********************************************************************
RESET_VECTOR CODE 0x0000 ; processor reset vector
goto start ; go to beginning of program
ISR CODE 0x0004 ; interrupt vector location
Interrupt:
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
; Place ISR Here
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
MAIN_PROGRAM CODE
start:
; remaining code goes here
goto $
END ; directive 'end of program'
If anyone is willing to do so, will you write the assembly code I am suppose to place here? I would appreciate it very much.
Also, (if anyone does help), do I erase all that is above and replace it with the written code? and what do I set the other things to, such as watchdog timer, oscilator etc.
What matters most to me is that my timer works. but if it can also do a cool thing at the end of countdown like: once the timer digits reaches zero, have the LED's for each digit at the same time, turn on the segments and off, so it looks like the top part of the digit comes on, then the b segments, then the c, you know? as though the light is moving around for each digit...
So if anyone could, I would really appreciate it.
-Aaron
Basically, I am using 4 digits. "seven-segment-LED"'s. They are common-cathode.
Two digits are for minutes and two are for seconds,obviously.
So I want to be able to have it countdown from any chosen time from 99 minutes . And I Do want to have zero's showing. for example if the count is set at 45 seconds, then the minutes show 00.
I am not a student. I have and am trying to learn electronics myself. I am a slow learner.
I've been working a while now and just seem to be stuck at writing the assembly code. (I think thats the correct term).
So if I am correct in what I know, then the first digit is connected to RA0, (by the common-cathode line), the tens of seconds digit is connected to RA1, the ones for the minutes digit is connected to the RA3 , and the tens of minutes digit is connected to the RA4.
And if I am not mistaken, when writing assembly , the digits from the RA0-RA3 would be "ones,tens,hundreds,thousandths."
I am going to have the segments connect to RBO-RB6.
I won't be using transistors, i just will have the common-cathode lines directly into the pin's.
Because I have not worked with transistors before.
Though I have ordered 4 "2N2222A NPN
General Purpose RF" from www.bitsbox.co.uk .
The common-cathode digits I am using are the "0.56" as shown here http://www.bitsbox.co.uk/optos.html
From what I understand, I can place a push button at pin 4.
yet am uncertain what to do for buttons.If one or two is needed.
I have ordered 3 different kinds of oscillators as well. and by the way, the PIC16F84A I'm using is the -04 , which I believe means the highest used is the 4MHz.
I have two 4MHz crystal oscillators , one is called "HC49/U style can." the other is "low profile can." and a third one I ordered is a "4.19 MHz Ceramic Resonator".
I am uncertain which one to use . (and how to connect them).
I will be using 6volts DC. obviously four AA batteries.
I'm using MPLAB the recent one. And I am using a JDM Programmer with winpic800.
I have MPLAB at this right now (which is what was there the moment I opened this project using project wizard) :
;**********************************************************************
; *
; This file is a basic code template for assembly code generation *
; on the PIC16F84A. This file contains the basic code *
; building blocks to build upon. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler (Document DS33014). *
; *
; Refer to the respective PIC data sheet for additional *
; information on the instruction set. *
; *
;**********************************************************************
; *
; Filename: xxx.asm *
; Date: *
; File Version: *
; *
; Author: *
; Company: *
; *
; *
;**********************************************************************
; *
; Files required: P16F84A.INC *
; *
; *
; *
;**********************************************************************
; *
; Notes: *
; *
; *
; *
; *
;**********************************************************************
list p=16F84A ; list directive to define processor
#include <p16F84a.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;***** VARIABLE DEFINITIONS
w_temp EQU 0x0C ; variable used for context saving
status_temp EQU 0x0D ; variable used for context saving
;**********************************************************************
RESET_VECTOR CODE 0x0000 ; processor reset vector
goto start ; go to beginning of program
ISR CODE 0x0004 ; interrupt vector location
Interrupt:
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
; Place ISR Here
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
MAIN_PROGRAM CODE
start:
; remaining code goes here
goto $
END ; directive 'end of program'
If anyone is willing to do so, will you write the assembly code I am suppose to place here? I would appreciate it very much.
Also, (if anyone does help), do I erase all that is above and replace it with the written code? and what do I set the other things to, such as watchdog timer, oscilator etc.
What matters most to me is that my timer works. but if it can also do a cool thing at the end of countdown like: once the timer digits reaches zero, have the LED's for each digit at the same time, turn on the segments and off, so it looks like the top part of the digit comes on, then the b segments, then the c, you know? as though the light is moving around for each digit...
So if anyone could, I would really appreciate it.
-Aaron