下面是main主函数,用keil调试发现进入不了SMBus中断,大神们给看看为什么?
void main (void)
{
/* volatile */unsigned char dat; // Test counter
unsigned char i; // Dummy variable counters
PCA0MD &= ~0x40; // WDTE = 0 (watchdog timer enable bit)
OSCICN |= 0x03; // Set internal oscillator to highest
// setting of 12000000
// If slave is holding SDA low because of an improper SMBus reset or error
while(!SDA)
{
// Provide clock pulses to allow the slave to advance out
// of its current state. This will allow it to release SDA.
XBR1 = 0x40; // Enable Crossbar
SCL = 0; // Drive the clock low
for(i = 0; i < 255; i++); // Hold the clock low
SCL = 1; // Release the clock
while(!SCL); // Wait for open-drain
// clock output to rise
for(i = 0; i < 10; i++); // Hold the clock high
XBR1 = 0x00; // Disable Crossbar
}
Port_Init (); // Initialize Crossbar and GPIO
Timer1_Init (); // Configure Timer1 for use as SMBus
// clock source
Timer3_Init (); // Configure Timer3 for use with SMBus
// low timeout detect
SMBus_Init (); // Configure and enable SMBus
P2=0x1f;
EIE1 |= 0x01; // Enable the SMBus interrupt
EA = 1;
// Global interrupt enable
// TEST CODE-------------------------------------------------------------------
dat = 0x55; // Output data counter
NUM_ERRORS = 0; // Error counter
while (1)
{
// SMBus Write Sequence
SMB_DATA_OUT = dat; // Define next outgoing byte
TARGET = SLAVE_ADDR; // Target the F3xx/Si8250 Slave for next
// SMBus transfer
SMB_Write(); // Initiate SMBus write
// SMBus Read Sequence
TARGET = SLAVE_ADDR; // Target the F3xx/Si8250 Slave for next
// SMBus transfer
SMB_Read(); // Check transfer data
if(SMB_DATA_IN != SMB_DATA_OUT)
{
NUM_ERRORS++;
LED1 = (!LED1); // 接收到错误LED1灯亮
}
else {};
// Run to here to view the SMB_DATA_IN and SMB_DATA_OUT variables
// dat++;
T0_Wait_ms (1); // Wait 1 ms until the next cycle
}
// END TEST CODE---------------------------------------------------------------
} |