I require too many tasks to be completed in relation to how long the loop() takes to repeat.
The LPC1227 that I'm using was chosen because it's perfect for something else I'm working on. This Arduino port is a side effect really. I see the 1227 as a Mega1284 on steroids, and as I think the 1284 is the perfect general-purpose "Arduino" chip I love the 1227 for being the same only better.
struggling with getting a FAT library for an an SD card to work properly over a year later!
Yikes! I won't spend that much time on a library I think. Actually one issue I have is that I'm stuck with C and no C++, that's because you have to pay for C++ and I'm not sure I want to do that yet. I will have to make that decision soon though as the more I write the harder it will be to port my port 
It will interesting to see what has been ported and what hasn't when it (finally) comes out.
Very much so.
my suspicions for the delay of the Due is that doing exactly what we are discussing here is actually much easier to discuss than do!
My thoughts as well, so I'm not going to kill myself trying to replicate what the Arduino guys are presumably doing as we speak. As I say on the linked web page "to create a familiar environment for Arduino programmers" (by which I mean the language and function calls, not the IDE), I want something that is familiar and that hides all the register twiddling that it still necessary, for example here's the code I've written to set up a UART and associated structures in memory
serialConnection * serialCreate (uint8 port, uint32 baudrate, uint8 data_bits, uint8 parity, uint8 stop_bits,
uint8 rx_buff_size, uint8 tx_buff_size) {
LPC_UART0_Type * uart;
uint32 clkDiv;
serialConnection * s;
if (port > MAX_SERIAL_CONNECTIONS) {
SYS_ERROR (ERR_SERIAL_BAD_PORT | 1);
SYS_ERROR (ERR_SERIAL_INIT_FAILED);
return (serialConnection *)ERROR;
}
/////////////////////////////////////////////////////////////////
// Create the serial structure
s = (void*)safeMalloc(sizeof (serialConnection));
if (s == NULL) {
SYS_ERROR (ERR_SERIAL_INIT_FAILED | 2);
return (serialConnection *)ERROR;
}
serialConnections [port] = s;
s->object_id = OBJID_SERIAL_CONNECTION;
s->not_object_id = ~OBJID_SERIAL_CONNECTION;
/////////////////////////////////////////////////////////////////
//
switch (port) {
case SERIAL_UART0:
/////////////////////////////////////////////////////////////////
// Setup Rx and Tx pins
pinFunc (1, FUNC_RXD0);
pinFunc (2, FUNC_TXD0);
s->rxPin = 1;
s->txPin = 2;
/////////////////////////////////////////////////////////////////
// Disable this UART's interrupt for the duration
NVIC_DisableIRQ(UART0_IRQn);
/////////////////////////////////////////////////////////////////
// Set a pointer to the UART structure. Note that UART0 and UART1 have different
// structs but for the purposes of this function they are the same because
// we are not using the RS-485 features of UART0
uart = LPC_UART0;
s->uart = uart;
/////////////////////////////////////////////////////////////////
// Create Rx and Tx buffers
s->RxBuffer = FIFObuffer16Create(rx_buff_size);
if (s->RxBuffer == NULL) {
free (s);
SYS_ERROR (ERR_SERIAL_INIT_FAILED | 3);
return (serialConnection *)ERROR;
};
s->TxBuffer = FIFObuffer16Create(tx_buff_size);
if (s->TxBuffer == NULL) {
free (s);
free (s->RxBuffer);
SYS_ERROR (ERR_SERIAL_INIT_FAILED | 4);
return (serialConnection *)ERROR;
}
/////////////////////////////////////////////////////////////////
// Release the UART's reset
LPC_SYSCON->PRESETCTRL |= (0x1 << 2); // Set UART0_RST_N bit
/////////////////////////////////////////////////////////////////
// Enable the UART's AHB clock
LPC_SYSCON->SYSAHBCLKCTRL |= (0x1 << 12); // Set UART0 bit
/////////////////////////////////////////////////////////////////
// Set the UART's clock divider
LPC_SYSCON->UART0CLKDIV = 0x1; // divide by 1, may be different later
/////////////////////////////////////////////////////////////////
// Get the clock divider for later use in baudrate calcs
// Could use the constant 1 but maybe this will change later
// so we just re-read the register
clkDiv = LPC_SYSCON->UART0CLKDIV;
break;
case SERIAL_UART1:
// NOTE: Comments as per the above UART0 code
pinFunc (8, FUNC_RXD1);
pinFunc (9, FUNC_TXD1);
s->rxPin = 8;
s->txPin = 9;
NVIC_DisableIRQ(UART1_IRQn);
uart = (LPC_UART0_Type*) LPC_UART1;
s->uart = uart;
s->RxBuffer = FIFObuffer16Create(rx_buff_size);
if (s->RxBuffer == NULL) {
free (s);
SYS_ERROR (ERR_SERIAL_INIT_FAILED | 5);
}
s->TxBuffer = FIFObuffer16Create(tx_buff_size);
if (s->TxBuffer == NULL) {
free (s);
free (s->RxBuffer);
SYS_ERROR (ERR_SERIAL_INIT_FAILED | 6);
}
LPC_SYSCON->PRESETCTRL |= (0x1 << 3); // Set UART1_RST_N bit
LPC_SYSCON->SYSAHBCLKCTRL |= (0x1 << 13); // Set UART1 bit
LPC_SYSCON->UART1CLKDIV = 0x1; // divide by 1, may be different later
clkDiv = LPC_SYSCON->UART1CLKDIV;
break;
default:
free (s);
SYS_ERROR (ERR_SERIAL_INIT_FAILED | (port << 8) | 7);
return (serialConnection *)ERROR;
}
/////////////////////////////////////////////////////////////////
//
// Start with a blank slate in the Line Control Register
//
uart->LCR = 0;
/////////////////////////////////////////////////////////////////
//
// Setup data bits
//
if (data_bits < 5 || data_bits > 8) {
SYS_ERROR (ERR_SERIAL_BAD_DATA_BITS | data_bits);
data_bits = UART_DATA_BITS_8;
}
uart->LCR |= data_bits - 5;
s->data_bits = data_bits;
/////////////////////////////////////////////////////////////////
//
// Setup stop bits
//
if ((stop_bits != UART_STOP_BITS_1) && (stop_bits != UART_STOP_BITS_2)) {
SYS_ERROR (ERR_SERIAL_BAD_STOP_BITS | stop_bits);
stop_bits = UART_STOP_BITS_2;
}
uart->LCR |= stop_bits;
s->stop_bits = stop_bits;
//////////////////////////////////////////////////////////////////
//
// Setup parity
//
if ((parity != UART_PARITY_NONE) &&
(parity != UART_PARITY_ODD) &&
(parity != UART_PARITY_EVEN) &&
(parity != UART_PARITY_FORCE1) &&
(parity != UART_PARITY_FORCE0)) {
SYS_ERROR (ERR_SERIAL_BAD_PARITY);
parity = UART_PARITY_NONE;
}
uart->LCR |= parity;
s->parity = parity;
//////////////////////////////////////////////////////////////////
//
// Setup baudrate
//
uint32_t Fdiv;
Fdiv = ((SystemCoreClock / clkDiv) / 16) / baudrate;
uart->LCR |= 0x80; // DLAB = 1
uart->DLM = Fdiv / 256;
uart->DLL = Fdiv % 256;
uart->LCR &= ~0x80; // DLAB = 0
s->baudrate = baudrate;
//////////////////////////////////////////////////////////////////
//
// Setup Fractional Divide Register
//
uart->FDR = 0x10; // set to default value, does nothing
//////////////////////////////////////////////////////////////////
//
// Setup FIFOs
//
uart->FCR = (1 << 0) | // Enable both FIFOs
(1 << 1) | // Reset Rx FIFO
(1 << 2) | // Reset Tx FIFO
(3 << 7); // RX FIFO trigger level = 14 chars
//////////////////////////////////////////////////////////////////
//
// Ensure a clean start, no data in either Tx or Rx FIFO.
//
while ((uart->LSR & (LSR_THRE | LSR_TEMT)) != (LSR_THRE | LSR_TEMT)) ;
while (uart->LSR & LSR_RDR) clkDiv = uart->RBR;
//////////////////////////////////////////////////////////////////
//
// Clear any line status bits
//
clkDiv = uart->LSR;
//////////////////////////////////////////////////////////////////
//
// Setup and enable UART interrupts
//
uart->IER = IER_RBR | IER_THRE | IER_RX;
if (port == 0)
NVIC_EnableIRQ(UART0_IRQn);
else
NVIC_EnableIRQ(UART1_IRQn);
return s;
}
Now a lot of that is overhead I want to various reasons, but there's also a lot of knowledge required to write into various registers. Much easier to write
my_uart = serialCreate(SERIAL_UART0, 115200, UART_DATA_BITS_8, UART_PARITY_ODD, UART_STOP_BITS_1, 10, 10);
or even
my_uart = serialBegin(SERIAL_UART0, 115200);
Which I guess is the point of a HAL after all.
Rob