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 N2HET

Hi,

I use NHET2 module for serial communication and I found  a code and ı try that.(code is in this page  "http://e2e.ti.com/support/microcontrollers/hercules/f/312/p/addpost.aspx"  on Mar 26 2013 09:51 AM )

This code work without problem  but if I want to sent many byte, sometimes program wait in here 


void HetUART1PutChar(char Data)
{
  unsigned int Tmp = Data;

  Tmp <<= 1;                                    // Shift in start bit (0)
  Tmp |= 0x00000200;                            // Add stop bit (1)
  while(hetRAM1->Instruction[2].Data != 0); -> waiting
  hetRAM1->Instruction[4].Data = Tmp << 7;  // Load TX buffer
  hetRAM1->Instruction[2].Data =  10 << 7;  // Load bit count
}

And so My program take watch dog reset. Why ? when I remove while loop, program send wrong data. Thank you for helping...

  • Hans,

    Thanks for using our forum.

    Your question has been forwarded to our HET expert.  

    Please note that with the Holidays this week, our answer may be delayed.

  • UART is slow. It takes ms to send the data. Here we use the polling method, so, it will block the CPU to serve the watchdog. What you can do is to use the interrupt method.

    1. define a circular buffer to hold the data to be sent out.

    void HetUART1PutChar(char Data)
    {
      unsigned int Tmp = Data;

      Tmp <<= 1;                                    // Shift in start bit (0)
      Tmp |= 0x00000200;                            // Add stop bit (1)

    2. Disable the interrupt

    3. if(circular buffer == empty) &&(hetRAM1->Instruction[2].Data == 0)
       {
            hetRAM1->Instruction[4].Data = Tmp << 7;  // Load TX buffer
            hetRAM1->Instruction[2].Data =  10 << 7;  // Load bit count

       }

       else{write to the circular buffer}

    4. enable the interrupt

    }

    5. in the ISR (buffer empty interrupt), check the circular buffer. If it is not empty, write the the next data in the circular buffer to the HET RAM.

    Regards,

    Haixiao