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.

Using UART0 on P1 (.alt2) not success

Other Parts Discussed in Thread: CC2430, CC2540, CC2541

For remaining debug ports and using uart, we are trying to use UART0 with ALT2 : P1

1. We comment out the "HAL_UART_DMA" definition in

Hal_board_cfg.h

to make sure we are using "HAL_UART_ISR=1"

2. We modified the _hal_uart_isr.c ==>

#if (HAL_UART_ISR == 1)
/*
#define PxOUT                      P0
#define PxDIR                      P0DIR
#define PxSEL                      P0SEL
*/
/* We are using uart0 alt2, so we uses port1 */
#define PxOUT                      P1
#define PxDIR                      P1DIR
#define PxSEL                      P1SEL
...

#endif

#if (HAL_UART_ISR == 1)
#define HAL_UART_PERCFG_BIT        0x01         // USART0 on P0, Alt-1; so clear this bit.
/* Holmas : For maintain debug port as well as uart port, we use uart0 alt2 on p1*/
/*

#define HAL_UART_Px_RX_TX          0x0C         // Peripheral I/O Select for Rx/Tx.
#define HAL_UART_Px_RTS            0x20         // Peripheral I/O Select for RTS.
#define HAL_UART_Px_CTS            0x10         // Peripheral I/O Select for CTS.

*/
#define HAL_UART_Px_RX_TX          0x30         // Peripheral I/O Select for Rx/Tx. We are using P1 pin 4,5
#define HAL_UART_Px_RTS            0x08         // Peripheral I/O Select for RTS.
#define HAL_UART_Px_CTS            0x04         // Peripheral I/O Select for CTS.
#else
...

#endif

3. We invoked the uart initialization functionas HalUARTInit( ) and HalUARTOpen( ) in SimpleBLEPeripheral_Init()

  uint8 port = HAL_UART_PORT_0;
  halUARTCfg_t conf;
  conf.baudRate = HAL_UART_BR_38400;
  conf.flowControl = 0;
  HalUARTInit();
  HalUARTOpen(port, &conf);

We believe that the UART interrupt is enabled in HalUARTOpen( ) with the codes

  UxCSR |= CSR_RE;
  URXxIE = 1;
  UTXxIF = 1;  // Prime the ISR pump.

4. Finally, we use the following code to check if there is any receiving data

 if ( events & PERIODIC_EVT )
  {
   uint8 uport = HAL_UART_PORT_0;
   uint8 cbuf[256];
   uint8 readlen;
    // Restart timer
   if (PERIODIC_EVT)
      osal_start_timerEx( simpleBLEPeripheral_TaskID, PERIODIC_EVT, PERIODIC_EVT_PERIOD );
 
    // Perform periodic application task
    performPeriodicTask();
     if( Hal_UART_RxBufLen(uport)) {
        /* read uart*/
        readlen = HalUARTRead(uport, cbuf, sizeof(cbuf));
    }
   
    return (events ^ PERIODIC_EVT);
  } 
 5. Now we put the uart tx rx on keyfob test port

1

x    x  --------> TX ----------------> RX of FDDI

x    x                                                  FDDI  ------------------------- Gnd

x    x <--------- RX ---------------- TX of FDDI

x    x

x    x

TEST

 

But the interrupt service runtine is never called and the periodic checking is never received any data.

Can you help us to fill the gap we missed ?

Wei

  • As I tested , There is something wrong about the port configuration when configure UART0 on ALT2 ( P1 )

    TX port (P1_5) worked but with some minor error.

    RX port (P1_4) didn't work anymore.

    I looked the schematic EB, the P1_4 and P1_5 is on test ports

    1

    X    X <--- P1_5 ( Tx )

    X    X

    X    X <--- P1_4 ( Rx ) here didn't work.

    X    X

    X    X

    Can anyone help me ?

     

  • As I measured by login analyser, when setting UART0, either alt1 or alt2,

    the Rx PIN always keep "low" (0) where as our start bit is also "low".

    I want to setup RX PIN to high, but all my effort failed.

    With my current setting, the

    TX works fine. ( UART0, alt1 or alt2 all ok)

    RX fails. Always low (0).

    I did set the U0UCR to 0x??????10, where did I miss ?

  • Have you checked the state of the PRIxP1 bits in the P2SEL register?  You may need to prioritize the correct peripheral for this pin.

    Jim Noxon

     

  • I checked he P2SEL, it's first three bits are all zero.

    By the way, because I tested uart0 on both P0 and P1, the RX signal voltage always"low", and P2SEL controls

    only the UART priority on P1, so I think it may not be this reason.

    Do you have workable register setting on CC2540EB(Keyfob) with UART0 ?

    I tried over a week and tested all related registers, I think it must be something I truely missed.

    A workable reference can help me very much.

     

  • Have you enabled the receive side of the uart via the UxCSR.RE bit?

    Jim Noxon

     

  • You could take a look at the code and application note here.

    http://focus.ti.com/analog/docs/litabsmultiplefilelist.tsp?docCategoryId=1&familyId=936&literatureNumber=swra306

    I know it is only provided for the CC2430 but the USART in the CC2430 and the CC253x/CC254x parts is identical except that the polarity bit is inverted in the CC253x/CC254x parts (why I dunno).  This code works well but you may need to suck some of the additional defines out of other files.

    If you look at the top of the file, you will see most of what you need to define to get things working.  I believe the following list should get you most of the way there.

    #define UART_CLOCK_MHz // the frequency of the input clock to the USART peripheral

    #define MCU_H iocc2430.h // possibly iocc2430_ext.h

    #define MRFI_CC2430 // to compile the 8051 portions of the header

    You will need to invert the sense of the polarity definitions under the 8051 section as I know those change from the CC2430 to the CC2540.

    If you only are looking for setup configuration, you should be able to get by just using uart.h header only and call the UART_INIT macro to initialize the appropriate registers and then you can use your own code to manage the dynamic operation of the uart.

    You may also need to remove the check for the IAR compiler if you are using a different build tool.

    Jim Noxon

     

  • I got the CC2430 codes and now am trying to port it to CC2540. It takes some time to complete it.

    By the way, you said that we can use a different build tool on CC2540 ?

     Could you give mode information about it ?

  • As you suggested, I ported CC2430 UART driver into CC2540eb keyfob.

    The TX worked fine and the RX still didn't work, for UART0 alt1 and alt2, all failed.

    It seems the RX pin just "DIE". I tried to set it to pullup with PxINP,

    the RX PIN still in LOW state(monitored with logic analyser).

    Is there any possiblility that a PIN is pre-configured as "die-low" state ?

  • The most common build tools in this forum are the IAR compiler, CCS (Code Composer Studio), and MSPGCC.  TI officially only supports the IAR and CCS compilers for supplied code but there are many people on this forum who regularly use the MSPGCC compiler.  The top comunity user of these forums (Jens Michael Gross) uses the MSPGCC compiler.

    Jim Noxon

     

  • ,

    Hi

     

    I have tried above method ..i am not getting no data on hyperterminal..

    can u send me  sample code for uart with pc?...

    Thanks for advance...

     

  • I am also try above code for transmission ...

    it is not working  means ..i am not getting no data on hyperterminal...

    can u send me  working code for cc2540  transmission ?...

     thanks for advance...

     

     

  • Hi I was wondering if you can upload 128KB image that I can put on my BLE112

    Thanks in advance

    Yunus

  • Hi Jim,

    Your DN117 doesn't discuss the polarity on the UART and how to change it. We are using the CC2541 and we see beautiful Tx signal and Rx signal from peripheral. However the peripheral is not responding to commands from the CC2541. We suspect that the polarity may be wrong - that is, the CC2541 is sending data with a polarity opposite to what the peripheral expects. Our question is how do we change the polarity?

    Thoughts?

    Patrick