gpt4 book ai didi

c - blackfin bf537 LED 闪烁

转载 作者:行者123 更新时间:2023-11-30 16:42:11 26 4
gpt4 key购买 nike

下面的代码是blackfin bf537的LED闪烁程序示例LED 将从右向左闪烁并切换回来。/**/

EX_INTERRUPT_HANDLER(Timer0_ISR)
{
// confirm interrupt handling
*pTIMER_STATUS = 0x0001;

// shift old LED pattern by one, left to right
if(sLight_Move_Direction)
{
if((ucActive_LED = ucActive_LED >> 1) <= 0x0020) ucActive_LED = 0x1000;
}
else
{
if((ucActive_LED = ucActive_LED << 1) == 0x0020) ucActive_LED = 0x0020;
}

// write new LED pattern to PORTF LEDs
*pPORTFIO_TOGGLE = ucActive_LED;

/**/

现在我正在尝试修改代码来完成新功能,我希望当我按下按钮时它从左到右闪烁一次,所以我的代码如下:/**/

EX_INTERRUPT_HANDLER(Timer0_ISR)
{
// confirm interrupt handling
*pTIMER_STATUS = 0x0001;

// shift old LED pattern by one, left to right
if(sLight_Move_Direction){

ucActive_LED == 0x0800;

ucActive_LED = ucActive_LED >> 1;

ucActive_LED == 0x0040;
}

// write new LED pattern to PORTF LEDs
*pPORTFIO_TOGGLE = ucActive_LED;

/**/

现在它无法工作或只是闪烁 LED3,我该如何修复它?

谢谢

最佳答案

经过几天的思考,这是我的答案:

int Mode;

EX_INTERRUPT_HANDLER(Timer0_ISR)
{
// confirm interrupt handling
*pTIMER_STATUS = 0x0001;

if(Mode == 1)
{
if((ucActive_LED = ucActive_LED >> 1) <= 0x0020)
ucActive_LED = 0x1000;
}
else if(Mode == 2)
{
if((ucActive_LED = ucActive_LED << 1) >= 0x1000)
ucActive_LED = 0x0020;
}
else if(Mode == 3)
{
if((ucActive_LED = ucActive_LED >> 2) <= 0x0020)
ucActive_LED = 0x1000;
}


// write new LED pattern to PORTF LEDs
*pPORTFIO = ucActive_LED;
}

然后将 PORTFIO 设置为从 PF2 到 PF5(SW13~SW10) 的按钮每个按钮对应每种模式,因此我们可以看到模式1是LED从左到右闪烁。模式 2 从右向左闪烁。模式 3 使 LED 2、4 和 6 闪烁。

关于c - blackfin bf537 LED 闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45934029/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com