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.

Help C Programming F28069 Power Line Communication

Other Parts Discussed in Thread: TMS320F28069, AFE031

Hi everyone,

I'm new in the world of PLC systems.

However, I have read some documents on it and now for my thesis work I'm going to develop and test a project on power line.

I know the existence of the development kit TMDSPLCKIT-V3 (actually my university have this) and maybe is useful for a first understand but for my purpose (and my professor request) I have to use separately the components (TMS320F28069, analog front end AFE031 etc..) and then merge togheter.

I also know the existence of the Zero Configuration GUI (TI) and I used it but as you can understand I need more "freedom" so I  found the entire project on CodeComposerStudio that I have attached in this thread.

This is an complete project in C who its goal is to "blink LED". Now my idea is to modify this project to send for example a proper signal (transmitter) and recover it at the receiver.

Becouse I'm not skilled in programming, I'd like if someone can help me to understand in a better way how does this project work and where lay a hand on.

Thanks for your support,

Best,

Andrea g3.zip

  • Hi Andrea,

    The project will send one packet and wait for one receive packet and then transmit another packet and so on. LED on DSP control card will blink if packet transmission and reception is ongoing.

    The packet is of size of 73 bytes with a repeating ramp data pattern using the following:
    - Tonemask: Enabled
    - PPDU payload length: 73 bytes

    Could you please elaborate on what do you mean by sending proper signal?
    TMS320F28069 plc solution supports frequency band 35kHz - 90kHz.

    Thanks,
    Katta
  • Hi Katta,

    Thanks for the support.
    The aim now is to understand in a more detailed way how does the program work, even in terms of DSP/BIOS so that I can modify the program to my purpose.

    For example, initially, I'd like to separate in two this program where there is one TMDSPLCKIT-V3 that ONLY transmit and the second TMDSPLCKIT-V3 that ONLY receive (for example blink led each time it receive a paket).

    I have tried to modify the code by removing all the stuff regarding TX from one side and RX in the other side and adding a for loop in the TX main.c in this line:

               PHY_txPreparePpdu(&PHY_tx_ppdu_s, cb_tx);
               PHY_txSmRun(0);
               PHY_txPpdu(&PHY_tx_ppdu_s, cb_tx)

    ..but obviously doesn't work.

    Can you help me or provide more information?

    Thanks,

    Best regards,

    Andrea

  • Hi Andrea,

    The Tx functionality waits for an Rx packet to transmit again the same packet. It is already a loop.
    You might have noticed it from the code. I suggest don't change the code to act just as Tx or Rx.
    It would create a problem in the synchronization. Instead try changing the test data which is sent.

    When you have used the for loop, did you notice the first packet receive on the other end?

    For more information refer phy_api document.

    Thanks,
    Katta
  • Hi Katta,

    Thanks for your suggestions. I have read the phy_api document and I have some doubt:

    1) Syntax: PHY_txSmRun(UINT16 mode) : This API runs PHY Tx process during active packet transmission. It is to be called at G3
    PHY symbol rate (per DMA interrupt, for symbol processing) and once TX bit processing needs to start (for bit processing).

    ----What does it means "bit"  and "symbols" processing? When and why it is called this function? Is regarding BIOS too?

    ps: this function is present also at the RX side --> PHY_rxSmRun.

     

    2) Syntax PHY_txGetStat(PHY_tx_stat_t *getData_p): This API reads PHY TX path statistics.

    ---Is that function useful to get statistics on packet sent, packet rate, errors, frequency etc? If yes, how can I implement and see these stastics?

    ps: this function is present also at the RX side -->PHY_rxGetStat.

     

    3) PHY_txPpduStartCbReg(PHY_tx_mbx_post);
    This API is not present in the PHY_API.PDF, can you explain briefly its goal? What is the purpose of the MBX? I see that is related to another function that call first PHY_txSmRun(0) and then PHY_txSmRun(1). 

     


    I hope for your support,

    Thanks,


    Best,

    Andrea

  • Hi Andrea,

    Please find the response in the same order.

    1. Please refer to "G3 PLC Physical layer specification" for details regarding symbols, tx and rx flow.
    PHY_txSmRun is used to create the preamble(symbols), do the bit processing (encoding, interleaver etc.) and convert the packet to OFDM symbols.

    2. Yes you can use PHY_txGetStat to get 'number of phy tx packets'.
    PHY_rxGetStat to get 'crc errors', 'rx dropped packets', 'number of received packets' etc.
    Try calling these function for every transfer and receive of the packets. Attach UART interface to read out stats over UART. (or) Read the stats values through CCS(watch window), setting a breakpoint.

    3. PHY_txPpduStartCbReg is used here to set the call back function which will be called for preamble generation or tx bit processing.

    'PHY_tx_mbx_post' is used to signal 'MBX_pend' which is waiting. Based on what is set for 'phyTxMsg.stage' when the call back function is called, PHY_txSmRun(0) or PHY_txSmRun(1) is executed.

    Hope this solves your problem.

    Thanks,
    Katta
  • Hi Katta,

    Thanks for the support.

    1). I have read the "G3 PLC Physical layer specification" but I found it hard to understand the correspondence between "Symbol processing" and "Bit processing".

    In a few words, PHY_txSmRun is used each time it is sent a packet, right?

    That is, PHY_txSmRun(1) - related to "symbol processing" - is used first to generate the preamble and FCH, and then PHY_txSmRun(0) for "bit processing" .

    In our case, because we use these two function:

    -PHY_txPreparePpdu

    -PHY_txPpdu

    PHY_txSmRun (again, first 0 and then 1, related to symbol processing and bit processing) must be called for each these function?

    2). SOLVED. THANKS.

    3). I infer that this point is closely related to the point 1. (that is again a little doubtful)..

    I attach the PHY_tx_thread.c file.

    At the line 94 there is this function:


    void PHY_tx_swi_proc(void)
    {
      // call PHY library API for symbol processing state machine
      PHY_txSmRun(2);  ------------>> what does it mean the "2" inside this function? From the API_PHY it seems that it can only have the "0" or "1" value.
      swiCnt++;
    }

    Thanks again for your support,

    Best,

    Andrea

    /*****************************************************************************
    * FILE PURPOSE: This file implements PTXM Thread Functions
    *******************************************************************************
    *
    * FILE NAME: PHY_tx_thread.c
    *
    * DESCRIPTION:
    *       This file contains functions used for PHY TX OS thread related functions.
    *       Note: This file is not included in the PHY library. User is expected 
    *             to provide OS hooks.
    *
    *  Copyright (c) 2009 Texas Instruments Inc.
    *  All Rights Reserved This program is the confidential and proprietary
    *  product of Texas Instruments Inc.  Any Unauthorized use, reproduction or
    *  transfer of this program is strictly prohibited.
    *
    * HISTORY:
    *
    * 03/10/2009 fum    Written
    *
    * LIST OF FUNCTIONS:
    *
    *
    ******************************************************************************/
    #include <phy_tx.h>
    #include <phy_tx_swi.h>
    #include <hal_afe.h>
    #ifdef F2806X
      #include <test_tx_rx_f2806xcfg.h>
    #elif defined (F28M35X)
      #include <test_tx_rx_f28m35xcfg.h>
    #else
      #include <test_tx_rxcfg.h>
    #endif
    
    //void PHY_tx_sema_post();
    //void PHY_tx_sema_reg(PHY_tx_sema_post_func_t func_p);
    /******************************************************************************
    * FUNCTION NAME: PHY_tx_thread
    *
    * DESCRIPTION:   PHY TX thread for bit processing. Lower priority.
    *
    * Return Value:  None
    *
    * Input Parameters:
    *
    * Output Parameters:
    * Functions Called:
    *
    ******************************************************************************/
    void PHY_tx_thread()
    {  
      PHY_txMsg_t phyTxMsg;
      // may have problem
      PHY_txPpduStartCbReg(PHY_tx_mbx_post);
    
      while(1)
      { 
        MBX_pend(&PHY_TX_QUE, &phyTxMsg, SYS_FOREVER);
        
        if (phyTxMsg.stage == 0)
        {
          // generate preamble
          PHY_txSmRun(0);
        }
        else if (phyTxMsg.stage == 1)
        {
          // call PHY library API for bit processing
    #ifndef P1901_2_FCC
          // F28069 FCC band: process the bit level in txPpdu for MIPS savings
          if (PHY_handle_s.band < PHY_MODE_FCC)
    #endif
             PHY_txSmRun(1);
        }
      }
    }
    /******************************************************************************
    * FUNCTION NAME: PHY_tx_swi_proc
    *
    * DESCRIPTION:   PHY TX SWI for symbol processing state machine. High priority.
    *
    * Return Value:  None
    *
    * Input Parameters:
    *
    * Output Parameters:
    * Functions Called:
    *
    ******************************************************************************/
    Uint32 swiCnt=0;
    void PHY_tx_swi_proc(void)
    {
      // call PHY library API for symbol processing state machine
      PHY_txSmRun(2);
      swiCnt++;
    }
    
    /******************************************************************************
    * FUNCTION NAME: PHY_tx_dma_bios_isr
    *
    * DESCRIPTION:   PHY TX DMA interrupt service routine (ISR).
    *                This ISR posts PHY_TX_SWI for symbol processing.
    *
    * Return Value:  None
    *
    * Input Parameters:
    *
    * Output Parameters:
    * Functions Called:
    *
    ******************************************************************************/
    void PHY_tx_dma_bios_isr(void)
    {
    
      // call HAL library API
      HAL_afeTxDmaCh2IntFunc();
    
      // post SWI
      SWI_post(&PHY_TX_SWI);        
    }
    
    /******************************************************************************
    * FUNCTION NAME: PHY_tx_sema_post
    *
    * DESCRIPTION:   PHY TX semaphore post.
    *
    * Return Value:  None
    *
    * Input Parameters:
    *
    * Output Parameters:
    * Functions Called:
    *
    ******************************************************************************/
    void PHY_tx_mbx_post(PHY_ev_t eventID, PHY_cbData_t *cbData_p)
    {  
      PHY_txMsg_t phyTxMsg;
      
      phyTxMsg.stage = cbData_p->cbParms.txStage.stage;
    
      MBX_post(&PHY_TX_QUE, &phyTxMsg, 0);
    }
    
    void sys_init_phy_tx()
    {
      /* Initialize PHY TX and HAL TX HW */
      PHY_txInit();
    }
    
    

  • Hi Andrea,

    Please find my responses in the same order.
    1. PHY_txSmRun is used each time it is sent a packet, right? Yes.
    PHY_txSmRun has to be called only at the start of first transmission as mentioned in the example. Rest of the time, call back function takes care of it.

    PHY_txSmRun(0) is for preamble generation. [create the preamble(symbols)]
    PHY_txSmRun(1) is for bit processing.[ do the bit processing (encoding, interleaver etc.) ]
    PHY_txSmRun(2) is for symbol processing.[convert the packet to OFDM symbols.]

    2. PHY_txSmRun(2) is for symbol processing. It is triggered via an internal mechanism which you may not worry as it is taken care in phy example.

    Thanks,
    Katta
  • Hi Katta,

    Thanks again for the support.

    Now seems more clear the concept of PHY_txSmRun(0),PHY_txSmRun(1),PHY_txSmRun(2). 

    Instead, I've again some trouble on PHY_txPpduStartCbReg(PHY_tx_mbx_post). It is also present in the main.c and even if I tried to remove it, the program work well. It is due to the fact that this function is called inside the BIOS that is performed after the main.c ?

    Hope for a support,

    Best,

    Andrea

  • Hi Andrea,

    You might have noticed 'PHY_txPpduStartCbReg(PHY_tx_mbx_post)' is also called in PHY_tx_thread().
    So, it is working. Try removing it from PHY_tx_thread() and observe the behaviour.

    I hope you have a fare idea how threads and semaphores work.

    Thanks,
    Katta
  • Hi Katta,

    Thanks for the support and above all for your patience!

    Shortly I will try to remove the PHY_txPpduStartCbReg(PHY_tx_mbx_post) on the PHY_tx_thread() and see what happens.

    -----I hope you have a fare idea how threads and semaphores work.-----

    Meanwhile, I post here the link about the thread made by me yesterday on this stuff and if you want me to do some clarification I will be grateful.

    Thanks for the support,

    Best regards,

    Andrea

  • Hi Andrea,

    I have replied with related workshop article link. Please refer to them.
    Do you see the phy tx and rx packet exchange now?
    If you do not see, try to run it without making any changes to the example project.

    Thanks,
    Katta
  • Hi Katta,

    thanks for the support.

    Summarizing, considering only the transmission side, once a packet is sent when occur PHY_txPpdu function, the hardware interrupt comes in, I'm right?

    It call this function:

    void PHY_tx_dma_bios_isr(void)
    {

      // call HAL library API
      HAL_afeTxDmaCh2IntFunc();

      // post SWI
      SWI_post(&PHY_TX_SWI);        
    }


    That in turn call the SWI:

    void PHY_tx_swi_proc(void)
    {
      // call PHY library API for symbol processing state machine
      PHY_txSmRun(2);
      swiCnt++;
    }


    Now my question is: Why it is performed first PHY_txSmRun(2) instead of It would not be logical to call first PHY_txSmRun(0)-(1) and then convert the packet to OFDM symbols PHY_txSmRun(2) ?

    Thanks for your support,

    Best,

    Andrea