UART_Send CMSIS2 problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART_Send CMSIS2 problem

966 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by clkunde on Sun Jun 05 12:39:08 MST 2011
Hi my friends.

I'm trying to write on UART0 using the command UART_Send (implementation by CMSIS 2.0) but I'm get wrong characters on PC terminal.
When I use UART_SendByte command, I have no problem. The byte arrive ok.
Look inside UART_Send implementation, I verify that this method call UART_SendByte, so why it doesn't work?
I'm using ETT Chinese Kit with LPC1768, CMSIS 2.0 on Linux and Code Sorcery.
I get the same error when I tried to run CMSIS UART examples.

Here the code. (I dont post .h because calls only CMSIS headers)
/*
 * gps.c
 *
 *  Created on: Jun 4, 2011
 *      Author: clkunde
 */

#include "gps.h"

void ConfigGPS_UART()
{
    /* UART0 */
    UART_CFG_Type UARTConfigStruct;
    UART_FIFO_CFG_Type UARTFIFOConfigStruct;
    PINSEL_CFG_Type PinselConfig;

    PinselConfig.Funcnum = PINSEL_FUNC_1;
    PinselConfig.OpenDrain = 0;
    PinselConfig.Pinmode = PINSEL_PINMODE_NORMAL;
    PinselConfig.Pinnum = PINSEL_PIN_3;
    PinselConfig.Portnum = PINSEL_PORT_0;
    PINSEL_ConfigPin(&PinselConfig);        // RXD0 -> P0.3
    PinselConfig.Pinnum = PINSEL_PIN_2;
    PINSEL_ConfigPin(&PinselConfig);        // TXD0 -> P0.2

    UARTConfigStruct.Baud_rate = 9600;
    UARTConfigStruct.Databits = UART_DATABIT_8;
    UARTConfigStruct.Parity = UART_PARITY_NONE;
    UARTConfigStruct.Stopbits = UART_STOPBIT_1;
    UART_Init(LPC_UART0, &UARTConfigStruct);

    UART_FIFOConfigStructInit(&UARTFIFOConfigStruct);
    UART_FIFOConfig(LPC_UART0, &UARTFIFOConfigStruct);

    UART_TxCmd(LPC_UART0, ENABLE);
}

Here the main.c

#include "main.h"
#include "led.h"
#include "gps.h"
#include "lpc17xx_uart.h"

uint8_t msg_test[] = "NXP LPC1768 UART OK\n\r";

/*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/
/*********************************************************************//**
 * @brief        SysTick handler sub-routine (1ms)
 * @param[in]    None
 * @return         None
 **********************************************************************/
void SysTick_Handler(void)
{
    SysTickCnt++;
}

/*-------------------------PRIVATE FUNCTIONS------------------------------*/
/*********************************************************************//**
 * @brief        Delay function
 * @param[in]    tick - number milisecond of delay time
 * @return         None
 **********************************************************************/
void Delay(unsigned long tick)
{
    unsigned long systickcnt;

    systickcnt = SysTickCnt;
    while ((SysTickCnt - systickcnt) < tick);
}

void InitBuzzerGPIO()
{
    GPIO_SetDir(3, BUZZER, 1);
    GPIO_SetValue(3, BUZZER);
}

void SystemReady()
{
    for (int i = 0; i < 4; i++)
    {
        GPIO_ClearValue(3, BUZZER);
        Delay(100);
        GPIO_SetValue(3, BUZZER);
        Delay(50);
    }
}

/*-------------------------MAIN FUNCTION------------------------------*/
/*********************************************************************//**
 * @brief        c_entry: Main program body
 * @param[in]    None
 * @return         int
 **********************************************************************/
int c_entry(void)
{
    int ascii = 'a';

    SystemInit();
    SystemCoreClockUpdate();

    SysTick_Config(SystemCoreClock / 1000 - 1); /* Generate interrupt each 1 ms   */

    InitLedGPIO();
    InitBuzzerGPIO();
    ConfigGPS_UART();
    SystemReady();


    for (;;)
    {
        UART_Send(LPC_UART0, msg_test, sizeof(msg_test), BLOCKING);
        Delay(500);
        UART_SendByte(LPC_UART0, (uint8_t)ascii++);
        UART_SendByte(LPC_UART0, (uint8_t)'\n');
        UART_SendByte(LPC_UART0, (uint8_t)'\r');
        Delay(500);
    }

}

int main(void)
{
    return c_entry();
}

#ifdef  DEBUG
/*******************************************************************************
 * @brief        Reports the name of the source file and the source line number
 *                 where the CHECK_PARAM error has occurred.
 * @param[in]    file Pointer to the source file name
 * @param[in]    line assert_param error line source number
 * @return        None
 *******************************************************************************/
void check_failed(uint8_t *file, uint32_t line)
{
    /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

    /* Infinite loop */
    while (1)
        ;
}
#endif

/*
 * @}
 */

0 Kudos
Reply
2 Replies

833 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by clkunde on Sun Jun 05 12:59:43 MST 2011

Quote: Zero
So LPCXpresso Forum is perhaps not the best place to ask for help...



You allrigth Zero.
Sory, I made a mistake. I post on wrong forum. But I have the LPC-Link and I will to do the same test.
I post the result later.
0 Kudos
Reply

833 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun Jun 05 12:54:24 MST 2011

Quote:

I'm using ETT Chinese Kit with LPC1768, CMSIS 2.0 on Linux and Code Sorcery.


So LPCXpresso Forum is perhaps not the best place to ask for help...
0 Kudos
Reply