How to Declare GPIO vs Alternate function using 8051 Micro-C

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?

Reply to
benn686
Loading thread data ...

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.
Reply to
Hans-Bernhard Broeker

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

formatting link

Reply to
Steve at fivetrees

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

formatting link
look for the Links to the "bible" which are the original complete data books online.

Reply to
Neil Kurzman

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.