简体   繁体   English

ATmega4808 32针-针PA0未被设置为高电平

[英]ATmega4808 32 Pin - Pin PA0 doesn't get set HIGH

I'm using an ATmega4808 32 Pin. 我正在使用ATmega4808 32针。 I have 2 LEDs connected to the pins PA0 and PA1. 我有2个LED分别连接到引脚PA0和PA1。 I want to set both high. 我想把两者都设置得很高。 Unfortunatly only the PA1 LED is on. 不幸的是,只有PA1 LED点亮。

I figured out the PA0 Pin could be set to EXTCLK by default. 我发现默认情况下,PA0引脚可以设置为EXTCLK。 If this is the problem i can't find the solution to change the port to GPIO. 如果这是问题,我找不到将端口更改为GPIO的解决方案。

int main(int argc, char** argv) {
    PORTA.DIRSET = PIN0_bm; // Config PA0 as output
    PORTA.DIRSET = PIN1_bm; // Config PA1 as output

    PORTA.OUTSET = PIN0_bm; // Set Pin PA0 to HIGH 
    PORTA.OUTSET = PIN1_bm; // Set Pin PA1 to HIGH 

    while(1){
    }


    return (EXIT_SUCCESS);
}

The configuration of PIN0 is lost by writing again to registers PORTA.DIRSET and PORTA.OUTSET . 再次写入寄存器PORTA.DIRSETPORTA.OUTSET将丢失PIN0的配置。

Try using | (bitwise OR) 尝试使用| (bitwise OR) | (bitwise OR) to not discard PIN0 config: | (bitwise OR)不放弃PIN0配置:

    PORTA.DIRSET  = PIN0_bm; // Config PA0 as output
    PORTA.DIRSET |= PIN1_bm; // Config PA1 as output

    PORTA.OUTSET  = PIN0_bm; // Set Pin PA0 to HIGH
    PORTA.OUTSET |= PIN1_bm; // Set Pin PA1 to HIGH

Or, to set them at the same time: 或者,要同时设置它们:

    PORTA.DIRSET = PIN0_bm | PIN1_bm; // Config PA0 and PA1 as output

    PORTA.OUTSET = PIN0_bm | PIN1_bm; // Set Pin PA0 and PA1 to HIGH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 STM32 - TIM2_ETR 引脚,连接到引脚 PA0(按钮),以奇怪的方式递增定时器 - STM32 - TIM2_ETR pin, connected to pin PA0 (button), incrementing the timer in strange way 如何从atmega32引脚读取输入值? - How to read an input value from atmega32 pin? 尽管 output 设置为 HIGH,为什么 Nucleo 144 上的引脚没有输出足够高的电压? - Why is the pin on a Nucleo 144 not outputting a high enough voltage, despite the output being set to HIGH? freeRTOS 在 atmega32A 上无法正常工作 - freeRTOS doesn't work properly on atmega32A 如何从ARM的32位端口的第15引脚获取值? - How to get value from 15th pin of 32bit port in ARM? 带ATMega164PA的PWM - PWM with ATMega164PA 是否可以将PCINT0和PCINT1用于atmega328pb上的所有引脚中断? - Can I use PCINT0 and PCINT1 for all pin interrupts on atmega328pb? PIN-获取要检测的二进制文件的进程ID? - PIN - get process ID for the Binary being instrumented? PIN从指令地址获取汇编操作码 - PIN get assembly opcodes from instruction address 从没有中断引脚的传感器读取数据的最佳方法,并且在测量准备好之前需要一些时间 - Best way to read from a sensor that doesn't have interrupt pin and requires some time before the measurement is ready
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM