0
是否有任何方式使用MikroC Pro的PIC庫在基於變化的soft_uart中產生中斷?基於中斷的Soft_Uart與MikroC庫
通過下面的例程讀取的字節是垃圾。我使用的是20MHz晶振,當我拿到一個時,會嘗試32MHz晶振。
char error, data_;
void interrupt(){
if (IOCAF.IOCAF2){
do{
data_ = Soft_Uart_Read(&error);
}while(error);
Soft_Uart_Write(data_);
IOCAF.IOCAF2 = 0;
}
}
void main() {
//set RA2, pin 11, as input
TRISA = 0b001100;
TRISC = 0;
ANSELA = 0;
ANSELC = 0;
//enable interrupts
INTCON.GIE = 1;
//enable interrupt on change
INTCON.IOCIE = 1;
//Clear all IOC flags in PORTA
IOCAF = 0;
//enable rising edge detection on RA2, pin 11
IOCAP.IOCAP2 = 1;
//Initialise software uart Pin11 = Rx, Pin12 = Tx
error = Soft_Uart_Init(&PORTA, 2,1,9600,0);
}