Mplab C30 Compiler Exclusive May 2026

Not a member yet? Register now
×

Mplab C30 Compiler Exclusive May 2026

int main() init_uart_buffer(); unsigned char ch; while (1) if (c30_cbuf_get(&uart_rx, &ch) == 0) // process byte

IFS0bits.U1RXIF = 0;

// Initialize (buffer must be 2^N, ideally in Y data space) void c30_cbuf_init(c30_cbuf_t *cb, unsigned char *buf, unsigned int size) cb->head = 0; cb->tail = 0; cb->mask = size - 1; cb->buffer = buf; cb->len = size; mplab c30 compiler

INTERRUPT(_U1RXInterrupt, 6) while (U1STAbits.URXDA) c30_cbuf_put(&uart_rx, U1RXREG); int main() init_uart_buffer(); unsigned char ch; while (1)

// Interrupt-safe get inline int c30_cbuf_get(c30_cbuf_t *cb, unsigned char *data) if (cb->head == cb->tail) return -1; // empty int main() init_uart_buffer()

// Usage: INTERRUPT(_U1RXInterrupt, 6) /* code */