我正在使用 PlatformIO 和 CLion 对 ATMega324P 微控制器进行编程。该项目是在 mac 上使用 PlatformIO 创建的,并在 CLion 中打开。我可以成功构建程序并在 ATMega324p 上运行它。我成功运行了以下代码。
主文件
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRB |= 1 << PINB0;
while (true)
{
PORTB ^= 1 << PINB0;
_delay_ms(100);
}
}
Platformio.ini
[env:mightycore324]
platform = atmelavr
board = mightycore324
framework = arduino
upload_protocol = usbtiny
board_f_cpu = 16000000L
尽管此代码运行延迟似乎明显不准确。我有没有做任何事情来确保延迟正常工作?