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.

Problem with INTVEC on cc2540 keyfob when using hal_uart and hal_key

Other Parts Discussed in Thread: CC2540

Hi,

I'm using keyfob from cc2540 mini DK and  blestack 1.3 (BloodPressure project). When I switched on HAL_UART=TRUE, I got following warning

Warning[w52]: More than one definition for the byte at address 0x6b in common segment INTVEC. It is defined in module "hal_uart" as well as in module "hal_key"

which prevents hal_key to work properly (no key press interrupts).

Any hints how to solve this ?

Preprocessor defines I use:

INT_HEAP_LEN=3072
HALNODEBUG
OSAL_CBTIMER_NUM_TASKS=1
HAL_AES_DMA=FALSE
HAL_DMA=TRUE
POWER_SAVING
xPLUS_BROADCASTER
HAL_LCD=FALSE
HAL_LED=TRUE
HAL_UART=TRUE
CC2540_MINIDK

  • Already found the problem.

    By default HAL_UART_DMA=1 is defined, which configures interrupts on P0 where keys are already connected (P0_0, P0_1).

    The correct configuration should use P1 where in fact uart is connected. So, HAL_UART_DMA=2 should be used instead.

  • If you use keyfob hardware and you want to use uart0 on P1 alt.2 (the only possible configuration with keyfob) in DMA mode, you will have to modify dma uart driver. 

    The driver in ble stack 1.3 supports only uart0 n P0 (HAL_UART_DMA=1) and uart1 on P1 (HAL_UART_DMA=2).

  • same for the ISR driver. I had to modify it to get UART working on the other port/alt

  • Hi,

    I am new on this Forum and new to BLE Development as well.

    I'm using keyfob from cc2540 mini DK and  blestack 1.3 --(HostTestRelease) Project.

    Preprocessor defines I use for Power Saving mode si put in below.

    INT_HEAP_LEN=2000
    HALNODEBUG
    OSAL_CBTIMER_NUM_TASKS=1
    POWER_SAVING
    xHAL_LED=FALSE
    xHAL_KEY=FALSE
    HAL_AES_DMA=FALSE
    HAL_DMA=TRUE
    HAL_UART=TRUE
    HAL_UART_DMA=2
    HAL_UART_ISR=0
    HAL_UART_SPI=2
    HAL_UART_PORT=TRUE

    and when i build this project a am getting below mention error. 

    Error[Pa052]: #pragma "call_graph_root" can only be used on a definition C:\Users\IRBNMO\Desktop\Texas Instruments\BLE-CC254x-1.3\Components\hal\target\CC2540EB\_hal_uart_spi.c 1049

    Error[Pe247]: function "port1Isr" has already been defined (at line 1020 of "C:\Users\IRBNMO\Desktop\Texas Instruments\BLE-CC254x-1.3\Components\hal\ C:\Users\IRBNMO\Desktop\Texas Instruments\BLE-CC254x-1.3\Components\hal\target\CC2540EB\_hal_uart_spi.c 1049                                   target\CC2540EB\_hal_uart_dma.c")

    Your valuable suggestion as most welcome. 

    Thanks a ton in advance.

    Abhishek Verma


  • @wrymarki ... this post (HAL_UART_DMA=2) helped me get around my problem... but now I have to modify the dma uart driver and would help to know how... basically I'm trying to get a UART connected to the keyfob on the TEST header (P1)

    thanks in advance

  • The easiest way is to define your own  #define HAL_UART_DMA 3 and under this define configure uart0 on P1 properly. You have to look into cc2540 spec for proper configuration of all necessary registers.

    I guess it's enough to change  _hal_uart_dma.c, hal_uart.c and hal_board_config.h

    Just look for HAL_UART_DMA == 1 or  HAL_UART_DMA == 2 in those files and add

    #elif  (HAL_UART_DMA == 3) 

    <configure properly registers here>

    #endif

    And don't  forget to define HAL_UART_DMA=3 in your project.

    Here you are what I found from my old project. However, I'm not sure how proper it is and if that was my last working version.

    _hal_uart_dma.c:

    #elif (HAL_UART_DMA == 3)
    #define UxPORT 0
    #define UxCSR U0CSR
    #define UxUCR U0UCR
    #define UxDBUF U0DBUF
    #define UxBAUD U0BAUD
    #define UxGCR U0GCR
    #define UTXxIE UTX0IE
    #define UTXxIF UTX0IF
    #endif

    ..

    #elif (HAL_UART_DMA == 3)
    #define PxSEL P1SEL
    #define HAL_UART_PERCFG_BIT 0x01 // USART0 on P1, Alt-2; so set this bit.
    #define HAL_UART_PRIPO 0x00 // USART0 priority over UART0.
    #define HAL_UART_Px_CTS 0x04 // Peripheral I/O Select for CTS flow control.
    #define HAL_UART_Px_RTS 0x05 // Peripheral I/O Select for RTS must be manual.
    #define HAL_UART_Px_SEL 0x30 // Peripheral I/O Select for Rx/Tx.
    #endif

    ....

    #elif (HAL_UART_DMA == 3)
    #define DMA_PAD U0BAUD
    #define DMA_UxDBUF HAL_DMA_U0DBUF
    #define DMATRIG_RX HAL_DMA_TRIG_URX0
    #define DMATRIG_TX HAL_DMA_TRIG_UTX0
    #endif

    ....

    #elif (HAL_UART_DMA == 3)
    #define PxDIR P1DIR
    #define PxIEN P1IEN
    #define PxIFG P1IFG
    #define PxIF P1IF
    #define DMA_RDYIn P1_2
    #define DMA_RDYOut P1_3
    #define DMA_RDYIn_BIT BV(2) // Same as the I/O Select for CTS flow control.
    #define DMA_RDYOut_BIT BV(3) // Same as the I/O Select for manual RTS flow ctrl.
    // Falling edge ISR on P1.4-7 pins.
    #define PICTL_BIT BV(2)
    #define IENx IEN1
    #define IEN_BIT BV(5)

    #endif

    ..

    also HalUARTInitDMA()  should be adjusted:

    static void HalUARTInitDMA(void)
    {
    halDMADesc_t *ch;
    #if (HAL_UART_DMA == 1)
    PERCFG &= ~HAL_UART_PERCFG_BIT; // Set UART0 I/O to Alt. 1 location on P0.
    #elif (HAL_UART_DMA == 2)
    PERCFG |= HAL_UART_PERCFG_BIT; // Set UART1 I/O to Alt. 2 location on P1.
    #elif (HAL_UART_DMA == 3)
    PERCFG |= HAL_UART_PERCFG_BIT; // Set UART0 I/O to Alt. 2 location on P1
    #endif

    PxSEL |= HAL_UART_Px_SEL; // Enable Peripheral control of Rx/Tx on Px.
    UxCSR = CSR_MODE; // Mode is UART Mode.
    UxUCR = UCR_FLUSH; // Flush it.
    #if ((HAL_UART_DMA == 1) || (HAL_UART_DMA == 2))
    P2DIR &= ~P2DIR_PRIPO;
    P2DIR |= HAL_UART_PRIPO;
    #elif (HAL_UART_DMA == 3)
    P2SEL |= 0x48; //set priority on P1: usart 0 over usart1
    #endif

    ....

    changes in hal_uart.c are quite obvious I guess.

    I hope that helped you.

  • Thank you very much wrymarki,


    Very helpful guide if you want to use UART and SPI

    the only difference is I used different ports for my UART but still... works like a charm...