How, it's quite easy in C !!!
If you want to put all bits of port P as output, just write :
DDRP = 0xff;
And to write datas on port P :
char c;
.../...
PORTP = c;
This suppose DDRP and PORTP are defined in your include file corresponding
to your processor. For 9s12dp256 and 9s12xdp512 :
This is in the very beginning of mcçS&édp256.h
#define _IO_BASE 0
#define _ADDR(off) (unsigned char volatile *)(_IO_BASE + off)
#define _P(off) *(unsigned char volatile *)(_IO_BASE + off)
#define _LP(off) *(unsigned short volatile *)(_IO_BASE + off)
.../...
And this is how the P port is defined in the same .h file :
#define PORTP PTP
#define PTP _P(0x0258)
.../...
#define DDRP _P(0x025A) // Data Direction Register
That means, in fine, PORTP and DDRP are defined as below :
#define PORT *(unsigned char volatile *) 0x0258
#define DDRP *(unsigned char volatile *) 0x025A
Hope this helps.
Joel
-----Message d'origine-----
De :
68HC12@... [mailto:
68HC12@...] De la part de
justin.lucas134
Envoyé : samedi 5 septembre 2009 14:26
À :
68HC12@...
Objet : [68HC12] Re: How to use Port P as an output pin?
You will have to configure the DDRP (Data Directional Register P) to output.
Pending on the HC12 you are using, you will have to set the bits [0-7] of
the DDRP address to logic 1. Not sure how to do it in C, but I have seen
examples in this group on how to do that.
Good Luck
Justin
--- In
68HC12@..., "deniz_kerimoglu" <deniz.kerimoglu@...>
wrote:
>
> Hi everyone,
>
> I got a simple question. I need to use port p as general purpose output, I
need to take 0V or 5V output from any of pp0-pp5 pins? How can I achieve it
in C?
>
> Regards.
>
------------------------------------
Yahoo! Groups Links