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.

[参考译文] UCD3138:Custimzied PMBus GUI

Guru**** 1617045 points
Other Parts Discussed in Thread: UCD3138, UCD9240, UCD90120, UCD7231, TPS40400
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/power-management-group/power-management/f/power-management-forum/1060088/ucd3138-custimzied-pmbus-gui

器件型号:UCD3138
主题中讨论的其他器件: UCD9240UCD90120UCD7231TPS40400

尊敬的 Amiel:

在您 的帮助下、我可以拥有一个 PMBus 客户 GUI、该 GUI 能够与 UCD3138器件通信。

但一个问题是、闪存模式下的扫描器件将需要 很长时间、您能不能帮助我了解如何使其像在器件 GUI 中那样更快?  

下面的代码是 FUSION API 示例中的参考代码、扫描所有地址大约需要10秒。

var sb =新 StringBuilder ();
//对于 Fusion Digital Power Designer 支持的大多数器件使用此样式
//示例:UCD9240、UCD90120、UCD7231
int num_devices = PMBusDevice.Discover ();

//另一种调用方法--只扫描列出的地址;非常快
// int num_devices = PMBusDevice.Discover (75、126);

//对不支持 device_ID 的选定设备使用此样式
//示例:TPS40400、TPS4100
// int num_devices = PMBusUtils.attach_and_Discover (PartID.TPS40400、true);


sb.append ("找到"+ num_device.ToString ()+"总线上的器件...");
log1 (sb.ToString());

谢谢、

插孔

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Jack:

    如果您知道要使用的地址、则可以像下面的行那样直接使用该地址。

    [引用 userid="290257" URL"~/support/power-management-group/power-management/f/power-management-forum 1060088/ucd3138-custimized-PMBus-GUI"] int num_devices = PMBusDevice.Discover (75、126

    您可能在 Visual Studio 中启用了一些条件断点。  这可以解释缓慢行为。  您能否确认您正在运行代码而没有任何断点?  对于适配器、您的运行频率是否为100 kHz 或400 kHz?  这些可能是需要考虑的问题。  如果您仍有困难、请告诉我专门需要时间的代码块、我将尝试复制。  我看不到一个明显的理由,为什么要花这么多时间。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Amiel:

    这是我的 C#代码、在我的 Visual Studio 中没有硬件断点。

    实际上、我将此代码(https://www.ti.com/lit/zip/slvc460)作为参考、它看起来与我具有相同的结果。

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    using TIDP.PMBus;
    
    using TIDP.SAA;
    using TIDP;
    using TIDP.PMBus.Parts.UCD92XX;
    using TIDP.PMBus.Parts.UCD3000;
    using System.Runtime.CompilerServices;
    using System.Threading;
    using System.Runtime.Serialization;
    
    namespace PMBUS_BOOT
    {
        public partial class Form1 : Form
        {
            public static UInt32 pageSize = 0;
            public static UInt32 oldAddress;
            public static UInt32 newAddress;
            public static UInt32 startAddress;
            public static UInt32 endAddress;
            public static UInt16 byteSize = 8; /* defaults are 8 bits */
            public static UInt16[] PFLASH_DATA = new UInt16[0x1000000];
    
            public byte pmbus_addr = 88;
            private TIBusAdapters Adapters = new TIBusAdapters();
    
            public Form1()
            {
                InitializeComponent();
    
                //Wire SAA events that tell us of interesting changes
                Adapters.RequestComplete += new TIBusAdapters.RequestCompleteEventHandler(Adapters_RequestComplete);
                Adapters.Warning += new TIBusAdapters.WarningEventHandler(Adapters_Warning);
                Adapters.ControlLineUpdated += new TIBusAdapters.ControlLineUpdatedEventHandler(Adapters_ControlLineUpdated);
                Adapters.SMBusAlertLineUpdated += new TIBusAdapters.SMBusAlertLineUpdatedEventHandler(Adapters_SMBusAlertLineUpdated);
                Adapters.USBDetached += new TIBusAdapters.USBDetachedEventHandler(Adapters_USBDetached);
                Adapters.USBReattached += new TIBusAdapters.USBReattachedEventHandler(Adapters_USBReattached);
    
                devicDetermination();
            }
    
            // PUBLIC METHODS //////////////////////////////////////////////
    
            // EVENTS I HANDLE /////////////////////////////////////////////
    
            // We do one-time SAA discovery here; you might do this somewhere else
            // in your app (the Fusion GUI has a custom splash screen form shared
            // by all Fusion apps which allows for retry/etc).
            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
                // This ensures that all SMBusAdapter events get fired on main thread,
                // making for much simpler development
                SMBusAdapter.Run_Events_On_UI_Thread(SynchronizationContext.Current);
                while (true)
                {
                    //find at least one USB adapter
                    if (Adapters.Discover() == 0)
                    {
                        var result = MessageBox.Show("No USB Adapter found. Please check your connection.", "No USB Adapter Found", MessageBoxButtons.RetryCancel);
                        if (result == DialogResult.Cancel)
                        {
                            Close();
                            return;
                        }
                    }
                    else
                    {
                        Log1("Found " + Adapters.Num_Adapters + "USB adapter(s)");
                        break;
                    }
                }
            }
            private void Adapters_USBReattached(TIBusAdapters.USBReattachedEventArgs e)
            {
                Log2("USBReattached: Adapter_Number" + e.Adapter_Number + "; Message=" + e.Message);
            }
    
            private void Adapters_USBDetached(TIBusAdapters.USBDetachedEventArgs e)
            {
                Log2("USBDetached: Adapter_Number" + e.Adapter_Number + "; Message=" + e.Message);
            }
    
            private void Adapters_SMBusAlertLineUpdated(TIBusAdapters.SMBusAlertLineUpdatedEventArgs e)
            {
                Log2("SMBusAlertLineUpdated: Adapter_Number=" + e.Adapter_Number + "; Message=" + e.Message);
            }
    
            private void Adapters_ControlLineUpdated(TIBusAdapters.ControlLineUpdatedEventArgs e)
            {
                Log2("ControlLineUpdated: Adapter_Number=" + e.Adapter_Number + "; Message=" + e.Message);
            }
    
            private void Adapters_Warning(TIBusAdapters.WarningEventArgs e)
            {
                Log2("Warning: Adapter_Number=" + e.Adapter_Number + ": Message=" + e.Message);
            }
    
            private void Adapters_RequestComplete(TIBusAdapters.RequestCompleteEventArgs e)
            {
                Log2("RequestComplete: Adapter_Number=" + e.Adapter_Number + "; Message=" + e.Message + "; Is_Success=" + e.Is_Success);
            }
    
            private void Log1(string msg)
            {
                logCtrlInfo.Add(msg);
            }
    
            private void Log2(string msg)
            {
                logCtrlInfo.Add(msg);
            }
    
            public void devicDetermination()
            {
                try
                {
                    Int32 BootSize = Convert.ToInt32(cBoxBootSize.Text);
    
                    if ((comboBoxDevice.Text == "F280049") || (comboBoxDevice.Text == "F280048") || (comboBoxDevice.Text == "F280045"))
                    {
                        rBtnFlashBank1.Visible = true;
                        rBtnFlashBank2.Visible = true;
                        rBtnBoth.Visible = true;
    
                        if (rBtnFlashBank1.Checked == true)
                        {
                            startAddress = 0x80000;
                            endAddress = 0x8FFFF;
                        }
                        else if (rBtnFlashBank2.Checked == true)
                        {
                            startAddress = 0x90000;
                            endAddress = 0x9FFFF;
                        }
                        else if (rBtnBoth.Checked == true)
                        {
                            startAddress = 0x80000;
                            endAddress = 0x9FFFF;
                        }
                        else
                        {
                            startAddress = 0x80000;
                            endAddress = 0x8FFFF;
                        }
    
                        pageSize = 16;
                        byteSize = 16;
                    }
                    else if ((comboBoxDevice.Text == "F280041") || (comboBoxDevice.Text == "F280040"))
                    {
                        rBtnFlashBank1.Visible = false;
                        rBtnFlashBank2.Visible = false;
                        rBtnBoth.Visible = false;
                        startAddress = 0x80000;
                        endAddress = 0x8FFFF;
    
                        pageSize = 16;
                        byteSize = 16;
                    }
                    else if (comboBoxDevice.Text == "F280025")
                    {
                        rBtnFlashBank1.Visible = false;
                        rBtnFlashBank2.Visible = false;
                        rBtnBoth.Visible = false;
                        startAddress = 0x80000;
                        endAddress = 0x8EFFF;
    
                        pageSize = 16;
                        byteSize = 16;
                    }
                    else if (comboBoxDevice.Text == "F280023")
                    {
                        rBtnFlashBank1.Visible = false;
                        rBtnFlashBank2.Visible = false;
                        rBtnBoth.Visible = false;
                        startAddress = 0x80000;
                        endAddress = 0x87FFF;
    
                        pageSize = 16;
                        byteSize = 16;
                    }
                    else if ((comboBoxDevice.Text == "F280021") || (comboBoxDevice.Text == "F280020"))
                    {
                        rBtnFlashBank1.Visible = false;
                        rBtnFlashBank2.Visible = false;
                        rBtnBoth.Visible = false;
                        startAddress = 0x80000;
                        endAddress = 0x83FFF;
    
                        pageSize = 16;
                        byteSize = 16;
                    }
                    else if ((comboBoxDevice.Text == "F28023") || (comboBoxDevice.Text == "F28027"))
                    {
                        rBtnFlashBank1.Visible = false;
                        rBtnFlashBank2.Visible = false;
                        rBtnBoth.Visible = false;
                        startAddress = 0x3F0000;
                        endAddress = 0x3F7FFF;
                        byteSize = 16;
                    }
                    else if (comboBoxDevice.Text == "UCD3138")
                    {
                        rBtnFlashBank1.Visible = false;
                        rBtnFlashBank2.Visible = false;
                        rBtnBoth.Visible = false;
                        startAddress = 0x0000;
                        endAddress = 0x7FFF;
                        byteSize = 8;
                    }
                    else if (comboBoxDevice.Text == "UCD3138064")
                    {
                        rBtnFlashBank1.Visible = true;
                        rBtnFlashBank2.Visible = true;
                        rBtnBoth.Visible = true;
    
                        if (rBtnFlashBank1.Checked == true)
                        {
                            startAddress = 0x0000;
                            endAddress = 0x7FFF;
                        }
                        else if (rBtnFlashBank2.Checked == true)
                        {
                            startAddress = 0x9000;
                            endAddress = 0xFFFF;
                        }
                        else if (rBtnBoth.Checked == true)
                        {
                            startAddress = 0x0000;
                            endAddress = 0xFFFF;
                        }
                        else
                        {
                            startAddress = 0x80000;
                            endAddress = 0x8FFFF;
                        }
                        byteSize = 8;
                    }
                    else if ((comboBoxDevice.Text == "F28034")||(comboBoxDevice.Text == "F28035"))
                    {
                        rBtnFlashBank1.Visible = false;
                        rBtnFlashBank2.Visible = false;
                        rBtnBoth.Visible = false;
                        startAddress = 0x3E8000;
                        endAddress = 0x3F7F7F;
                        byteSize = 16;
                    }
    
                    startAddress += (UInt32)BootSize * 1024;
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
    
            }
            public void FilledPflashBuff()
            {
                for (UInt32 n = 0; n < PFLASH_DATA.Length; n++)
                {
                    PFLASH_DATA[n] = 0xFFFF;
                }
            }
    
            private void bTbrowse_Click(object sender, EventArgs e)
            {
                try
                {
                    OFDImage.InitialDirectory = System.Environment.CurrentDirectory;
                    OFDImage.Title = "Select firmware files";
    
                    OFDImage.CheckFileExists = true;
                    OFDImage.CheckPathExists = true;
    
                    OFDImage.DefaultExt = "txt";
                    OFDImage.Filter = "Hex files (*.hex)|*.hex|TekHex Files (*.x0)|*.x0|All Files (*.*)|*.*";
                    OFDImage.RestoreDirectory = true;
    
                    OFDImage.ReadOnlyChecked = true;
                    OFDImage.ShowReadOnly = true;
    
                    if (OFDImage.ShowDialog() == DialogResult.OK)
                    {
                        textBoxFilePath.Text = OFDImage.FileName;
    
                        devicDetermination();
    
                        FilledPflashBuff();
    
    
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
    
            private void bTclear_Click(object sender, EventArgs e)
            {
                logCtrlInfo.Clear();
            }
    
            private void llbRomID_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                int AdaperNum = Adapters.Num_Adapters;
    
                var sb = new StringBuilder();
                byte addr = 11;
                byte cmd = 0xEC;
                sb.Append("SAA:BlockRead (Address: "+ addr +"d, Cmd 0x" + cmd.ToString("X2") + "): ");
                var block_result = Adapters.Read_Block(AdaperNum, addr, cmd);
                if (block_result.Success)
                {
                    sb.Append("ACK ");
                    sb.Append(block_result.Block.Hex);
                }
                else
                {
                    sb.Append("NACK ");
                    sb.Append(block_result.ToString());
                }
                Log1(sb.ToString());
            }
    
            private void llbFlashID_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                var sb = new StringBuilder();
                // Use this style for most devices supported by Fusion Digital Power Designer
                // Examples: UCD9240, UCD90120, UCD7231
                int num_devices = PMBusDevice.Discover();
    
                // Another way to call -- only scan the addresses listed; very fast
                // int num_devices = PMBusDevice.Discover(75, 126);
    
                // Use this style for select devices that do not support DEVICE_ID
                // Examples: TPS40400, TPS4100
                // int num_devices = PMBusUtils.Attach_And_Discover(PartID.TPS40400, true);
    
     
                sb.Append("Found " + num_devices.ToString() + " device on bus...");
                Log1(sb.ToString());
    
    #if false
                for (byte addr = 1; addr <= 127; ++addr)
                {
                    if ((addr == 11)||(addr == 12)) { continue; }   //Skip PMBus alert response address
                    var sb = new StringBuilder();
                    sb.Append(addr + ":");
                    var block_result = Adapters.Read_Block(1, addr, 0xFD);
                    if (block_result.Success)
                    {
                        sb.Append(block_result.Block.Hex);
                    }
                    else
                    {
                        sb.Append(block_result.ToString());
                    }
                    Log1(sb.ToString());
                }
    #endif
            }
            private void comboBoxDevice_TextChanged(object sender, EventArgs e)
            {
                devicDetermination();
            }
    
            private void btCopyAll_Click(object sender, EventArgs e)
            {
                //Clipboard.SetText();
                logCtrlInfo.CopyAllToClipboard();
            }
    
            private void btCopySelected_Click(object sender, EventArgs e)
            {
                logCtrlInfo.CopySelectToClipboard();
            }
        }
    }
    

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Jack:

    我将尝试在周五返回给您。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Jack:

    我认为调试一大块代码很困难。  我强烈建议您只使用控制台应用程序、如自定义 GUI 的第一个主题中所述。  那么、您遇到困难的程序中的这些特定行比整个程序更容易与我共享和调试。  

    拥有 UI 后、现在需要管理前端和后端进程。  用户界面上的日志记录可能会导致一切运行缓慢。  另外、关于速度、请确保 SMBusAdapter 以400kHz 的频率运行、因为这也可能是一个问题

    SMBusAdapter.Adapter.Set_Bus_Speed (SMBusAdapter.BusSpeed.Speed400KHz);

    您可以使用控制台应用程序来开发程序、然后在最后、您可以考虑添加 UI。  通过这种方式、我可以更直接地提供 Fusion API 支持、因为调试具有前端的 API 会涉及很多。

    我还添加了一份基本的 Fusion API 用户指南、其中介绍了一些制作简单程序的方法。  供参考当指向程序集时、您可以直接在最新 Fusion Studio 安装程序的 bin 文件夹中指向这些程序集。  您需要将.Net framework 设置为4.5而不是4.0。   

    ------------------------------

    话虽如此、当前 GUI 确实支持 PFLASH 的部分闪存下载。  如果您查看引导选项、您可以只下载引导或高于引导。  因此、这样它只会选择高于或属于引导的位置。  即使它被称为引导、它也不需要被视为引导闪存、但可以是您的部分 PFLASH。 因此、如果您的部分闪存从程序闪存的开头开始、您可以使用引导选项。  如果它不是从 pflash 开始、而是在 pflash 块结束、那么您可以使用上面的引导选项。  如果它不是从 pflash 的开头开始、也不是在 pflash 的末尾结束、那么您需要继续使用 Fusion API.e2e.ti.com/.../Fusion-API-Training.docx

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Amiel:

    感谢您在这里提出的建议、感谢您与我分享这些培训文档。

    看起来您是对的、登录 GUI 会导致速度减慢。 我的代码将在事件处理程序中逐个显示 ACK 消息、在所有发现完成后更改代码以显示所有信息后、这看起来是正常的。

    谢谢。。。

    插孔