Content originally posted in LPCWare by noahk on Tue Jun 18 12:25:20 MST 2013Hi vs,
I hope Mike's help works for you on getting an ISR set up. I don't have much information on that. Regarding the ISR functionality you can do something like this:
main() {
INTENSET = (1 << 0); // enable rx rdy interrupt
};
isr() {
int intstat = INTSTAT;
if(intstat & (1 << 0)) { // rx rdy interrupt
TXDAT = RXDAT; // write rx data to tx buffer
}
}
For your situation, checking TXRDY doesn't seem necessary. You also don't want to enable the TXRDY interrupt, otherwise you will be stuck in the ISR. Another way of doing this with checking TXRDY could be: (Much more complicated than necessary for your situation, but useful for demonstrating functionality.)
int txrdy_flag;
main() {
txrdy_flag = 0;
INTENSET = (1 << 2) | (1 << 0); // enable tx and rx interrupts
}
isr() {
int intstat = INTSTAT; // equivalent to STAT & INTENSET: ie, only the statuses that you want interrupts for
if(intstat & (1 << 0)) { // rx rdy interrupt
if(!txrdy_flag)
abort_error();
txrdy_flag = 0;
TXDAT = RXDAT; // write rx data to tx buffer
INTENSET = (1 << 2); // re-enable tx rdy interrupt
}
if(intstat & (1 << 2)) { // tx rdy interrupt
if(txrdy_flag)
abort_error();
txrdy_flag = 1; // save tx rdy flag
INTENCLR = (1 << 2); // disable tx rdy interrupt
}
}
Noah