Hi everybody, I am learning to program with MCUs and now i have got the SK-XC164 board.I am trying to transmit via ASC0 a message. This message has 6 equal bytes and I must do it with transmit interrupt. Has anyone a simple program to practise??. The message I would like to see the message through Hyperterminal on PC. Thanks to everyone.
Ok you have a problem to set the interrupt levels.
Anyway I stripped down some previous code to show a bare minimum if this helps you.
#include <xc164.h> #include <intrins.h> unsigned int cnt; unsigned int txSendCount; unsigned char *txTailptr; unsigned char txBuf[] = {"Hello"}; /*****************************************************/ void main(void) { ASC0_CON = 0x0011; ASC0_BG = 0x0011; ALTSEL0P3 |= 0x0400; /* select alternate output function */ _bfld_(P3,0x0C00,0x0400); /* P3.10 (Tx) and P3.11 (Rx) are used */ _bfld_(DP3,0x0C00,0x0400); /* P3.10 (Tx) and P3.11 (Rx) are used */ ASC0_TXFCON = 0x0100; /* transmit FIFO is disabled */ ASC0_TBIC = 0x0079; txSendCount = 0; txTailptr = &txBuf[0]; ASC0_CON |= 0x8000; /* enable baud rate generator */ PSW_IEN = 1; /* globally enable interrupts */ txSendCount = 5; /* set the number of bytes to send */ ASC0_TBIC_IR = 1; /* send message */ for(;;) { /* run forever! */ cnt++; }; } /*****************************************************/ void ASC0_TxBufferIsr (void) interrupt (0x47U) { if (txSendCount > 0) { txSendCount--; ASC0_TBUF = *txTailptr++; } }