<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div>I have 3 state machines in my code, initialization, write, and read. The write and read state machines cannot be incremented until the initialization state machine has completed.</div>
<div><br>
</div>
<div>Everything I have done seems to match your data flow, the only difference was I was setting the 0x407x registers for the SDO configuration (the Beckhoff docs said from hardware version 03 so I wanted it to be compatible). I changed my SDO writes to the
8000:xx registers, but this did not change the data not pushing out the port. I am running the EL6021 in half duplex mode so I have tx+ tied to rx+ and tx- tied to tx-. Since I am seeing the issue with the EL6021 and the EL6001, I am just trying to get the
EL6001 working first since I have the other side of the transmission line hooked up to PC.</div>
<div><br>
</div>
<div>My system is setup through a configuration file which is parsed on startup and the system adapts to what was in the contents of the file. I currently have 10 or so Beckhoff cards which are mostly I/O modules. Therefore, the SDO registers are only set on
startup and do not need to have their own state machine in realtime since they can’t really change dynamically. I write all SDO registers before I configure the PDOs / domain.</div>
<div><br>
</div>
<div><br>
</div>
<div>Here’s how I am writing my SDO registers for the EL6001 and EL6021:</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// do all of the write requests....</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// the write value will change with respect to the data set in the configuration file</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #4e9072">//</span></div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// send <span style="text-decoration: underline">
xon</span> <span style="text-decoration: underline">xoff</span> <span style="text-decoration: underline">
tx</span></div>
<div style="margin: 0px; font-size: 9px;">data[0] = ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_xon_xoff_tx</span> ? 1 : 0;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>if</b></span> (<span style="color: #793d93"><b>ecrt_master_sdo_download</b></span>(ecat.<span style="color: #0326cc">master</span>, i, 0x8000, 0x02, data, 1, &abort_code) < 0)</div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span>LOGMSG(</span><span style="color: #0326cc"><i>LOG_WARNING</i></span><span style="color: #000000">) <<
</span>"Failed to upload <span style="text-decoration: underline">xon</span> <span style="text-decoration: underline">
xoff</span> <span style="text-decoration: underline">tx</span> SDO with code "<span style="color: #000000"> << abort_code;</span></div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// check <span style="text-decoration: underline">
xon</span> <span style="text-decoration: underline">xoff</span> <span style="text-decoration: underline">
rx</span></div>
<div style="margin: 0px; font-size: 9px;">data[0] = ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_xon_xoff_rx</span> ? 1 : 0;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>if</b></span> (<span style="color: #793d93"><b>ecrt_master_sdo_download</b></span>(ecat.<span style="color: #0326cc">master</span>, i, 0x8000, 0x03, data, 1, &abort_code) < 0)</div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span>LOGMSG(</span><span style="color: #0326cc"><i>LOG_WARNING</i></span><span style="color: #000000">) <<
</span>"Failed to upload <span style="text-decoration: underline">xon</span> <span style="text-decoration: underline">
xoff</span> <span style="text-decoration: underline">rx</span> SDO with code "<span style="color: #000000"> << abort_code;</span></div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// check the baud rate</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>switch</b></span> (ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_baud_rate</span>){</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span><font color="#931a68">case</font> 2400: data[0] = EL60XX_BAUD_2400;
<span style="color: #931a68"><b>break</b></span>;</div>
<div style="margin: 0px; font-size: 9px;"> <span style="color: #931a68"><b>case</b></span> 4800: data[0] = EL60XX_BAUD_4800;
<span style="color: #931a68"><b>break</b></span>;</div>
<div style="margin: 0px; font-size: 9px;"> <span style="color: #931a68"><b>case</b></span> 9600: data[0] = EL60XX_BAUD_9600;
<span style="color: #931a68"><b>break</b></span>;</div>
<div style="margin: 0px; font-size: 9px;"> <span style="color: #931a68"><b>default</b></span>:</div>
<div style="margin: 0px; font-size: 9px;"> <span style="color: #931a68"><b>case</b></span> 19200: data[0] = EL60XX_BAUD_19200;
<span style="color: #931a68"><b>break</b></span>;</div>
<div style="margin: 0px; font-size: 9px;"> <span style="color: #931a68"><b>case</b></span> 38400: data[0] = EL60XX_BAUD_38400;
<span style="color: #931a68"><b>break</b></span>;</div>
<div style="margin: 0px; font-size: 9px;"> <span style="color: #931a68"><b>case</b></span> 57600: data[0] = EL60XX_BAUD_57600;
<span style="color: #931a68"><b>break</b></span>;</div>
<div style="margin: 0px; font-size: 9px;"> <span style="color: #931a68"><b>case</b></span> 115200: data[0] = EL60XX_BAUD_115200;
<span style="color: #931a68"><b>break</b></span>;</div>
<div style="margin: 0px; font-size: 9px;">}</div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// upload the baud rate</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>if</b></span> (<span style="color: #793d93"><b>ecrt_master_sdo_download</b></span>(ecat.<span style="color: #0326cc">master</span>, i, 0x8000, 0x11, data, 1, &abort_code) < 0)</div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span>LOGMSG(</span><span style="color: #0326cc"><i>LOG_INFO</i></span><span style="color: #000000">) <<
</span>"Failed to upload baud rate with code "<span style="color: #000000"> << abort_code;</span></div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// check the data frame</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>if</b></span> (ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_data_bits</span> == 7 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_stop_bits</span>
== 1 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_parity</span> == 1)</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space:pre"></span>data[0] = EL60XX_DATA_7E1;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>else</b></span>
<span style="color: #931a68"><b>if</b></span> (ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_data_bits</span> == 7 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_stop_bits</span>
== 1 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_parity</span> == 2)</div>
<div style="margin: 0px; font-size: 9px;"> <span class="Apple-tab-span" style="white-space:pre">
</span>data[0] = EL60XX_DATA_7O1;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>else</b></span>
<span style="color: #931a68"><b>if</b></span> (ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_data_bits</span> == 8 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_stop_bits</span>
== 1 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_parity</span> == 0)</div>
<div style="margin: 0px; font-size: 9px;"> data[0] = EL60XX_DATA_8N1;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>else</b></span>
<span style="color: #931a68"><b>if</b></span> (ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_data_bits</span> == 8 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_stop_bits</span>
== 1 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_parity</span> == 1)</div>
<div style="margin: 0px; font-size: 9px;"> data[0] = EL60XX_DATA_8E1;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>else</b></span>
<span style="color: #931a68"><b>if</b></span> (ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_data_bits</span> == 8 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_stop_bits</span>
== 1 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_parity</span> == 2)</div>
<div style="margin: 0px; font-size: 9px;"> data[0] = EL60XX_DATA_8O1;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>else</b></span>
<span style="color: #931a68"><b>if</b></span> (ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_data_bits</span> == 7 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_stop_bits</span>
== 2 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_parity</span> == 2)</div>
<div style="margin: 0px; font-size: 9px;"> data[0] = EL60XX_DATA_7O2;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>else</b></span>
<span style="color: #931a68"><b>if</b></span> (ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_data_bits</span> == 8 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_stop_bits</span>
== 2 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_parity</span> == 0)</div>
<div style="margin: 0px; font-size: 9px;"> data[0] = EL60XX_DATA_8N2;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>else</b></span>
<span style="color: #931a68"><b>if</b></span> (ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_data_bits</span> == 8 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_stop_bits</span>
== 2 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_parity</span> == 1)</div>
<div style="margin: 0px; font-size: 9px;"> data[0] = EL60XX_DATA_8E2;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>else</b></span>
<span style="color: #931a68"><b>if</b></span> (ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_data_bits</span> == 8 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_stop_bits</span>
== 2 && ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_parity</span> == 2)</div>
<div style="margin: 0px; font-size: 9px;"> data[0] = EL60XX_DATA_8O2;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>else</b></span></div>
<div style="margin: 0px; font-size: 9px;"> data[0] = EL60XX_DATA_7E2;</div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// upload the data frame</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>if</b></span> (<span style="color: #793d93"><b>ecrt_master_sdo_download</b></span>(ecat.<span style="color: #0326cc">master</span>, i, 0x8000, 0x15, data, 1, &abort_code) < 0)</div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span>LOGMSG(</span><span style="color: #0326cc"><i>LOG_INFO</i></span><span style="color: #000000">) <<
</span>"Failed to upload data frame with code "<span style="color: #000000"> << abort_code;</span></div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// check send
<span style="text-decoration: underline">fifo</span> data continuous</div>
<div style="margin: 0px; font-size: 9px;">data[0] = ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_send_fifo_continuous</span> ? 1 : 0;</div>
<div style="margin: 0px; font-size: 9px;"><font color="#931a68">if</font> (<span style="color: #793d93"><b>ecrt_master_sdo_download</b></span>(ecat.<span style="color: #0326cc">master</span>, i, 0x8000, 0x04, data, 1, &abort_code) < 0)</div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: #000000"> LOGMSG(</span><span style="color: #0326cc"><i>LOG_INFO</i></span><span style="color: #000000">) <<
</span>"Failed to upload send <span style="text-decoration: underline">fifo</span>
<span style="text-decoration: underline">cont</span>. SDO with code "<span style="color: #000000"> << abort_code;</span></div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// check send transfer rate opt.</div>
<div style="margin: 0px; font-size: 9px;">data[0] = ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL60xx_transfer_rate_opt</span> ? 1 : 0;</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>if</b></span> (<span style="color: #793d93"><b>ecrt_master_sdo_download</b></span>(ecat.<span style="color: #0326cc">master</span>, i, 0x8000, 0x05, data, 1, &abort_code) < 0)</div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span>LOGMSG(</span><span style="color: #0326cc"><i>LOG_INFO</i></span><span style="color: #000000">) <<
</span>"Failed to upload transfer rate opt. SDO with code "<span style="color: #000000"> << abort_code;</span></div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// check the device type</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>if</b></span> (ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">dev_type</span> ==
<span style="color: #0326cc"><i>DEV_EL6021</i></span>){</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>// send
<span style="color: rgb(78, 144, 114); text-decoration: underline;">duplex</span></div>
<div style="margin: 0px; font-size: 9px;"> <span class="Apple-tab-span" style="white-space:pre">
</span>data[0] = ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL6021_duplex</span> ? 1 : 0;</div>
<div style="margin: 0px; font-size: 9px;"> <span class="Apple-tab-span" style="white-space:pre">
</span><span style="color: #931a68"><b>if</b></span> (<span style="color: #793d93"><b>ecrt_master_sdo_download</b></span>(ecat.<span style="color: #0326cc">master</span>, i, 0x8000, 0x06, data, 1, &abort_code) < 0)</div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: #000000">
<span class="Apple-tab-span" style="white-space:pre"></span>LOGMSG(</span><span style="color: #0326cc"><i>LOG_INFO</i></span><span style="color: #000000">) <<
</span>"Failed to upload <span style="text-decoration: underline">duplex</span> type SDO with code "<span style="color: #000000"> << abort_code;</span></div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: #000000">
</span>// check point to point communications</div>
<div style="margin: 0px; font-size: 9px;"> data[0] = ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL6021_point_to_point</span> ? 1 : 0;</div>
<div style="margin: 0px; font-size: 9px;"> <span style="color: #931a68"><b>if</b></span> (<span style="color: #793d93"><b>ecrt_master_sdo_download</b></span>(ecat.<span style="color: #0326cc">master</span>, i, 0x8000, 0x07, data, 1, &abort_code) < 0)</div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: #000000">
<span class="Apple-tab-span" style="white-space:pre"></span>LOGMSG(</span><span style="color: #0326cc"><i>LOG_INFO</i></span><span style="color: #000000">) <<
</span>"Failed to upload point to point SDO with code "<span style="color: #000000"> << abort_code;</span></div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);">}</div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #931a68"><b>else</b></span> {</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>// check send
<span style="color: rgb(78, 144, 114); text-decoration: underline;">rts</span> <span style="color: rgb(78, 144, 114); text-decoration: underline;">
cts</span></div>
<div style="margin: 0px; font-size: 9px;"> data[0] = ecat.<span style="color: #0326cc">device</span>[i].<span style="color: #0326cc">EL6001_rts_cts_enable</span> ? 1 : 0;</div>
<div style="margin: 0px; font-size: 9px;"> <span class="Apple-tab-span" style="white-space:pre">
</span><span style="color: #931a68"><b>if</b></span> (<span style="color: #793d93"><b>ecrt_master_sdo_download</b></span>(ecat.<span style="color: #0326cc">master</span>, i, 0x8000, 0x01, data, 1, &abort_code) < 0)</div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: #000000">
<span class="Apple-tab-span" style="white-space:pre"></span>LOGMSG(</span><span style="color: #0326cc"><i>LOG_INFO</i></span><span style="color: #000000">) <<
</span>"Failed to upload <span style="text-decoration: underline">rts</span> <span style="text-decoration: underline">
cts</span> enable SDO with code "<span style="color: #000000"> << abort_code;</span></div>
<div style="margin: 0px; font-size: 9px;">}</div>
</div>
<div style="margin: 0px; font-size: 9px;"><br>
</div>
<div style="margin: 0px; font-size: 9px;"><br>
</div>
<div style="margin: 0px; font-size: 9px;"><br>
</div>
<div style="margin: 0px; font-size: 9px;"><br>
</div>
<div style="margin: 0px; font-size: 9px;"><br>
</div>
<div style="margin: 0px; font-size: 9px;">
<div style="font-size: 12px; margin: 0px;">Here is my initialization sm which finishes successfully:</div>
<div style="font-size: 12px; margin: 0px;">
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);">// check the state of the initialization</div>
<div style="margin: 0px; font-size: 9px; color: rgb(3, 38, 204);"><span style="color: rgb(147, 26, 104);"><b>if</b></span><span style="color: rgb(0, 0, 0);"> (ecat.</span>device<span style="color: rgb(0, 0, 0);">[device].</span>EL60xx_init_status<span style="color: rgb(0, 0, 0);"> == </span><i>EL6021_Init_Terminal</i><span style="color: rgb(0, 0, 0);">){</span></div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>// read the control register first and set initialization request bit to 1</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span><span style="color: rgb(147, 26, 104);"><b>int</b></span> control_byte = EC_READ_U8(ecat.<span style="color: rgb(3, 38, 204);">domain_pd</span> + ecat.<span style="color: rgb(3, 38, 204);">device</span>[device].<span style="color: rgb(3, 38, 204);">EL60xx_control_offset</span>);</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>control_byte |= EL60XX_CTRL_INIT_REQUEST;</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>EC_WRITE_U8(ecat.<span style="color: rgb(3, 38, 204);">domain_pd</span> + ecat.<span style="color: rgb(3, 38, 204);">device</span>[device].<span style="color: rgb(3, 38, 204);">EL60xx_control_offset</span>,
control_byte);</div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span></span>// wait for verification that the initialization succeed successfully</div>
<div style="margin: 0px; font-size: 9px; color: rgb(3, 38, 204);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span>ecat.</span>device<span style="color: rgb(0, 0, 0);">[device].</span>EL60xx_init_status<span style="color: rgb(0, 0, 0);"> = </span><i>EL6021_Init_Accepted</i><span style="color: rgb(0, 0, 0);">;</span></div>
<div style="margin: 0px; font-size: 9px;">}</div>
<div style="margin: 0px; font-size: 9px; color: rgb(3, 38, 204);"><span style="color: rgb(147, 26, 104);"><b>else</b></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(147, 26, 104);"><b>if</b></span><span style="color: rgb(0, 0, 0);"> (ecat.</span>device<span style="color: rgb(0, 0, 0);">[device].</span>EL60xx_init_status<span style="color: rgb(0, 0, 0);"> == </span><i>EL6021_Init_Accepted</i><span style="color: rgb(0, 0, 0);">){</span></div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>// read the status register to see if the device accepted the request</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>uint16_t status = EC_READ_U16(ecat.<span style="color: rgb(3, 38, 204);">domain_pd</span> + ecat.<span style="color: rgb(3, 38, 204);">device</span>[device].<span style="color: rgb(3, 38, 204);">EL60xx_status_offset</span>);</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span><font color="#931a68">if</font> (status & EL60XX_STAT_INIT_ACCEPTED){</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span></span>// clear the <span style="text-decoration: underline;">init</span> request bit...</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span><span style="color: rgb(147, 26, 104);"><b>int</b></span> control_byte = EC_READ_U8(ecat.<span style="color: rgb(3, 38, 204);">domain_pd</span> + ecat.<span style="color: rgb(3, 38, 204);">device</span>[device].<span style="color: rgb(3, 38, 204);">EL60xx_control_offset</span>);</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>control_byte &= ~EL60XX_CTRL_INIT_REQUEST;</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>EC_WRITE_U8(ecat.<span style="color: rgb(3, 38, 204);">domain_pd</span> + ecat.<span style="color: rgb(3, 38, 204);">device</span>[device].<span style="color: rgb(3, 38, 204);">EL60xx_control_offset</span>,
control_byte);</div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span></span>// wait for the transmission success</div>
<div style="margin: 0px; font-size: 9px; color: rgb(3, 38, 204);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span>ecat.</span>device<span style="color: rgb(0, 0, 0);">[device].</span>EL60xx_init_status<span style="color: rgb(0, 0, 0);"> = </span><i>EL6021_Init_Verified</i><span style="color: rgb(0, 0, 0);">;</span></div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>}</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span><span style="color: rgb(147, 26, 104);"><b>else</b></span> {</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span></span>// waiting for initialization accepted...</div>
<div style="margin: 0px; font-size: 9px; color: rgb(3, 38, 204);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span></span><span style="color: rgb(147, 26, 104);"><b>if</b></span><span style="color: rgb(0, 0, 0);"> (ecat.</span>device<span style="color: rgb(0, 0, 0);">[device].</span>EL60xx_init_print<span style="color: rgb(0, 0, 0);">){</span></div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span>LOGMSG(</span><span style="color: rgb(3, 38, 204);"><i>LOG_INFO</i></span><span style="color: rgb(0, 0, 0);">)
<< </span>"Still waiting for verification of transmission on EL60xx"<span style="color: rgb(0, 0, 0);">;</span></div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>ecat.<span style="color: rgb(3, 38, 204);">device</span>[device].<span style="color: rgb(3, 38, 204);">EL60xx_init_print</span> = <span style="color: rgb(147, 26, 104);"><b>false</b></span>;</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>}</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>}</div>
<div style="margin: 0px; font-size: 9px;">}</div>
<div style="margin: 0px; font-size: 9px; color: rgb(3, 38, 204);"><span style="color: rgb(147, 26, 104);"><b>else</b></span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(147, 26, 104);"><b>if</b></span><span style="color: rgb(0, 0, 0);"> (ecat.</span>device<span style="color: rgb(0, 0, 0);">[device].</span>EL60xx_init_status<span style="color: rgb(0, 0, 0);"> == </span><i>EL6021_Init_Verified</i><span style="color: rgb(0, 0, 0);">)
{</span></div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span></span>// check the status bit and wait for terminal to set the initialization accepted bit
to 0</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span><span style="color: rgb(0, 97, 65);">uint16_t</span> status = EC_READ_U16(ecat.<span style="color: rgb(3, 38, 204);">domain_pd</span> + ecat.<span style="color: rgb(3, 38, 204);">device</span>[device].<span style="color: rgb(3, 38, 204);">EL60xx_status_offset</span>);</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span><span style="color: rgb(147, 26, 104);"><b>if</b></span> (!(status & EL60XX_STAT_INIT_ACCEPTED)){</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span></span>// everything is up and running!</div>
<div style="margin: 0px; font-size: 9px; color: rgb(3, 38, 204);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span>ecat.</span>device<span style="color: rgb(0, 0, 0);">[device].</span>EL60xx_init_status<span style="color: rgb(0, 0, 0);"> = </span><i>EL6021_Terminal_Ready</i><span style="color: rgb(0, 0, 0);">;</span></div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span></span>// notify the user</div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;"></span>LOGMSG(</span><span style="color: rgb(3, 38, 204);"><i>LOG_INFO</i></span><span style="color: rgb(0, 0, 0);">)
<< </span>"EL60xx device read / write terminal ready for data"<span style="color: rgb(0, 0, 0);">;</span></div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space: pre;"></span>}</div>
<div style="margin: 0px; font-size: 9px;">}</div>
</div>
</div>
<div style="margin: 0px; font-size: 9px;"><br>
</div>
<div style="margin: 0px; font-size: 9px;"><br>
</div>
<div style="margin: 0px;">My write state sm to be working correctly as well since when I set the transmit request bit after filling the data bytes, the terminal sets the transmit request accepted bit successfully, I am just not seeing data coming out the port.
This is happening with both the EL6021 and the EL6001. </div>
<div style="margin: 0px;"><br>
</div>
<div style="margin: 0px;">This is how my write sm works right now (I just created a temporary array of 8 bytes and filled it with random data, TEST_SIZE = 8):</div>
<div style="margin: 0px;"><br>
</div>
<div style="margin: 0px;">
<div style="margin: 0px; min-height: 11px;"><font color="#4e9072"><span style="font-size: 9px;">// get the status used for write and write sm</span></font></div>
<div style="margin: 0px; font-size: 9px;"><span style="color: #006141">uint16_t</span> status = EC_READ_U16(ecat.<span style="color: #0326cc">domain_pd</span> + ecat.<span style="color: #0326cc">device</span>[device].<span style="color: #0326cc">EL60xx_status_offset</span>);</div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><span style="color: rgb(78, 144, 114);"><br>
</span></div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><span style="color: rgb(78, 144, 114);">// check the write state</span></div>
<div style="margin: 0px; font-size: 9px; color: rgb(3, 38, 204);"><span style="color: #931a68"><b>if</b></span><span style="color: #000000"> (ecat.</span>device<span style="color: #000000">[device].</span>EL60xx_send_status<span style="color: #000000"> ==
</span><i>EL6021_Send_Idle</i><span style="color: #000000">){</span></div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span></span>// map the data to the output registers</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space:pre"></span><span style="color: #931a68"><b>for</b></span> (<span style="color: #931a68"><b>int</b></span> i=0;i<<span style="color: rgb(78, 144, 114);">TEST_SIZE</span>;i++)</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space:pre"></span>EC_WRITE_U8(ecat.<span style="color: #0326cc">domain_pd</span> + ecat.<span style="color: #0326cc">device</span>[device].<span style="color: #0326cc">EL60xx_out_offset</span>[i],
data[i]);</div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span></span>// set the second byte of the control register to be the size of the output size</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span></span>// mask with 255...</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span></span><span style="color: #006141">uint16_t</span><span style="color: #000000"> control_byte = (</span>TEST_SIZE<span style="color: rgb(0, 0, 0);"> &
255) << 8;<span class="Apple-tab-span" style="white-space:pre"> </span></span>// bit shift over by 8 and mask out the first byte</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space:pre"></span>control_byte |= EL60XX_CTRL_TRANSMIT_REQUEST;</div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span></span>// set the transmit request bit</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space:pre"></span>EC_WRITE_U8(ecat.<span style="color: #0326cc">domain_pd</span> + ecat.<span style="color: #0326cc">device</span>[device].<span style="color: #0326cc">EL60xx_control_offset</span>,
control_byte);</div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span></span>// set next step in the transaction process</div>
<div style="margin: 0px; font-size: 9px; color: rgb(3, 38, 204);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span>ecat.</span>device<span style="color: #000000">[device].</span>EL60xx_send_status<span style="color: #000000">
= </span><i>EL6021_Send_Request</i><span style="color: #000000">;</span></div>
<div style="margin: 0px; font-size: 9px;">}</div>
<div style="margin: 0px; font-size: 9px; color: rgb(3, 38, 204);"><span style="color: #931a68"><b>else</b></span><span style="color: #000000">
</span><span style="color: #931a68"><b>if</b></span><span style="color: #000000"> (ecat.</span>device<span style="color: #000000">[device].</span>EL60xx_send_status<span style="color: #000000"> ==
</span><i>EL6021_Send_Request</i><span style="color: #000000">){</span></div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span></span>// check the status bit for successful transition...</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space:pre"></span><span style="color: #931a68"><b>if</b></span> (status & EL60XX_STAT_TRANSMIT_ACCEPTED){</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span></span>// transmit accepted and bytes sent to transmission FIFO</div>
<div style="margin: 0px; font-size: 9px; color: rgb(57, 51, 255);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span>LOGMSG(</span><span style="color: #0326cc"><i>LOG_INFO</i></span><span style="color: #000000">) <<
</span>"Data transmission from EL6021 success with status "<span style="color: #000000"> << status;</span></div>
<div style="margin: 0px; font-size: 9px; min-height: 11px;"><br>
</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span></span>// set the status back to idle</div>
<div style="margin: 0px; font-size: 9px; color: rgb(3, 38, 204);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span>ecat.</span>device<span style="color: #000000">[device].</span>EL60xx_send_status<span style="color: #000000">
= </span><i>EL6021_Send_Idle</i><span style="color: #000000">;</span></div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space:pre"></span><span style="color: #931a68"><b>else</b></span> {</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre"></span></span>// check for additional errors…</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span class="Apple-tab-span" style="white-space:pre"></span>…</div>
<div style="margin: 0px; font-size: 9px; color: rgb(78, 144, 114);"><span class="Apple-tab-span" style="white-space:pre"></span>…</div>
<div style="margin: 0px; font-size: 9px;"><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
<div style="margin: 0px; font-size: 9px;">}</div>
</div>
<div style="margin: 0px; font-size: 9px;"><br>
</div>
<div style="margin: 0px;">The transmit accepted status bit is set high, so my assumption is that the terminal is receiving the data (my log prints “Data transmission from EL6021 success with status ” every time through). </div>
</body>
</html>