[mc1322x] problems with the UART

Jon Smirl jonsmirl at gmail.com
Mon Jan 4 23:50:05 EST 2010


Setup looks like this now:

void uart1_init(void) {
	uint8_t i;
		
	/* Restore UART regs. to default */
	/* in case there is still bootloader state leftover */
	
	/* INC = 767; MOD = 9999 works: 921600 @ 24 MHz 8 bit sample */
	#define INC 3071
	#define MOD 9999
	reg32(UART1_BR) = INC << 16 | MOD;

	/* see Section 11.5.1.2 Alternate Modes */
	/* you must enable the peripheral first BEFORE setting the function
in GPIO_FUNC_SEL */
	/* From the datasheet: "The peripheral function will control
operation of the pad IF */
	/* THE PERIPHERAL IS ENABLED. */
	reg32(UART1_CON) = 0x00001403; /* enable receive and transmit */
	reg32(GPIO_FUNC_SEL0) = ( (0x01 << (14*2)) | (0x01 << (15*2)) ); /*
set GPIO15-14 to UART (UART1 TX and RX)*/

	/* interrupt when 28 bytes are free */
	reg32(UT1CON) = 28;

	head = tail = 0;
}


-- 
Jon Smirl
jonsmirl at gmail.com



More information about the mc1322x mailing list