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.

Re: Hello i want to start pic programming with Hitech c can any one help me

Status
Not open for further replies.

picmicroh

Newbie level 3
Newbie level 3
Joined
Apr 10, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,310
Re: Hello i want to start pic programming with Hitech c can any one help me

Thanks,
PA3040, nikhilsigma, ec_nisarg.

dear 'nikhilsigma' ,
one question to u plz clear me
1. #define status PORTDbits.RD1

here,
Does 'status' mean STATUS register which contains C,Z,RP0,RP1 etc. bits or PORTD1 is definning as 'status' symbol???

if 'status' is not STATUS, then can i write
#define status PORTD,RD1

at the end to "PA3040, nikhilsigma, ec_nisarg" and to all plz send me more easy samples to understand and help to program
 

Re: Hello i want to start pic programming with Hitech c can any one help me

#define creates aliases. With #define status PORTDbits.RD1 statement you can use status = 1 or status = 0 like that in your code instead of PORTDbits.RD1 = 1 or 0
Another example if you have an LED on PORTBbits.RB0 then you can use #define LED PORTBbits.RB0 and in code refer to it like LED = 1, LED = 0, LED = ~LED.
 

Re: Hello i want to start pic programming with Hitech c can any one help me

with this code further u can develop yourself

Code:
/*****		uC Series : PIC16F877A						*****/
/*****		Prog Lang : Hi-tech C						*****/

#include <pic.h> 

unsigned long delay;

void mc_init();

 void main()
 {
	mc_init();

	delay=500;
	while(delay--);

	do
	{
		RC0=1;  // pointing single pin to toggle
		PORTB=0XFF;  // entire port toggling
		delay=50000;
		while(delay--);

		RC0=0;
		PORTB=0X00;
		delay=50000;
		while(delay--);

	
					
	}while(1);
}

void mc_init()
{
	// configure as per ur requirement : 1- I/P ,   0-O/P
	TRISA=0x0F;   
	TRISB=0xFF;
	TRISC=0xFE;   // 11111110 - RC0 only O/P
	TRISD=0x00;
	TRISE=0x00;

	// Reset all port after initialize 	
	PORTA=0X00;
	PORTB=0X00;
	PORTD=0X00;
	PORTC=0X00;
	PORTE=0x00;
	}
 

Re: Hello i want to start pic programming with Hitech c can any one help me

#define status PORTD,RD1

this is wrong, you should write
Code:
#define status PORTDbits.RD1

"PORTxbits" is a structure in include file of pic.
they have made such structures for all sfrs, you can access individual bits by accessing members of such structures,
if you are using mplabx, when you just type ****bits. it will show you available members.

- - - Updated - - -

don't merge status with STATUS.

try different name as alias than SFR names, to avoid misleads.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top