IRQ success
I've had success and updated unix_guy's terminal application to support 115200 baud using the uart rx IRQ and a circular receive buffer.
The new serial application can be downloaded from the Wiki: http://www.elinux.org/wiki/JuiceBoxFAQHardThings
Here are the details:
When the JuiceBox boots FatBox, the CPSR register is 0x60000010 this means IRQ and FIQ interrupts are enabled -- no change to CPSR is needed
When an IRQ interrupt is called, the JuiceBox jumps to location 0x00000018
Location 0x00000018 contains LDR PC, =0x0C000018 which causes a jump to 0x0C000018
(It actually jumps to the location specified at location 0x00000618 which happens to be 0x0C000018)
By default, location 0x0C000018 jumps to the location stored in 0x0C00009C.
So I just leave this alone and put the address of my IRQ handler in location 0x0C00009C
Here are code snippets of the firmware:
The IRQ handler:
__attribute__ ((interrupt("IRQ"))) void IRQ_handler(void)
{
*I_ISPC |= 0x00000080; // Clear the pending interrupt condition, 0x80 = 1 << 7, INT_URXD0
receive_buffer[receive_in_index] = *URXH0;
receive_in_index = (receive_in_index+1) & (RECEIVE_BUFFER_SIZE-1);
}
The IRQ init:
void irq_init()
{
*INTMSK = 0x07FFFFFF; // Disable all interrupts
*INTCON = 0x00000005; // Configure the interrupt controller for non-vectored IRQ
*((uint32_t *)0x0C00009C) = (uint32_t)IRQ_handler; // Set the IRQ handler location
*INTMSK &= (~0x00000080); // Enable the UART RX0 interrupt
*INTMSK &= (~0x04000000); // Enable global interrupts
}
Thats it. Other IRQs should be able to be used as well by enablinng the proper interrupt and checking in the handler for which interrupt caused the handler to be called. The proper interrupt pending bit will need to be cleared as well.
I don't see why fast interrupts (FIQ) shouldn't work also by changing INTCON, but I've not tried this yet.
I don't think vectored interrupts can be used because the vector addresses do not appear to be confgured in ROM