1858 views|0 replies

52

Posts

0

Resources
The OP
 

ATmega4809 Curiosity Nano Review Lighting [Copy link]

The most traditional lighting step has arrived. According to the logo on the board, the built-in light on the board corresponds to the PF5 pin.

According to the programming specification of XC8, it can be concluded that:

PORTF = Input and output registers of PF series pins

OUTTGL=Output Value Toggle, which means IO flip

AVR microcontroller comes with a delay function library, which is referenced.

\note As an alternative method, it is possible to pass the
F_CPU macro down to the compiler from the Makefile.
Obviously, in that case, no \c \#define statement should be
used.

Delay.h tells us that we need to configure the clock, that is, F_CPU, before using the delay function. After configuration, find the corresponding delay function template in delay.h and apply it in our program.


This content is originally created by EEWORLD forum user yang8555u . If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

/*
* File: avr-main.c
* Author: 11618
*
* Created on 2019?10?31?, ??1:27
*/

#define F_CPU 2000000/6
#include <xc.h>
#include <util/delay.h>
int main(void) {
PORTF.DIR |=(1<<5);/* Replace with your application code */
while (1) {
PORTF.OUTTGL|= (1<<5);
_delay_ms(500) ;
}
return 0;
}

image.png (46.34 KB, downloads: 0)

image.png
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list