【问题标题】:How do you run a SCL file in MPLAB without a "Run SCL" button如何在没有“运行 SCL”按钮的情况下在 MPLAB 中运行 SCL 文件
【发布时间】:2023-01-13 19:48:57
【问题描述】:

我正在尝试通过 MPLAB X V5.05 Stimulus 窗口使用 SCL 文件来刺激 PIC18F458 上的 AIO 引脚之一。

虽然,文件已成功附加;当我运行模拟时,除了不包含任何值的 ADRESL 和 ADRESH 寄存器外,无法确认 SCL 是否真的在运行。

此外,我没有“运行 SCL”按钮;不像我在网上看到的其他例子。

如果缺少按钮,是否还有另一种运行 SCL 文件的方法?或者我是否需要更改项目配置中的某些内容以启用“运行 SCL”按钮?

请注意,我正在使用其他人创建的 SCL 文件和数据点文件的示例,因为我是新手。

因此,请在下面找到 SCL 文件引用的数据点文件及其相关值。

time 100 us  // 100KSPS
// Long lines are possible:
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15
// next line is ignored

-- this is a comment also
-- next we have a pulse
100 110 150 250 480 800 960 1023
wait for 400 us
1023 1000 900 700 650 600 580 550 510 480
400 300 210 128 96 80
wait for 1 ms -- long pause

如果有人能告诉我我尝试运行 SCL 文件时出错的地方,这是我第一次尝试,我将不胜感激。

另外,请注意,我没有包括程序代码或测试平台代码,因为我认为它们不会为这个问题增加多少价值。但是,如果有帮助,我愿意将它们包括在内。 问候

【问题讨论】:

  • 也许一些额外的细节有助于分析情况,也许我们可以尝试使用 MPLAB 模拟器。例如,您使用什么版本的 MPLAB,它是什么 PIC?您还可以在文件中包含这些值。

标签: microcontroller mplab


【解决方案1】:

SCL Code Repo 和 MPLAB IDE 帮助中提供的 SCL 用户指南中进行了一些研究,并进行了一些测试后,即使使用直接的 SCL 代码,我也无法从文件中获取值。我首先使用的 SCL 代码如下:

configuration for "pic18f458" is
end configuration;

testbench for "pic18f458" is
begin
    // Register Injection
    process is
    file fileVar : text;
    variable status : file_open_status;
    variable val : integer;
    begin
        report("Analog injection started...");
        file_open(status, fileVar, "<file_path>", read_mode);
        if status == open_ok then
            report("Reading the values file...");
            while endfile(fileVar) == false loop
                read(fileVar, val);
                wait until ADCON0.GO_nDONE == '1';
                report("Conversion started");
                wait until ADCON0.GO_nDONE == '0';
                report("Conversion ended");
                if ADCON1.ADFM == '0' then  -- left justified
                    ADRESH <= val / 4;
                    ADRESL <= val * 64;
                else                        -- right justified
                    ADRESH <= val / 256;
                    ADRESL <= val;
                end if;
            end loop;
        file_close(fileVar);
        wait;
        end if;
    end process;

end testbench;

我确实在模拟器输出中看到了报告字符串,但是 ADRES 寄存器总是被注入0xFFFF价值。我尝试修改版本但没有成功。


然而,当我决定修改 SCL 代码并尝试使用代码内变量时,它确实起作用了。代码内变量的值已正确注入。从这个案例中我发现文件读取操作在某处失败并且无法正确地从文件中获取值。后者的工作 SCL 代码如下:

configuration for "pic18f458" is
end configuration;

testbench for "pic18f458" is
begin
    // Register Injection
    process is
    file fileVar : text;
    variable status : file_open_status;
    variable val : integer;
    begin
        report("Analog injection started...");
        val := 7;
        while val < 1024 loop
            wait until ADCON0.GO_nDONE == '1';
            report("Conversion started");
            wait until ADCON0.GO_nDONE == '0';
            report("Conversion ended");
            if ADCON1.ADFM == '0' then  -- left justified
                ADRESH <= val / 4;
                ADRESL <= val * 64;
            else                        -- right justified
                ADRESH <= val / 256;
                ADRESL <= val;
            end if;
            val := val * 8;
        end loop;
        report("Analog injection ended...");
        wait;
    end process;

end testbench;

上述 SCL 代码将在每次 ADC 转换结束时注入 val 变量的实际值(GO_nDONE 位首先变为高电平,当转换完成时变为低电平)。根据ADFM位进行值注入。如果设置为 0,则值将左对齐,否则将右对齐。

所以我在微芯片论坛上发了an issue关于这个问题。让我们看看它将如何解决。


好吧,如果这些值不需要非常具体,您可以使用第二个 SCL 代码。但是,为了在 MPLABX IDE 中启用寄存器注入,您需要先配置模拟器。去做这个

  1. 通过单击打开项目属性窗口文件 -> 项目属性在菜单中。
  2. 然后从类别部分选择模拟器.
  3. 选择外设:ADC1来自选项类别在右窗格中。
  4. 最后确保为 ADCxBUF0 使用 MPLAB 8 样式激励/SCL如下图所示。

    配置好后打开刺激窗口,首先启动模拟一次,以便显示其内容,然后单击附加 SCL 文件图标附加您的 SCL 文件,最后使用新附加的 SCL 重新启动仿真。

【讨论】:

    猜你喜欢
    • 2022-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多