- This topic has 1 reply, 2 voices, and was last updated 7 years, 8 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
|
Microcontroller › AVR › how to make PORTB.BIT0=0; and PORTB=0x00; without any libaries
how to make PORTB.BIT0=0; and PORTB=0x00; without any libaries ?
/* atemga32 */
// PORTB Address 0x38
#define PORTB (*(volatile Reg *) 0x38)
typedef struct
{
unsigned char Bit0:1 ;
unsigned char Bit1:1 ;
unsigned char Bit2:1 ;
unsigned char Bit3:1 ;
unsigned char Bit4:1 ;
unsigned char Bit5:1 ;
unsigned char Bit6:1 ;
unsigned char Bit7:1 ;
}Reg;
int main (void)
{
while(1)
{
PORTB.Bit2=1;
/*question here how to write PORTB=0X00; */
}
return 0;
}
Dear,
you can create your own the library for that. However, the MCU will take some time to process, it means that the power will be wasted. Atmege( attiny, or atxmega) use logic switch to turn on or turn off the bit. The reason is that it is already built in assembly instruction set so that MCU can run much faster because of having hardware support.
Have a nice day