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)
}
}