Embedded_Geek
Full Member level 6
Could anyone please tell me as to how the alternate function of port pin are enabled in ATmega32?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
There is no certain register that controls port pins functionality. Instead, each peripheral connects or disconnects itself to the corresponding port pin.Could anyone please tell me as to how the alternate function of port pin are enabled in ATmega32?
Embedded_Geek said:What if I want to use SPI instead of gpio?
void SPI_MasterInit(void)
{
/* Set MOSI and SCK output, all others input */
DDR_SPI = (1<<DD_MOSI)|(1<<DD_SCK);
/* Enable SPI, Master, set clock rate fck/16 */
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
}
• Bit 6 – SPE: SPI Enable
When the SPE bit is written to one, the SPI is enabled. This bit must be set to enable
any SPI operations.
Correct. To be honest, it never happened to me to multiplex alternate functions in a single pin. To be accurate I avoid it.Embedded_Geek said:So whatever peripherals are muliplexed we have to only enable and configure the peripheral without bothering about whether it is multiplexed or not right???