i need your help
i am trying atmega128a using AVR studio 7
but one problem is there
when i control DDRB and PORTB into main()
it works fine
but if i control DDRB and PORTB out of main()
if becomes error
'expected identifier or '(' before volatile'
i just want to know that why always handing DDRB and PORTB is only in main()
here is my code
#define F_CPU 14745600UL
#include <avr/io.h>
#include <util/delay.h>
DDRB = 0xFF;
PORTB = 0x00;
int main(void)
{
/* Replace with your application code */
PORTB = 0x01;
_delay_ms(300);
while (1)
{
PORTB <<= 1;
_delay_ms(300);
if(PORTB == 0x80){
PORTB = 0x01;
_delay_ms(300);
}
}
}