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.

Use BCD Switch to vary Frequency with PIC

Status
Not open for further replies.

lorenzo14

Newbie level 1
Joined
Oct 7, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,291
I just finished going through a beginner’s book and I've learned the basics but I still have a lot of questions. Well I wanted to see if anyone can help write a code for a PIC that would take a BCD switch input and output the frequency. So for example if I set the BCD switch to 9 it would output 9Khz.

Here's what I've done so far:

#include <htc.h>
#include <pic.h>



//Configuration for PIC16F877 Using HI-TECH C COMPILER

__CONFIG (INTIO & WDTDIS & MCLRDIS & UNPROTECT);
// Internal CLK, Watchdog timer off, MCLR off, Code unprotected

//Variable declarations
char BCD_SWITCH;

void main()
{
//Input from switches

//Initialisation
ADCON0 = 7; // A/D ports off

PORTA = 0x00; // clear all PortA
TRISA = 0xFF; // Make all Port A Inputs

//Infinite Loop
//Loop: While 1
while (1)
{
//Get input from switches on Port A
//Input: PORT A -> SWITCHES
TRISA = TRISA | 0xff;
BCD_SWITCH = PORTA;


//Convert BCD_SWITCH setting to an output frequency(Need Help Here)


}


}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top