I will run the uart4 of MK10FX512VLQ12.
If I set the register UART4_C1 then the controller jumps to "Default_Handler".
I don't understand why this is?
#include <stdint.h>
#include "MK10FX512.h"
#include "pin_mux.h"
#define UIP unsigned int *
const uint8_t buffStart[] = "\r\n UART Send Example \r\n\0";
void UART_PutChar(uint8_t u8Char)
{
/* Wait until space is available in the FIFO */
while (!*(UIP)(UART4_S1 & TDRE));
/* Send the character */
*(UIP)UART4_D = (uint8_t)u8Char;
}
int main(void)
{
int i = 0;
*(UIP)SIM_SCGC5 |= PORTC; /* Port C Clock Gate Control: Clock enabled */
*(UIP)PORTC_PCR14 |= MUX_ALT3; /* DB_RX PTC14 as UART4_RX */
*(UIP)PORTC_PCR15 |= MUX_ALT3; /* DB_TX PTC15 as UART4_TX */
/* uart4 display board */
/* Enable the clock to the selected UART */
*(UIP)SIM_SCGC1 |= UART4; /* UART4 switch on */
/* Make sure that the transmitter and receiver are disabled while we change settings. */
*(UIP)UART4_C2 = 0x00;
/* Configure the UART for 8-bit mode, no parity */
*(UIP)UART4_C1 = 0x00;
/* Set baud rate referring K10P144M120SF3RM.pdf table 48-351 */
/* SBR */
*(UIP)UART4_BDH &= ~(UART_BDH_SBR_MASK); // 0x1F
*(UIP)UART4_BDL = 0x21;
/* BRFA */
*(UIP)UART4_C4 &= ~(UART_C4_BRFA_MASK);
/* Enable receiver and transmitter */
*(UIP)UART4_C2 |= (UART_PE | UART_TE);
while(buffStart[i] != '\0')
{
UART_PutChar(buffStart[i++]);
}
for (;;) {
}
return 0;
}
Solved! Go to Solution.
I found my fault. The uart register is 8 bit and therefor I have to use a point to an 8 bit int.
#define UI8P uint8_t *
I found my fault. The uart register is 8 bit and therefor I have to use a point to an 8 bit int.
#define UI8P uint8_t *