How to Declare GPIO vs Alternate function using 8051 Micro-C
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
How to Declare GPIO vs Alternate function using 8051 Micro-C

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System
Author Message
Guest






Posted: Thu Dec 08, 2005 1:15 am    Post subject: How to Declare GPIO vs Alternate function using 8051 Micro-C Reply with quote

How do you tell the micro-c compiler that you want to use the pin as a
general purpose i/o versus use the alternative function (like pwm)..

For example, the PWM uses pins CEX0-CEX4, and according to the 8051
datasheet, the port pin must be set to to '1' inorder for the pwm to
drive it.
HOWEVER, If I set the bit this way, "setbit(1.3)", this is how you
configure the port pin to be an input gpio (opposite of what I want).

Is there another way to initialize a port for alternative function and
gpio+direction?
Back to top
Steve at fivetrees
Guest





Posted: Thu Dec 08, 2005 1:15 am    Post subject: Re: How to Declare GPIO vs Alternate function using 8051 Mic Reply with quote

<benn686@hotmail.com> wrote in message
news:1133983898.860586.150380@g14g2000cwa.googlegroups.com...
Quote:
How do you tell the micro-c compiler that you want to use the pin as a
general purpose i/o versus use the alternative function (like pwm)..

For example, the PWM uses pins CEX0-CEX4, and according to the 8051
datasheet, the port pin must be set to to '1' inorder for the pwm to
drive it.
HOWEVER, If I set the bit this way, "setbit(1.3)", this is how you
configure the port pin to be an input gpio (opposite of what I want).

Is there another way to initialize a port for alternative function and
gpio+direction?

The PWM function will be a timer-counter, err, function. You'll need to
setup the specific timer-counter for the mode you need, and enable it.

The port pin being set to 1 requirement probably just means that there is
then no conflict between two possible ways of driving the pin as an output
(the GPIO and the timer-counter).

HTH,

Steve
http://www.fivetrees.com
Back to top
Hans-Bernhard Broeker
Guest





Posted: Thu Dec 08, 2005 1:15 am    Post subject: Re: How to Declare GPIO vs Alternate function using 8051 Mic Reply with quote

benn686@hotmail.com wrote:
Quote:
How do you tell the micro-c compiler that you want to use the pin as a
general purpose i/o versus use the alternative function (like pwm)..

You don't, because the compiler couldn't care less what that the bits
in that SFR are used for.

If such a configuration setting exists for whatever 8051 variant
you're thinking about (and you forgot to tell), that's between you and
the data sheet to figure out.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Back to top
Neil Kurzman
Guest





Posted: Thu Dec 08, 2005 9:15 am    Post subject: Re: How to Declare GPIO vs Alternate function using 8051 Mic Reply with quote

benn686@hotmail.com wrote:

Quote:
How do you tell the micro-c compiler that you want to use the pin as a
general purpose i/o versus use the alternative function (like pwm)..

For example, the PWM uses pins CEX0-CEX4, and according to the 8051
datasheet, the port pin must be set to to '1' inorder for the pwm to
drive it.
HOWEVER, If I set the bit this way, "setbit(1.3)", this is how you
configure the port pin to be an input gpio (opposite of what I want).

Is there another way to initialize a port for alternative function and
gpio+direction?

The 8051 STANDARD pins are quas-bidirectional. The is not make it and
input or out put.
If a pin is set to 1 (by bit or byte) other things like in puts or the PWM
can pull it down.

the 8051 core has been added to by many manufactures. Additional feature
pins may not work this way.

Goto www.8052.com look for the Links to the "bible" which are the
original complete data books online.
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB