poxusa
Newbie level 2
Hello. I am programming PIC16f616 microcontroller and having trouble having pins RC0 - RC4 going high as outputs. If you have any suggestion, please let me know. Thank you.
Code:
#include <pic.h>
#include <stdio.h>
#include <htc.h>
#include "delay.h"
#define output_high 0xFF
#define _XTAL_FREQ (4000000L)
#define TRUE 1
__CONFIG(BORDIS amp OSC_4MHZ amp UNPROTECT amp MCLREN amp PWRTDIS amp WDTDIS amp INTCLK);
void main() {
//set RA5 as an digital input
//set RA1 as analog input
//when RA5 is high and RA1 is high -> pins RC0 to RC4 are all high
//when RA5 is low and RA1 is low -> pins RCO to RC4 are all low
CCP1CON = 0b00011100;
INTCON = 0b10100000;
TRISC = 0b00011111;
CCP1CON = 0b00011100;
CCPR1L = 0b00000000;
T2CON = 0b00000101;
OPTION = 0b01000111; //bit 7 RAPU: PORTA Pull-up Enable bit
PR2 = 0b10011011;
ANSEL = 0; // Configure AN pins as digital
// AD1PCFG = 0;
// C1ON_bit = 0; // Disable comparators
// C2ON_bit = 0;
//TRISA = 0x00; // set direction to be output
TRISC = 0b00000000; //Define PORTC as output
PORTC = 0b00000000; //clear PORTC
// TRISC = 0x00; // set direction to be output
do {
PORTA = 0x00; // Turn OFF outputs on PORTA
PORTC = 0x00; // Turn OFF outputs on PORTC
DelayMs(1); // 1 second delay
///__delay_ms(x) // request a delay in milliseconds
PORTA = 0xFF; // Turn ON outputs on PORTA
PORTC = 0xFF; // Turn ON outputs on PORTC
DelayMs(1); // 1 second delay
} while(1); // Endless loop
}