User guide

config.stack_base = SP; // inherit sp from the execution environment
return config;
}
/*
Below is an equivalent example assembler version of __user_initial_stackheap
It will be entered with the value of the stackpointer in r1 (as set in init.s),
this does not need to be changed and so can be passed unmodified out of the
function.
IMPORT bottom_of_heap
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR r0,=bottom_of_heap
MOV pc,lr
*/
The code in Example 6-6 implements a simple polled RS232 serial driver for the ARM Integrator board. It outputs
single characters on Serial Port A at 9600 Baud, eight data bits, no parity, and one stop bit. Initialize the port with
init_serial_A() before calling sendchar(). To monitor the characters output from the board, use a
null-modem cable to connect the Intergrator serial port A to an RS232 terminal or a PC running a terminal emulator.
Example 6-6 serial.c
#include "intgrt.h"
#include "uart.h"
extern struct uart uart0;
#define UART0_DR uart0.dr
#define UART0_RSR uart0.dr
#define UART0_ECR uart0.ecr
#define UART0_LCRH uart0.lcrh
#define UART0_LCRM uart0.lcrm
#define UART0_LCRL uart0.lcrl
#define UART0_CR uart0.cr
#define UART0_FR uart0.fr
#define UART0_IIR uart0.iir
#define UART0_ICR uart0.iir
void init_serial_A(void)
{
/* First set the correct baud rate and word length */
UART0_LCRL = LCRL_Baud_38400; // LCRL and LCRM writes _MUST_
// be performed before the LCRH
UART0_LCRM = LCRM_Baud_38400; // write as LCRH generates the
// write strobe to transfer the
UART0_LCRH = LCRH_Word_Length_8 | // data.
LCRH_Fifo_Enabled; //
/* Now enable the serial port */
UART0_CR = CR_UART_Enable; // Enable UART0 with no interrupts
}
void sendchar( char *ch )
{
while (UART0_FR & FR_TX_Fifo_Full)
;
if (*ch == '\n') // Replace line feed with '\r'
*ch = '\r';
UART0_DR = *ch; // Transmit next character
}
6.5.4 Building the example
You can build the example using either:
Writing Code for ROM
Copyright ?1999 2001 ARM Limited 6-13