pupist 发表于 2013-3-4 21:39:40

PB2 IO翻转不起作用 LGT8F08A 求助!!

我用下面的代码测试LGT8F08A SOP8封装的端口翻转

PIN1 2 3 6 7都成功了
只有PIN4 PB2不能翻转 是常低的哪位大牛能提示一下这个端口有什么特殊么?


nclude <iom164pv.h>
#include "iolgt8f0xa.h"
#include <macros.h>


void port_init(void)
{
PORTA = 0x00;
DDRA= 0xFF;
PORTB = 0x00;
DDRB= 0xFF;
PORTC = 0x00;
DDRC= 0xFF;
PORTD = 0x00;
DDRD= 0xFF;
}

//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
//CLI(); //disable all interrupts
port_init();
/*
MCUCR= 0x00;
EMCUCR = 0x00;
//GIMSK= 0x00;
TIMSK= 0x00; //timer interrupt sources
ETIMSK=0x00;
GICR= 0x00;
PCMSK0=0x00;
PCMSK1=0x00;
SEI(); //re-enable interrupts
//all peripherals are now initialized
*/
}
void delay_1us(void)               //1us延时函数
{
    asm("nop");
}

void delay_nus(unsigned int n)       //N us延时函数
{
    unsigned int i=0;
    for (i=0;i<n;i++)
      delay_1us();
}
void delay_1ms(void)               //1ms延时函数
{
    unsigned int i;
    for (i=0;i<1140;i++);
}

void delay_nms(unsigned int n)       //N ms延时函数
{
    unsigned int i=0;
    for (i=0;i<n;i++)
      delay_1ms();
}
//
void main(void)
{
init_devices();
//insert your functional code here...
while(1)
{
PORTA = 0;
PORTB = 0;
PORTC = 0;
delay_nms(500);
PORTA = 0xFF;
PORTB = 0xFF;
PORTC = 0xFF;
delay_nms(500);
}

pupist 发表于 2013-3-4 22:36:24

请问手册上这个写法怎么理解

PORTB 的地址到底是 0x25还是 0x05呢

qkm11111 发表于 2013-3-5 15:38:05

PORTB – 端口B驱动输出寄存器 地址: 0x05 默认值: 0x00

pupist 发表于 2013-3-5 22:00:40

那0x25怎么理解呢按照官方说法都引用 164pv.h 那个里面都是按照 0x25定义的

pupist 发表于 2013-3-6 00:42:10

无人解答 自己摸索了手册写有些引脚是封装在一起的, 我猜是物理连接的所以端口被不止一个寄存器操作
使用的时候注意不要冲突就可以 已经搞定
这个问题以前竟然没人提 ..

logicgreen 发表于 2013-3-6 13:57:57

pupist 发表于 2013-3-6 00:42 static/image/common/back.gif
无人解答 自己摸索了手册写有些引脚是封装在一起的, 我猜是物理连接的所以端口被不止一个寄存器操作
...

是的,要留意一些IO是绑定在一起的。

oste_ 发表于 2013-3-13 11:50:44

pupist 发表于 2013-3-6 00:42 static/image/common/back.gif
无人解答 自己摸索了手册写有些引脚是封装在一起的, 我猜是物理连接的所以端口被不止一个寄存器操作
...

怎样搞定的?楼主可以说明一下吗?

pupist 发表于 2013-3-16 13:17:59

oste_ 发表于 2013-3-13 11:50 static/image/common/back.gif
怎样搞定的?楼主可以说明一下吗?

有些IO呗两个寄存器同时控制的注意不要冲突就可以
页: [1]
查看完整版本: PB2 IO翻转不起作用 LGT8F08A 求助!!