現在、AT32UCB1258 カスタム ボードで RS485 usart 割り込みに取り組んでおり、txempty 割り込みに苦労しています。基本的には、5 バイト送信後に tx を無効にしたいと考えています。私の rx 割り込み (マスター ボードからの受信コマンド) と tx レディ割り込みは正しく発生していますが、tx empty 割り込みはまったく発生していません。USART2 割り込みハンドラで発生する割り込みを区別するために、チャネル ステータス レジスタをチェックしています。どんな助けでも大歓迎です。前もって感謝します!
//***********************USART INT HANDLER***************************************
__attribute__((__interrupt__)) static void rs485Interrupt(void)
{
if(AVR32_USART2.CSR.rxrdy)
{
gpio_set_pin_low(AVR32_PIN_PA08);
AVR32_USART2.IDR.txrdy = 1;
AVR32_USART2.IDR.txempty = 1;
rs485RxInterrupt();
}
else if(AVR32_USART2.CSR.txrdy)
{
AVR32_USART2.IDR.rxrdy = 1;
AVR32_USART2.IDR.txempty = 1;
rs485TxInterrupt();
}
else if(AVR32_USART2.CSR.txempty)
{
gpio_set_pin_low(AVR32_PIN_PA06);
rs485TxEmpty();
}
}
//**********************************************************************************
// this function is in main, and calls txrdy interrupt if data is available to send
static void rs485_write(void)
{
gpio_set_pin_high(AVR32_PIN_PA10);
txBuf[0] = ATEAddress;
AVR32_USART2.THR.txchr = txBuf[0];
tx_outctr = 1;
txLength = 5;
//txempty_flag = false;
txBuf[1] = peaks[loop][0];
txBuf[2] = peaks[loop][1];
txBuf[3] = peaks[loop][2];
txBuf[4] = peaks[loop][3];
AVR32_USART2.IER.txrdy = 1;
}
//************************TX INTERRUPT ROUTINE******************************************
static void rs485TxInterrupt(void)
{
//gpio_set_pin_low(AVR32_PIN_PA06);
for(tx_outctr=1; tx_outctr<=5; tx_outctr++)
{
//AVR32_USART2.THR.txchr = 0x01;
AVR32_USART2.THR.txchr = txBuf[tx_outctr];
//usart_write_char(&AVR32_USART2,(int)txBuf[tx_outctr]);
if (tx_outctr == 5)
{
// if 5btyes are sent, disable tx by causing txempty interrupt
AVR32_USART2.IDR.txrdy = 1;
AVR32_USART2.IER.txempty = 1;
txempty_flag = true;
}
}
//gpio_set_pin_low(AVR32_PIN_PA08);
}
//**********************************************************************************
現在、txempty 割り込みがある場合に gpio_pin06 が Low になるのを監視していますが、その段階に進むことはありません。他の割り込みが正しく起動しているため、usart の初期化、gpio 有効化モジュール、および割り込みレジスタが正しく設定されていると思います。