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.

[Help] Hi-tech PIC C Beginner need help on i/o

Status
Not open for further replies.

johncsl82

Advanced Member level 4
Joined
Aug 16, 2004
Messages
105
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
925
hi.....

I already search the entrie post for some tutorial dealing with I/O..... but it seems I still have some problem dealing and understanding with the code..... it quite confusing me....

Anyway can you guys to help me out to clear thing up?

ok my questions are:

1. what is the function of "@" and how to utilize it? if A @ 0x03, means A = 0x03 or A address is fixed as 0x03 or else?

2.how do we receive an input coming from a pin?

3.how do we send an ouput to a pin?

4.how to detect incoming data? using infinte loop?

5.how to send or receive a group of binary (0111 0001)? does frequency or time matter?

6.how do we check the microcontroller frequency and modify it?

7.how do we check the microcontroller "time" and modify it?

8.how do declare our own interrupt, plus how to retrieve list of available intterupt in the microcontroller?

9.can we declare our own register?btw, i find register like RCREG, RCIF and etc etc how do we utilize it?

10.if send an ascii character like 'A' do we have to convert to hex then to binary and send it?

11.how do we make the program go into sleep or wait mode?

12.how do we utilize the option pin function, for example PIN PORT C 3 has 3 function, which are RC3/SCK/SCL... plus other available dunction on the microcontroller?

13.PORTB = 0x02 //set 4 bit mode? or it means PORTB1 = 1?

:confused:

Thanks
:eek:
 

i recommend tat u go thru the manual of pic c and to understand the specific functions u hav to understand tat pic's various ragisters for tat u hav to hav a very good look at the pic's data sheet, i believe u will find the answers there, becaz i had the same sort of problem wen i started hitech pic c, if u hav still problems plz dont hesitate to ask,,,

rwgards
 

    johncsl82

    Points: 2
    Helpful Answer Positive Rating
This might Help you out. Did a search here and did not find it.

Good Luck

Enigma460
 

    johncsl82

    Points: 2
    Helpful Answer Positive Rating
Hello

If you have bought the PICC compiler, then you can have a direct customer support form Hi-Tech themselves, I think they will not hesitate to answer any question, even if its as simple as asking them, what is the differnece between PIC16F84 and PIC16F84A :)

My self I don't use any Hi-Tech product, but a friend told me they have excellent customer support.

Regards
 

    johncsl82

    Points: 2
    Helpful Answer Positive Rating
1. what is the function of "@" and how to utilize it? if A @ 0x03, means A = 0x03 or A address is fixed as 0x03 or else?

the address of a is 0x03...

2.how do we receive an input coming from a pin?

ex
char value

value = PB5;

3.how do we send an ouput to a pin?


char value


if ( value == 1)
PB5 = 1;
else
PB5 = 0;


4.how to detect incoming data? using infinte loop?

or an interrupt
or

while ( PB5 == 1 ){
...........
........

}

5.how to send or receive a group of binary (0111 0001)? does frequency or time matter?

what do you mean uart?

6.how do we check the microcontroller frequency and modify it?

if the mcu has the ability to change the frequency
form the OSCCON

7.how do we check the microcontroller "time" and modify it?

???????????

10.if send an ascii character like 'A' do we have to convert to hex then to binary and send it?

NO
value = 'a';



13.PORTB = 0x02 //set 4 bit mode? or it means PORTB1 = 1?

PORTB = 0x02 equal to PORTB = 2 equal to PORTB = 0b00000010;
 

    johncsl82

    Points: 2
    Helpful Answer Positive Rating
xxtigerxx... thank for reply

Code:
5.how to send or receive a group of binary (0111 0001)? does frequency or time matter?

what do you mean uart?

I mean software implementation rather than hardware(UART).......
let say i got a binary '0b0111 0001', if we send it to port a pin 0 (RA0)
we just put like RA0 = 0b0111 0001?

how about receving it in a group?

Code:
7.how do we check the microcontroller "time" and modify it?

???????????

"time" -> prescaler or TMR0 (8-bit timer/counter)

Thanks
 

see in files .h of hi-tech c or MPLaB C
 

    johncsl82

    Points: 2
    Helpful Answer Positive Rating
hai

10) registers like rereg and rcif are special function registers
this registers will be used to configure and control theat particular peripheral

Added after 4 minutes:

11.how do we make the program go into sleep or wait mode?

by executing the instruction sleep wecan go to the sleep mode

12.how do we utilize the option pin function, for example PIN PORT C 3 has 3 function, which are RC3/SCK/SCL... plus other available dunction on the microcontroller?

in this pins the peripehral functions are multiplexed so at a time we can use as a one

13.PORTB = 0x02 //set 4 bit mode? or it means PORTB1 = 1?

ya it is correct

there is no problem to study
you just go through the material more than one time to understand better
still you are not able to understand then do one more time reading
which will help you definitely then concepts you won't forget at any time

best of luck
 

    johncsl82

    Points: 2
    Helpful Answer Positive Rating
i having a little problem here:

Code:
void main()
{
	unsigned char rb, sb;

	TRISA0 = 1;
	TRISB1 = 0;
	TRISB2 = 1;
	TRISB6 = 0;
	TRISB7 = 0;
	RB6 = 0;
	RB7 = 0;
	sb = 0x0f;
	rb = 0;
	for(;;)
	{
		if(RA0 == 1)
		{
			//send8Bits(RB1, 0x0f);
			RB1 = sb;
			//rb = RB2;
		}
		
		rb = RB2;
		//if(receive8Bits(RB2) == 0x0f)
		if(rb == sb)
		{
			RB6 = 1;
			RB7 = 0;
		}
		else
		{
			RB6 = 0;
			RB7 = 1;
		}
	}
}

it seems that RB1 = sb; mean sending out 0b00001111 at a time, is not working..

but if I change sb = 1, it's working....

so does this mean i have to send bit by bit?

Thanks
 

Dear johncsl82

RB1 it is a bit and the bit 1 of port B

sb it is a char it have 8 bits

the compiler will put on RB1 the bit 0 of sb

you could do something like that to take out the bits

the simbol (>>n) makes a rotation to rigth of n bits

RB1 = sb // this put bit 0 out

wait some time

RB1 = sb >> 1; // this will put bit 1

wait some time

RB1 = sb >> 2; // this will put bit 2

if you catch the idea you could use a for stament

unsigned char ucN;
unsigned char ucTime;

for(ucN=0; ucN<=7; ucN++)
{
RB1 = sb >> ucN;
// delay to see it in pin
ucTime = 255;
while(ucTime--){};
}

hope this help you, other way it is using timer0 to put out bit in a sharp time
 

    johncsl82

    Points: 2
    Helpful Answer Positive Rating
hea


if you catch the idea you could use a for stament

unsigned char ucN;
unsigned char ucTime;

for(ucN=0; ucN<=7; ucN++)
{
RB1 = sb >> ucN;
// delay to see it in pin
ucTime = 255;
while(ucTime--){};
}

and
RB1 it is a bit and the bit 1 of port B

sb it is a char it have 8 bits

the compiler will put on RB1 the bit 0 of sb

you could do something like that to take out the bits

the simbol (>>n) makes a rotation to rigth of n bits

RB1 = sb // this put bit 0 out

wait some time

RB1 = sb >> 1; // this will put bit 1

wait some time

RB1 = sb >> 2; // this will put bit 2


so delays r required


test some basic mode s first for all the timers

if u have a osscilosope and observe then it will be great
in hardware



hope this help you,
 

    johncsl82

    Points: 2
    Helpful Answer Positive Rating
1. what is the function of "@" and how to utilize it? if A @ 0x03, means A = 0x03 or A address is fixed as 0x03 or else?

ans:
@ may sometimes as label
@ pointing address

but there are rules in assembly language that prohibits it.
@ 3:
instead

label3:

if conditions
goto label3


2.how do we receive an input coming from a pin?

ans:
a low or high input level
a digital signals
0 volts = 0 = off
5 volts= 1 = on;a floating signal

3.how do we send an ouput to a pin?

for a data port
pb.0=0x02 // first port - first bit send an output 0010
pb.1=0x03

4.how to detect incoming data? using infinte loop?

ans: compare variable,parameterss

do
{
var ++ // increment or decrement
if(var -compare-value) // detector for control
} while(Var-value) // control -infinite or not

5.how to send or receive a group of binary (0111 0001)? does frequency or time matter?
ans: somehow yes if you are grouping it into a bits ,byte, word - or equivalent data type but in syncronizations times matter most and frequency as well


6.how do we check the microcontroller frequency and modify it?
ans:
.. first you have to read the crystal oscilator or its resonator
that produce the pulse of the device-Microcontroller


7.how do we check the microcontroller "time" and modify it?
... need to know also the input clok.. then if you desired designing
clock variability device such as 555 or equivalent family

the formula-RC chargingConstant

F = 1/T
T=RC


8.how do declare our own interrupt, plus how to retrieve list of available intterupt in the microcontroller?
ans:
need to read the data sheet of whatever Microcontroller you want and find out
all the interrupt you are able to map inside its ROm -Interrupt architecture

or a compiler itself able to read the I/O Mapping

9.can we declare our own register?btw, i find register like RCREG, RCIF and etc etc how do we utilize it?

[b]ans:
take note that in I/O map of its microcontroller architecture
the next addresses are reserved for a user temporary storage or say memory
ex

0000 - stack
01F0 - instruction
0FFF - Reserved temporary
FFFF -----

10.if send an ascii character like 'A' do we have to convert to hex then to binary and send it?


ans:
take note all dispaly are characters

' a',bc,d ...'1','3'
in digital system it has an equivalent aschi code in hex,
which hex also has an equivalent bits

ex
'a' = 40h = 01010>> this what you are processing inside the machine

11.how do we make the program go into sleep or wait mode?
ans:you use loop and its equivalent interrupt

12.how do we utilize the option pin function, for example PIN PORT C 3 has 3 function, which are RC3/SCK/SCL... plus other available dunction on the microcontroller?

13.PORTB = 0x02 //set 4 bit mode? or it means PORTB1 = 1?
you are refrerring to a declarations a hex value assigned to a port
say 2h= 0010

:confused:

maybe not this time anymore


wish i could help...Thanks


Cyrix-Cracker
 

1. what is the function of "@" and how to utilize it? if A @ 0x03, means A = 0x03 or A address is fixed as 0x03 or else?
I recommend not to use "@" instead use BANK1,BANK2... In most cases you cant follow the adress.
 

hi guyes

could you please give me alink or upload abook about the pic microcontrolleres

thanks .....
 

Ouch I don't have the necessary points to download :(

Can a kind soul please donate some points to download this one? Thanks
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top