Re: [piclist] PIC16C733, C programming


Sep 12, 2004

 


----------------------------

#7108 Sep 12, 2004

Hi



Im currently using the lower 4 bits of both ports A and C, and i want

to put both of these into one, 8 bit Byte. Does any of you C

programmers out there, know of a function which could help me with

this. Also does anybody recommend any good embedded C books which

are relavant to pic?



Cheers



----------------------------

#7119 Sep 17, 2004

Im currently using the lower 4 bits of both ports A and C, and i want

>to put both of these into one, 8 bit Byte. Does any of you C

>programmers out there, know of a function which could help me with

>this. Also does anybody recommend any good embedded C books which

>are relavant to pic?



How about something like:-





#define BYTE unsigned char



BYTE result;



result = (PORTA & 0xf) < 4;

result |= PORTB & 0xf;



----------------------------

#7121 Sep 17, 2004

>Im currently using the lower 4 bits of both ports A and C, and i want

> >to put both of these into one, 8 bit Byte. Does any of you C

> >programmers out there, know of a function which could help me with

> >this. Also does anybody recommend any good embedded C books which

> >are relavant to pic?

>

>How about something like:-

>

>#define BYTE unsigned char

>

>BYTE result;

>

>result = (PORTA & 0xf) < 4;

>result |= PORTB & 0xf;



In hindsight the first mask is probably redundant. The following code

should produce the same results. Actually, the optimiser would probably

remove it automatically.



#define BYTE unsigned char



BYTE result;



result = PORTA < 4;

result |= PORTC & 0xf;



----------------------------

#7174 Sep 19, 2004

I assumed he was talking about mapping the variable to the physical locations of the port(s).

Phil Seakins pseakins@...> wrote:> >Im currently using the lower 4 bits of both ports A and C, and i want> >to put both of these into one, 8 bit Byte.  Does any of you C> >programmers out there, know of a function which could help me with> >this.  Also does anybody recommend any good embedded C books which> >are relavant to pic?>>How about something like:->>#define BYTE unsigned char>>BYTE result;>>result = (PORTA & 0xf) < 4;>result |= PORTB & 0xf;

In hindsight the first mask is probably redundant. The following code should produce the same results. Actually, the optimiser would probably remove it automatically.

#define BYTE unsigned char

BYTE result;

result = PORTA < 4;result |= PORTC & 0xf;



to unsubscribe,go to www.yahoogroups.com and follow the instructions







Do you Yahoo!?vote.yahoo.com - Register online to vote today!


S
e
n
i
o
r
T
u
b
e
.
o
r
g