This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540, UART1 UART (without flow control), Alt.2

Other Parts Discussed in Thread: CC2540

Hi All,

Use CC2540 in custom board, RF part work properly and can communicate with TI iPhone 5 utility.

I'm debuging digital communication part. As reference I use "SimpleBLEPeripheral". My custom board is identical to CC2540 USB dongle, instead pins of CC2540: P1_7, P1_6 connected to Stellaris UART (PA1,PA0 respectively). I don't want use flow control. (see schematic below for clarification)

I want just send to Uart 1, some peace of data. Here is my way:

1. In options of "SimpleBLEPeripheral" 

INT_HEAP_LEN=3072
HALNODEBUG
OSAL_CBTIMER_NUM_TASKS=1
HAL_AES_DMA=TRUE
HAL_DMA=TRUE
xPOWER_SAVING
PLUS_BROADCASTER
HAL_LCD=FALSE
HAL_LED=FALSE
HAL_UART
HAL_UART_DMA=2
xCC2540_MINIDK

2. In "void SimpleBLEPeripheral_Init( uint8 task_id )" I/O and UART configurations:

// IO Config
P0SEL = 0; // Configure Port 0 as GPIO
P1SEL = 0; // Configure Port 1 as GPIO
P2SEL = 0; // Configure Port 2 as GPIO

P0DIR = 0xFF;//P0DIR = 0xFC; // Port 0 pins P0.0 and P0.1 as input (buttons),
// all others (P0.2-P0.7) as output
P1DIR = 0xFF; // All port 1 pins (P1.0-P1.7) as output
P2DIR = 0xEF; // All port 1 pins (P2.0-P2.4) as output

P0 = 0;//P0 = 0x03; // All pins on port 0 to low except for P0.0 and P0.1 (buttons)
P1 = 0; // All pins on port 1 to low
P2 = 0; // All pins on port 2 to low

// Configure UART1 for Alternative 2 => Port P1 (PERCFG.U1CFG = 1)
PERCFG |= 0x02;
// P1SEL.SELP1_4/5/6/7 = 1 => CT = P1_4, RT = P1_5, TX = P1_6, RX = P1_7
P1SEL |= 0xC0;
// Configure relevant Port P0 pins back to GPIO function
// P0SEL &= ~0x3C;

// UART Config
halUARTcfg.configured = TRUE;
halUARTcfg.baudRate = HAL_UART_BR_115200;
halUARTcfg.flowControl = FALSE;
halUARTcfg.flowControlThreshold = 48;
halUARTcfg.rx.maxBufSize = 128;
halUARTcfg.tx.maxBufSize = 128;
halUARTcfg.idleTimeout = 6;
halUARTcfg.intEnable = TRUE;
halUARTcfg.callBackFunc = NULL;//sbpSerialPacketParser; // Call-back function

(void)HalUARTOpen( HAL_UART_PORT_1, &halUARTcfg );

3. In "static void performPeriodicTask( void )" function:

HalUARTWrite(HAL_UART_PORT_1,"qwerty",2);

P1^=0x02; //blink LED

I can see blinking led, but oscilloscope show "0" on TX (P1_6) of CC2540

Please any advice. Why data is not transmited throw UART1?

  • I do not see problems in your UART code. However, you do not fill RX callback function. I do not know if this will cause your problem but you can fill it and have another test. If your UART is correctly configured, the TX(P1_6) should be "1" (high status). Do you want to disconnect P1_6 from PA0 and use scope to have a look? Check the TX status, is it high or low to make sure your SW and HW are no problem first.

  • Hi YiKai,

    Thanks for reply. I've just added highlighted text and TX of CC2540 works fine now:

    INT_HEAP_LEN=3072
    HALNODEBUG
    OSAL_CBTIMER_NUM_TASKS=1
    HAL_AES_DMA=TRUE
    HAL_DMA=TRUE
    xPOWER_SAVING
    PLUS_BROADCASTER
    HAL_LCD=FALSE
    HAL_LED=FALSE
    HAL_UART=TRUE
    HAL_UART_DMA=2
    xCC2540_MINIDK

    This gives ability properly tune drivers in "void HalDriverInit (void)" function (file "hal_drivers.c"):

    ..

    /* UART */
    #if (defined HAL_UART) && (HAL_UART == TRUE)
    HalUARTInit();
    #endif

    ..

    As you can see without assign TRUE to HAL_UART HalUARTInit isn't called at all.

  • Hi Varsity,

    I am working on a project about BLE and uart communication. I also use uart1 in alternative 2 location, P1_6. I tried your method but it does not work. Would you mind email me the whole project file? My email address is henry123456236@gmail.com. Thank you!

  • Hi Vasiliy,

    I am using a CC2540EM to connect to an external MCU with my own modified SimpleBLECentral coding. However I keep on getting the same error: PERCFG, P0SEL, etc. are undefined. If I use them in SimpleBLEPeripheral I do not get this error. I really need to get this code going but I seem to be missing an include file or library or something. If possible can anyone please assist me in this matter it would be much appreciated.

    Regards
    Ruart

    EDIT 1: I fixed it

  • Hello Ruart, do you still have you project files?

    Is it possible for you to share them with me? I need to setup a UART communication in a short period of time and I would appreciate your help a lot !

    Thanks.