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.

PIC16f616 Help Please

Status
Not open for further replies.

poxusa

Newbie level 2
Joined
Feb 14, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,291
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
}
 

DelayMs(1); // 1 second delay ???????

Is this 1 second or 1mS delay.
 

Thank you for your reply. I have figured out the code. Yes 1 is for one millisecond.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top