Hi, I'll hope you can help me with this problem.
I've added the "utils/uartstdio.c" to the workspace and also I tested the example code "hello" and works.
If I use UARTConfigSetExpClk i cand send characteres.
Here is my code:
#define RED_LED GPIO_PIN_1
#define BLUE_LED GPIO_PIN_2
#define GREEN_LED GPIO_PIN_3
#define SW1 GPIO_PIN_4
#define SW2 GPIO_PIN_0
// Variables para el control, directo, del angulo.
#define minAlpha 9000 //
#define maxAlpha 590000 // La diferencia es de 581000
uint32_t alpha = maxAlpha; // Nos aseguramos que el motor inicie lento.
// Variables para usar con QEI
uint8_t QEI_fs = 0x01; // Tiempo de captura en el QEI (1/QEI_fs)
float rpm = 0;
// Variables auxiliares para leds
uint8_t state = 0x00; // Variable auxiliar para usar en el led verder, QEI
uint8_t state2 = 0x02;
uint8_t state4 = 0x04;
uint32_t V_rpm[20] ;
uint32_t V_alpha[20] ;
uint8_t count = 0;
void config()
{
SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Reloj del puerto F, Led's e interruptores
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); // Reloj del puerto D, QEI
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
// Configuracion del puerto UART
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // Configure the pins for the receiver and transmitter using GPIOPinConfigure
//UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // Initialize the parameters for the UART: 115200, 8-1-N
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
//
// Initialize the UART for console I/O.
//
UARTStdioConfig(0, 115200, 16000000);
//
UARTStdioConfig(0, 115200, 16000000);
// Configuracion del puerto digital GPIOF
// Se desbloquea el GPIOF_0, para poder ocupar SW2
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01;
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0;
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, RED_LED|BLUE_LED|GREEN_LED);
ROM_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, SW1 | SW2); // Se declara pin de entrada, SW1 y SW2
//ROM_GPIOPadConfigSet(GPIO_PORTF_BASE, SW1 , GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // Se configura la resistencia pull-up PF_4
ROM_GPIOPadConfigSet(GPIO_PORTF_BASE, SW2 , GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // Se configura la resistencia pull-up PF_0
// CONFIGURACIONES DEL QEI
// Se desbloquea le pin GPIOD7, para usarlo con el QEI
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTD_BASE + GPIO_O_CR) |= 0x80;
HWREG(GPIO_PORTD_BASE + GPIO_O_AFSEL) &= ~0x80;
HWREG(GPIO_PORTD_BASE + GPIO_O_DEN) |= 0x80;
HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = 0;
SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0); // Se habilita el periferioco QEI
GPIOPinConfigure(GPIO_PD6_PHA0); // Pin GPIOD6 como PHA0 // GPIOPinConfigure(0x00031806); //0x00031806 =>GPIO_PD6_PHA0
GPIOPinTypeQEI(GPIO_PORTD_BASE, GPIO_PIN_6); // Pin GPIOD6 como PHA0
QEIConfigure(QEI0_BASE,(QEI_CONFIG_CAPTURE_A | QEI_CONFIG_NO_RESET | QEI_CONFIG_CLOCK_DIR | QEI_CONFIG_NO_SWAP), 1725); // Configuracion del enconder de cuadratura
QEIVelocityConfigure(QEI0_BASE, QEI_VELDIV_2, (SysCtlClockGet()/QEI_fs)); // Divide by clock speed to get counts/sec
QEIVelocityEnable(QEI0_BASE); // QEI velocidad activada
// CONFIGURACIONES DEL TIMER
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
TimerConfigure(TIMER0_BASE, TIMER_CFG_ONE_SHOT);
TimerLoadSet(TIMER0_BASE, TIMER_A, minAlpha + alpha);
// CONFIGURACION DE INTERRUPCIONES
IntPrioritySet(INT_TIMER0A, 0x20); // Prioridad 1, del TIMER0
IntEnable(INT_TIMER0A);
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Interrupcion TIMER0, activada
IntPrioritySet(INT_QEI0, 0x04); // Prioridad 2, de la interrupcion QEI
IntEnable(INT_QEI0); // Habilitada interrupcion de QEI
QEIIntEnable(QEI0_BASE,QEI_INTTIMER); // Habilitada la interrupcion QEI
IntPrioritySet(GPIO_PORTF_BASE,0x00); // Prioridad 0, para el cruce por cero.
IntEnable(INT_GPIOF); // Habilitada la interrupcion GPIOF PF_4
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_4); // Habilitada en el pin 4, SW1
//Erase a block of the flash.
//
FlashErase(0x1000);
//
// Program some data into the newly erased block of the flash.
//
//pui32Data[0] = 0;
IntMasterEnable();
// ACTIVACION DE PERIFERICOS
TimerEnable(TIMER0_BASE, TIMER_A);
QEIEnable(QEI0_BASE);
}
void main(void){
config();
while(1){
if(alpha <= 357600){
FlashProgram(V_rpm, 0x1000, sizeof(V_rpm));
FlashProgram(V_alpha,0x106C,sizeof(V_alpha));
while(1);
}
}
}
// Envia el pulso para controlar los SCR's
void Timer0IntHandler(void){
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Clear the timer interrupt
IntMasterDisable(); // Se deshabilitan las interrupciones
GPIOPinWrite(GPIO_PORTF_BASE, RED_LED, 0x02);
ROM_SysCtlDelay(5333); // (3 ciclos de reloj)(12.5ns)(5333) ~ 200us
GPIOPinWrite(GPIO_PORTF_BASE, RED_LED, 0x00);
IntMasterEnable(); // Habilitamos las interrupciones
}
// Obtiene la velocidad del encoder
void QEI0IntHandler(void){
float velocidad;
QEIIntClear(QEI0_BASE,QEI_INTTIMER);
//GPIOPinWrite(GPIO_PORTF_BASE, GREEN_LED, state);
state = ~ state;
velocidad = QEIVelocityGet(QEI0_BASE);
rpm = (velocidad/1024)*60*QEI_fs; // Calculo de las revoluciones
if (alpha > 357600){
alpha -= 11620;
V_rpm[count] =(uint32_t) rpm;
V_alpha[count] = alpha;
count ++;
}
}
// Detecta el cruce por cero y manda el angulo para controlar la velocidad
void GPIOFIntHandler(void){
GPIOIntClear(GPIO_PORTF_BASE, GPIO_INT_PIN_4);
//GPIOPinWrite(GPIO_PORTF_BASE, BLUE_LED, state4);
state4 = ~state4;
TimerLoadSet(TIMER0_BASE, TIMER_A, minAlpha + alpha);
TimerEnable(TIMER0_BASE, TIMER_A);
}