交叉矩阵配置图如下:
config2.jpg (183.81 KB, 下载次数: 0)
下载附件
2012-6-24 23:34 上传
生成的端口代码:
/////////////////////////////////////
// Generated Initialization File //
/////////////////////////////////////
#include "C8051F020.h"
// Peripheral specific initialization functions,
// Called from the Init_Device() function
void Reset_Sources_Init()
{
WDTCN = 0xDE;
WDTCN = 0xAD;
RSTSRC = 0x04;
}
void Timer_Init()
{
CKCON = 0x10;
TCON = 0x40;
TMOD = 0x20;
TH1 = 0xC4;
}
void UART_Init()
{
SCON0 = 0x40;
SCON1 = 0x40;
}
void SMBus_Init()
{
SMB0CN = 0x40;
}
void Port_IO_Init()
{
// P0.0 - TX0 (UART0), Push-Pull, Digital
// P0.1 - RX0 (UART0), Open-Drain, Digital
// P0.2 - SDA (SMBus), Open-Drain, Digital
// P0.3 - SCL (SMBus), Open-Drain, Digital
// P0.4 - TX1 (UART1), Push-Pull, Digital
// P0.5 - RX1 (UART1), Open-Drain, Digital
// P0.6 - Skipped, Open-Drain, Digital
// P0.7 - Skipped, Open-Drain, Digital
// P1.0 - Skipped, Open-Drain, Analog
// P1.1 - Skipped, Open-Drain, Analog
// P1.2 - T0 (Timer0), Open-Drain, Digital
// P1.3 - Unassigned, Push-Pull, Digital
// P1.4 - Unassigned, Push-Pull, Digital
// P1.5 - Unassigned, Open-Drain, Digital
// P1.6 - Unassigned, Open-Drain, Digital
// P1.7 - Unassigned, Open-Drain, Digital
// P2.0 - Unassigned, Open-Drain, Digital
// P2.1 - Unassigned, Open-Drain, Digital
// P2.2 - Unassigned, Open-Drain, Digital
// P2.3 - Unassigned, Open-Drain, Digital
// P2.4 - Unassigned, Open-Drain, Digital
// P2.5 - Unassigned, Open-Drain, Digital
// P2.6 - Unassigned, Open-Drain, Digital
// P2.7 - Unassigned, Open-Drain, Digital
// P3.0 - Unassigned, Open-Drain, Digital
// P3.1 - Unassigned, Open-Drain, Digital
// P3.2 - Unassigned, Open-Drain, Digital
// P3.3 - Unassigned, Open-Drain, Digital
// P3.4 - Unassigned, Open-Drain, Digital
// P3.5 - Unassigned, Open-Drain, Digital
// P3.6 - Unassigned, Open-Drain, Digital
// P3.7 - Unassigned, Open-Drain, Digital
P1MDIN = 0xFC;
P0MDOUT = 0x11;
P1MDOUT = 0x18;
XBR0 = 0x05;
XBR1 = 0x02;
XBR2 = 0x46;
}
void Oscillator_Init()
{
int i = 0;
OSCXCN = 0x67;
for (i = 0; i < 3000; i++); // Wait 1ms for initialization
while ((OSCXCN & 0x80) == 0);
OSCICN = 0x0D;
}
// Initialization function for device,
// Call Init_Device() from your main program
void Init_Device(void)
{
Reset_Sources_Init();
Timer_Init();
UART_Init();
SMBus_Init();
Port_IO_Init();
Oscillator_Init();
}
看看这儿的代码:
// P0.5 - RX1 (UART1), Open-Drain, Digital
// P0.6 - Skipped, Open-Drain, Digital
// P0.7 - Skipped, Open-Drain, Digital
// P1.0 - Skipped, Open-Drain, Analog
// P1.1 - Skipped, Open-Drain, Analog
// P1.2 - T0 (Timer0), Open-Drain, Digital
P0.5和P1.2和配置图对不上呀?这是怎么回事?
图和代码不配套应该是你后来把 外部存储器的锁存信号给勾掉了 仔细检查一下吧
一周热门 更多>