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.

Serial Comm & TIMAC

Other Parts Discussed in Thread: TIMAC, CC2430, Z-STACK, CC2530

I want to add a serial command and control to the TIMAC example, but I'm not sure

how to proceed.  Are there any docs that would guide me through the process?

I've tried setting the defined symbols in the project options to:

HAL_UART=TRUE
SERIAL_APP_PORT=0

Do I need to write an app to Open and Init the serial port?

Has anyone implemented this application?

I'm using the SmartRF04EB DK.

 

  • Yeah, the MAC layer doesn't really come with any examples.  Though there is a serial example in Z-Stack.  Have you looked in the hal libraries?  You will likely find these very useful.  For example, the CC2430 version of has a hal_uart.c located here

     C:\Texas Instruments\TI-MAC-1.2.1\Components\hal\target\CC2430EB

    This will have some Uart routines already written.  Of course, also check your configuration.

    Hope this helps get you a bit further ....

  • Here are some really basic steps to send and receive serial I/O with TIMAC:

    1. Make sure the following files are included in the project: hal_uart.c and hal_driver.c

    2. Define HAL_UART=TRUE in the IDE compiler pre-processor options

    3. Call HalUARTInit() in main()

    4. Call HalUARTOpen() in your program -- see sample code below:

          halUARTCfg_t uartConfig;

          /* UART Configuration */

          uartConfig.configured           = TRUE;

          uartConfig.baudRate             = HAL_UART_BR_38400;

          uartConfig.flowControl          = TRUE;

          uartConfig.flowControlThreshold = 5;

          uartConfig.rx.maxBufSize        = 120;

          uartConfig.tx.maxBufSize        = 120;

          uartConfig.idleTimeout          = 5;

          uartConfig.intEnable            = TRUE;

          uartConfig.callBackFunc         = MT_UartProcessRxData;

          HalUARTOpen (0, &uartConfig); //0 for port 0 and 1 for port 1

    5. Define a callback function MT_UartProcessRxData (defined in the call to HalUARTOpen()) somewhere in your program. This function will be called when the UART receives stuff. The user program can call HalUARTRead() here to read the buffer -- it's totally up to the user to handle the buffer here.

    6. Use HalUARTWrite() to write stuff to the serial port.

  • Thank you for the response.

    I have duplicated your instructions, but the serial port still fails to communicate.  It appears that I'm lacking one more part of the initialization.

    Do HAL_UART_ISR and HAL_UART_DMA need to be set true?   I'm not sure what role these play in the UART. 

     

    Is "uartConfig.flowControl  = TRUE;" required, or can I set it to FALSE to avoid the RTS and CTS operation?

    I set a couple of breakpoints and found the code will call ProcessPoll() in OSAL.c which then calls the

    timer and HalUARTPoll() in hal_uart.c

    Do you have any other recommended places to set breakpoints to verify if the system is actually using the UART?

    Thanks for any assistance.

     

     

  • It does look like you need a couple more settings -- try HAL_UART_ISR=TRUE and HAL_UART_DMA=FALSE.

    You should be able to set uartConfig.flowControl = FALSE if you aren't using CTS.

    If you set a breakpoint at HAL_ISR_FUNCTION( halUart0TxIsr, UTX0_VECTOR ), it should trigger right after HalUARTWrite is called.

  • HAL_UART_ISR=TRUE and HAL_UART_DMA=FALSE

    That did the trick!!!

    Thank you so much.  I'm not very experienced in C code, so reading advanced code just kind of

    glazes my eyes over.  I tried understanding the Zstack SerialApp, but it seemed to confuse me more.  At least now

    I can move on with the meat of my code.  Thanks again!

  • Hi ,
    I am using the CC2430 chip with the smart Rf04 EB. I am having trouble with my UART communication.
    I am able to transmit data using HalUARTWrite(); but I am not able to receive  any data.
    I tried using the function HalUARTRead(), to receive data , but it doesnt work.
    In the halUARTCfg_t uartConfig; described above, i am  not sure what the MT_UartProcessRxData; function is suppose to be.

    Any help is appriciated.

    Thanks

  •  

    MT_UartProcessRxData is the callback function for the UART.

    This is what is contained in mine for reading a single character:

    static void MT_UartProcessRxData(uint8 port, uint8 event)
    {

      uint8   cmdbuff[6];

      HalUARTRead( SERIAL_APP_PORT, cmdbuff, 1);

      switch (cmdbuff[0])
      {
        case '1':
            HalUARTWrite( SERIAL_APP_PORT, "CMD - 1\n\r", 10 );   // Echo character
            break;

        case 'f':
            HalUARTWrite( SERIAL_APP_PORT, "CMD - f\n\r", 10 );
            break;

        default:
            break;

    }

    }

    This callback did not work until I set HAL_UART_ISR=TRUE and HAL_UART_DMA=FALSE.  in the preprocessor directives.

    Hope this helps.  I know how frustrating this can be.

     

  • Sir,
    Thank you for your help. But unfortunately i am still not able to get my HalUARTRead(); to work.
     I am unsure how to make changes at the preprocessor directives.
    I am  new at programming at this level and will appriciate any more help you can provide.

    Thanks

  • In the IAR Workbench go to

    Project> Options> C/C++ Compiler> Preprocessor> Defined Symbols.

    This is what mine has defined:

    CC2430EB
    POWER_SAVING
    HAL_DMA=FALSE
    HAL_AES=FALSE
    HAL_UART_ISR=TRUE
    HAL_UART=TRUE

    I think if you are using another compiler such as Keil, maybe you would

    just use the #define statement for these definitions in your include .h file, such as:

     #define HAL_UART_ISR=TRUE

    Hope this helps

  •  Hi,

    Have you check with a Serial Monitor Sniffer if anything from the Firmware is transmitted over the serial port to a PC? 

    http://www.developer.com/net/cplus/article.php/633421

    http://www.lvr.com/serport.htm

    http://www.serial-port-monitor.com/

    LPRF_Rocks

  •  I am using the same IAR Workbench. I tried the changes you suggested, but it still doesnt work.

    However, i am able to write data out with the RS232 port.

    I am trying to modify the  Zstack example code, does this make it different from what you had ?

  • Yes, I am doing something differenct.  This discussion has been for using the TIMAC, not the Zstack examples.

    If you are trying to get the Zstack SerialApp example to run, then you need to

    double check your version codes.  There isn't much documentation in the pdf doc files for the

    SerialApp example, and I had a difficult time getting it to run properly.  I got the SerialApp example to run after I requested TI

    support.  This is what support sent me:

    Please use the 7.30B version of the compiler. 7.40B is not supported by 1.4.3-1.2.1 version of the stack. Also, you’ll need to configure one of the boards as a coordinator, then one as a router. Both should
    be setup for 38400 baud rate, 8-N-1. You must press SW4 on both devices to bind them. Then you can
    use hyperterm to send characters back and forth.

    You may want to start with a fresh copy of the example program if you've been trying several modifications

    to get it to run.  After a certain amount of time, I seem to forget all the changes I've made to software and

    create more problems going down dead end roads.  Try a new copy of SerialApp and follow the instructions above.

     

    Anything beyond this, I cannot help.  I'm at the same skill level as you, and I got these to run by pure blind luck.

    Maybe another user could assist you if this doesn't work.

    Good luck.

  • Hi Jef,

    I read you comment about the problem you had with the uart.I still have the same problem even I did what is written exactlly

  • Ahmad,

    If you followed the instructions above, then you should check your serial connections.

    Double check your COM port setup for the correct baud, stop, bits, and hand shaking.

    If you are using HyperTerm, be aware that it occasionally locks up, and adds more

    problems.  All I can provide are these general suggestions, unless you have more

    details. 

  • Hi Ahmad, 

    I would start just focus on getting the UART up and running, then your TMAC Sample App and next TIMAC + UART

    Check out the following Design Note just released: 

    New design note: DN112 – Using UART in CC111xFx, CC2431x, and CC251xFx
    This design note explains the basic software use of the UART on CC111xFx, CC243xFx and CC251xFx. The UART is an asynchronous serial interface typically used to communicate data at moderate speed. A common application would use the UART to relay data between the CC111xFx/CC243xFx/CC251xFx RF engine and a PC hyperterminal.

    LPRF_Rocks 

  • Hi,

    I am running the TIMAC's sample application with the led blinking until it associates to a coordinator.

    I added the code for implementing the UART and when i activate HAL_UART=TRUE the led stops blinking and is always switched to on.

    Do you know why this happen? Am I doing something wrong?

     

    The DN112 is very confusing to me, it should work with the HAL layer of the TIMAC, isn't it?

  • T3: What platform are you targeting?

  • I'm testing with the computer with hyperterminal.

    I can send with HalUARTWrite() when I comment HalUARTPoll() from Hal_ProcessPoll() in hal_drivers.c.

    But if I try to receive something the CC2430 does nothing.

    And if I don't comment this function the led stops blinking, I can't send, and the system crashs (the events of keys doesn't work and everything seems stopped).

    Thanks

  • What EVM are you using, or is this your own target board?

    The reason I am asking is to help with the knowing which files of the TI-MAC software base to be looking at as it supports the CC2430DB and CC2430EB platforms.  They may have different hardware connections.

  • Well, i'm using SmartRF04EB, and I'm programming with the workspace CC2430EB using IAR Workbench.

    Is it right?

    Thank you

  • Alright,

    My error was to Open the UART port when pressing the switch, and i should configure it and open it before entering in the osal_start_system().

    Now I can leave HalUARTPoll() without comments, but I still can't send from the PC to the device.

    Something weird is that everytime I send information from device to PC it enters in the CallBack function "MT_UartProcessRxData". I think it only have to enter when I Receive something, not when I send, isn't it?

     

    Thank you for your support

  • Hi..

    I'm using SmartRF04DK..I want to send data to the PC through serial port.

    can you guide me as to how can I start with..The application present in TIMAC has so many stuff I just need to send data from the board to the computer.How can I do that..I'm confused seeing the application  given in the TIMAC.If possible can you just give me an example as to how it can be done step by step.

     

  • Hi..

    I'm trying to send some data to the serial port of the computer through cc2430DB's UART.I modified the example application in the TIMAC stack to write data on to the UART.But I'm not getting any data from the mote..I have set all the parameters like HAL_DMA= FALSE etc.... as metioned in the forum.I'm not able to figure out what is the problem.

    I have added the following code in msa.c file in MSA.HandleKeys function.I have initialized the UART in msa_Main.c and I have included the uart,driver files,

    if ( keys & HAL_KEY_SW_3 )
      {
        HalLedBlink (HAL_LED_ALL, 0, 40, 200);
        uint8 cmd[6] = {157,12,34,45,56,15};
           halUARTCfg_t uartConfig;

          /* UART Configuration */

          uartConfig.configured           = TRUE;

          uartConfig.baudRate             = HAL_UART_BR_38400;

          uartConfig.flowControl          = TRUE;

          uartConfig.flowControlThreshold = 5;

          uartConfig.rx.maxBufSize        = 120;

          uartConfig.tx.maxBufSize        = 120;

          uartConfig.idleTimeout          = 5;

          uartConfig.intEnable            = TRUE;

          uartConfig.callBackFunc         = MT_UartProcessRxData;

          HalUARTOpen (0, &uartConfig);
          HalUARTWrite(0,cmd,6);
      }

    Here if I press switch three all the leds are blinking but I'm not able to see any data written into the serial port.

    Do I need to do something else?I'm using Hyperterm in windowsxp to see if some data has arrived.

    2)I even tried running the serialApp given in the Z-stack,after I program cc2430 nothing happens,I'm just able to see the LEDs blinking,I send some data using the hyperterm but nothing happens.If anyone has implemented the example kindly help as to how to run the application.

     

  • Hi JeF,

    As far as I´ve seen in your post, you´ve succeed by adding serial communication to your app. I´m trying to do the same in my CC2530DK, but it seems to be impossible. I´ve followed all steps you mentioned, but just can send data and not receive. What I want to do is adding serial communication to the TIMAC example in order to configure all parameters related to Beacon-enabled  networking, sending the value of these parameters via COM port from a LabWindowsCVI app that I already programmed.

    Any help would be apreciated.

    Thanks in advance

  • Hi,

    I have to configure UART in CC2530 SoC using TIMAC. I am using the following.

    IAR 7.60.1

    TIMAC 1.3.1

    SMART RF05 1.7.1

    chip: 2530 EM 1.3.1.

    Is this configuration valid? I have configured all the things as told here.  I set UART_DMA = FALSE, UART_ISR = TRUE and HAL_UART = TRUE in preprocessor directive.

    But then an error occurred, saying HAL_UART_PRIPO  not defined, in file HAL_UART_ISR.C. So I defined it there.

    Then in MSA.C the MSA_HALUartopen() and static void MT_UartProcessRxData(uint8 port, uint8 event) are defined. The MSA_HALUartopen() is simply called in

    MSA_INIT(). The HALUartopen() is called afterwards in the MSA.C itself.

    1). is the whole process right?

    2). I am confused about the UART call back event. Is simply writing MT_UARTProcessRxData() in MSA.C enough?

     

     

  • Try to take a look at the SerialApp in Z-Stack and port this the TIMAC MSA framework.

    www.ti.com/z-stack

    The sample application can be found on the following default installation folder:
    C:\Texas Instruments\ZStack-CC2530-2.4.0-1.4.0\Projects\zstack\Utilities\SerialApp

    This examples shows you have to utilize the callback function for the UART and the whole process.

    LPRF Rocks the World

  • Hi, 

    Thanks for your help. Could you please suggest a design note like DN122 to configure UART. That current link to DN112 is not working. I took your advice to see through the Zstack serial application for configuring UART, even though ZStack is little bit confusing. Thanks in advance

    Regards,

    Deepu Cyriac