AnsweredAssumed Answered

ST7580 USART with Arduino

Question asked by Patrick Ramirez on Feb 1, 2013
Latest reply on Apr 29, 2015 by keles.tolga

I'm having a problem interfacing my ST7580 using Arduino Mega USART. And I think I already broke 2 pcs of IC and I cannot afford to lose some more.

Please help me code to PING, Read/Write MIB and send even simple PHY data over the powerline.

The Arduino code I used is here....
/* Arduino Code – ST7580 Transceiver Board

Code Consideration: 
Not sure if syntax and arguments in User Manual work with all types of microcontroller. Just to be sure, per byte transmission will be used. 
For fields with >1 byte, endianness is assumed to start with byte index 0, which is the logical thing to do.

Code Author: Patth Rick L. Ramirez, BS ECE 2008-11684

//GPIO Pin Assignments
#define  aT_REQ  2
#define  aBR0    3
#define  aBR1    4
#define  aPL_TX_ON  22
#define  aPL_RX_ON  24
#define  aPLC_RESETN  26

//Local UART/Serial Pin Assignments
#define  uC_TX  14     //RxD of ST7580 ; USART TX3     
#define  uC_RX  15     //TxD of ST7580 ; USART RX3
//Analog Pin Assignments
//#define      aCL_ADC     12       //hardware available but may not be necessary
//#define      aPA_ADC     13

/*Initialize variables*/
     int avail = 0;
        byte inBUF = 0x00;     //general purpose byte storage

     word inSTAT = 0x0000;     //status message 2 bytes, index 0 should always be 3Fh          

     byte inSTX = 0x00;
     byte inLEN = 0x00;     // byte length of data field
     byte inCC= 0x00;
     byte inCSUM_LSB = 0x00;          //checksum field is sent LSByte first
     byte inCSUM_MSB = 0x00;          
     byte inDATA_0 = 0x00;          
     byte inDATA_1 = 0x00;
     byte inDATA_2 = 0x00;
     byte inDATA_3 = 0x00;
     byte inDATA_4 = 0x00;
     byte inDATA_5 = 0x00;
     byte inDATA_6 = 0x00;
     byte inDATA_7 = 0x00;
     byte inDATA_8 = 0x00;
     byte inDATA_9 = 0x00;
     byte inDATA_10 = 0x00;
     byte inDATA_11 = 0x00;
     byte inDATA_12 = 0x00;
     byte inDATA_13 = 0x00;
     byte inDATA_14 = 0x00;          //max number of data bytes as set by user == 16
     byte inDATA_15 = 0x00;

void GPIO_Init(void){
/*Initial Values*/
     digitalWrite(aBR0,LOW);          //set ST7580’s UART Baud rate to 9600
     digitalWrite(aT_REQ,HIGH);     //set to LOW if requesting transmission to ST7580
} //GPIO_Init();

void send_START(byte outSTX, byte outLEN, byte outCC){
        Serial.println("STX field is sent.");
        digitalWrite(aT_REQ, HIGH);     //bring back to default HIGH as soon as STX byte is received by ST7580
        Serial3.write(outLEN);          //byte length of data field
}//e.g. send_START(0x02, 0x05, 0x2C); 

void send_PING_DATA(byte PDATA){
     Serial.println("Pinging the ST7580 device...");
     Serial3.write(PDATA);          //make it a 3-byte data ping     
}//e.g. send_PING_DATA(0xAA);             //CC for PingRequest is 2Ch

void send_CSUM(byte outCSUM_LSB, byte outCSUM_MSB){
     Serial3.write(outCSUM_LSB);     //checksum is sent LSB first
        Serial.println("Checksum bytes sent.");

void setup(){
     /*Initialize GPIO ports*/
     /*Set-up serial port 0 at 9600 bps – for printing data to the serial monitor*/
     /*Initialize Serial Port 3 at 9600 bps, 8 data bits, 1 stop bit*/
         Serial.println("Trying to PING ST7580 in");

void loop(){
  while (Serial3.available() > 0){
      inBUF =;
      Serial.println("Flushing FIRST.");
  }  //flush unnecessary receive buffer bytes
  digitalWrite(aT_REQ, LOW);
  Serial.println("Requesting transmission to ST7580.");
  inBUF =;
  inSTAT = inBUF;
  inBUF =;
  inSTAT = inSTAT | (inBUF<<8);
  if (inSTAT == 0x093F)
    Serial.println("ST7580 is available.");
    Serial.println("ST7580 is busy.");
  } while (inSTAT != 0x093F);
  delay(30);                  //IMPT Why?
  send_START(0x02,0x06,0x2C);  //PING Request
  //inBUF =; // has stray FEh?

  while (Serial3.available() > 0){
    inBUF =;
    if ((inBUF==0x06) || (inBUF==0x15))
      Serial.println("Acknowledgement message received.");
      Serial.println("Received what byte?");


Thank you very much to those who can help me. I hope you guys can I really need help. T_T