#pragma interrupt_handler gpio_handler
void gpio_handler()
{
:
タクトスイッチ処理、モード変更や設定等
:
LED_1_Invert();
}
void main()
{
//Initialize
LCD_1_Start();
UART_1_CmdReset();
UART_1_EnableInt();
UART_1_Start(UART_1_PARITY_NONE);
LED_1_Start();
INT_MSK0 |= INT_MSK0_GPIO;
M8C_EnableGInt;
while(1) {
if (UART_1_bCmdCheck()) { // Wait for command
if (cmd = UART_1_szGetParam()) { // get command
switch (*cmd) {
case 'R': // Reset
UART_1_CPutString(">Read \r\n");
break;
case 'W': // Write
UART_1_CPutString(">Write \r\n");
break;
}
}
UART_1_CmdReset(); // Reset command buffer
}
:
// モードや設定による処理等
:
CPU_SCR0 |= CPU_SCR0_SLEEP_MASK; //sleep
}
#pragma interrupt_handler rx_handler
void rx_handler()
{
LED_1_Invert();
}
org 2Ch ;PSoC Block DCB03 Interrupt Vector
ljmp _rx_handler
reti
まるで割込み許可されていないような感じだ。
試しに直接割込みフラグをEnableにしてみたが、ダメ。
INT_MSK1 |= INT_MSK1_DCB03; //RX Interrupt enable
void rx_handler()
{
LED_1_Invert();
}
UART_1_IntCntl(UART_1_ENABLE_RX_INT); // Enable RX interrupts
INT_MSK1 |= INT_MSK1_DCB03; // RX Interrupt enable →これは試しにやっただけで本来は不要
M8C_EnableGInt; // Global Interrupt enable
#pragma interrupt_handler rx_handler
org 2Ch ;PSoC Block DCB03 Interrupt Vector
ljmp _UART_1_RX_ISR
reti
ljmp _rx_handler
UART_1_IntCntl(UART_1_DISABLE_RX_INT ); // Enable RX interrupts
while (!(UART_1_bReadTxStatus()&UART_1_TX_COMPLETE)); // wait TX Complete
while (!(UART_1_bReadTxStatus()&UART_1_TX_BUFFER_EMPTY)); // wait TX Complete
while (!(UART_1_bReadTxStatus()&UART_1_TX_BUFFER_EMPTY));
if (UART_1_bReadTxStatus()&UART_1_TX_COMPLETE)
CPU_SCR0 |= CPU_SCR0_SLEEP_MASK; //sleep
while (UART_1_bReadTxStatus()&UART_1_TX_COMPLETE);
Tx Complete is a flag that indicates if a data byte is in the process of being transmitted.
This bit is reset when the register is read.
if (UART_1_bReadTxStatus()&UART_1_TX_COMPLETE)
CPU_SCR0 |= CPU_SCR0_SLEEP_MASK; //sleep
#pragma interrupt_handler gpio_handler
void gpio_handler()
{
if (~PRT1DR&0x40 || !(~PRT1DR&0x03F)) return; // RX変化なら何もしない
: // bit6=RX,bit0〜5=タクトスイッチ
タクトスイッチ処理、モード変更や設定等
:
}
void main()
{
//Initialize
LCD_1_Start();
UART_1_CmdReset();
UART_1_EnableInt();
UART_1_Start(UART_1_PARITY_NONE);
LED_1_Start();
INT_MSK0 |= INT_MSK0_GPIO;
M8C_EnableGInt;
while(1) {
:
// 設定モード、キー入力等のローカル処理
:
// 以下、UARTによるPCリモート処理
if (UART_1_bCmdCheck()) { // Wait for command
if (cmd = UART_1_szGetParam()) { // get command
switch (*cmd) {
case 'R': // Read
UART_1_CPutString(">Read \r\n");
UART_1_PutCRLF();
break;
case 'W': // Write
UART_1_CPutString(">Write \r\n");
UART_1_PutCRLF();
break;
}
}
UART_1_CmdReset(); // Reset command buffer
}
while (~UART_1_bReadTxStatus()&UART_1_TX_BUFFER_EMPTY);
wait_ms(1); // about 1ms delay
CPU_SCR0 |= CPU_SCR0_SLEEP_MASK; // sleep
}