Answer the question
In order to leave comments, you need to log in
How to determine the right F_CPU for MK?
Good afternoon, I work in Atmel Studio and it requires you to set the frequency. #define F_CPU 1000000UL
Is this the frequency of the MK or what and where to look for it?
In one of the examples, I found a value of 2 MHz, but my studio hung and gave an error, but it works fine at 1 MHz. Or UL is not Hz?
And there is a code
int main(void)
{
DDRD = 0xFF;
PORTD = 0b00000000;
while (1)
{
PORTD = 0xFF;
_delay_ms(1000);
PORTD = 0x00;
_delay_ms(1000);
}
}
Answer the question
In order to leave comments, you need to log in
UL is an explicit indication that a constant of type unsigned long is included in the standard of the language itself.
F_CPU is needed so that the compiler knows the frequency of your processor and that, for example, sleep (1) waits for a second, not two. The frequency can be found in the documentation for the processor. (google <process name> datasheet)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question