I
I
Ingerniated2017-08-06 15:45:26
Electronics
Ingerniated, 2017-08-06 15:45:26

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);
    }
}

Why does it not show interrupts and alternating 0 and 1, but all 0?
530e26e2e3ad480bb3ac50605336c0fe.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
15432, 2017-08-06
@Ingernirated

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 question

Ask a Question

731 491 924 answers to any question