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.

[参考译文] TMS320F28335:基于 EPWM 中断和向 SYS/BIOS 添加任务的 ADC 初始化

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

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1383956/tms320f28335-adc-initialization-based-on-epwm-interrupt-and-adding-task-to-sys-bios

器件型号:TMS320F28335
Thread 中讨论的其他器件: SYSBIOSTM4C123GH6PMC2000WAREcontrolSUITE

工具与软件:

嘿、Fellas、我是一名新手、正在使用具有控制卡的 TMS320F28335、您可以看到下面。 我正在对其运行 SYS/BIOS、并想使用 ADC 来测量交流电压。 我无法通过数据表弄清楚初始化序列。 我从一个示例开始、但它显示了错误。 我发布了 我写入用于切换 GPIO 的代码、现在我要尝试在其中添加一个 ADC 任务。 但在此之前、我想通过内置功能来校准 ADC、所以会出现错误。

代码如下:

/*
 *  ======== main.c ========
 */


#include <xdc/std.h>

#include <xdc/runtime/Error.h>
#include <xdc/runtime/System.h>

#include <ti/sysbios/BIOS.h>

#include <ti/sysbios/knl/Task.h>

#include <ti/sysbios/hal/Hwi.h>
#include <ti/sysbios/knl/Semaphore.h>
extern const ti_sysbios_knl_Semaphore_Handle sem0,sem1;
#include "include/DSP28x_Project.h"


#define GPAQSEL1    (*((volatile UInt16 *)0x6F82))  //GPA Qualifier Select. It works like how many samples required to register an Input
#define GPAMUX1     (*((volatile UInt16 *)0x6F86))  // GPA MUX 1 register for gpio 0 -15
#define GPADIR      (*((volatile UInt16 *)0x6F8A))  // GPA Direction Input/Output
#define GPAPUD      (*((volatile UInt16 *)0x6F8C))  // GPA Internal Pull-Up 0-enable/1-Disable
#define GPACTRL     (*((volatile UInt16 *)0x6F80))  // GPIO Port control
#define GPADAT      (*((volatile UInt16 *)0x6FC0))  // GPIO Data Register
#define GPASET      (*((volatile UInt16 *)0x6FC2))  // GPIO SET pin state
#define GPACLEAR    (*((volatile UInt16 *)0x6FC4))  // GPIO Clear pin state
#define GPATOGGLE  (*((volatile UInt16 *)0x6FC6))  // GPIO Toggle the pin state
#define ADC_Cal     (void (*) (void)) 0x380080

UInt16 counter=0;
static UInt32 count=0;
/*
 *  ======== taskFxn ========
 */
Void taskFx1(UArg a0, UArg a1)
{

    for(;;){
        Semaphore_pend(sem0, BIOS_WAIT_FOREVER);
        count+= 1;
    System_printf("enter taskFx1(): %i",count);
//    System_printf((char*)count);
    Task_sleep(1000);
    GPASET = (1<<2);
//    Task_sleep(1000);
//    GPATOGGLE = (1<<2);
//    System_printf("exit taskFxn()\n");
//    Task_sleep(1000);

    System_flush(); /* force SysMin output to console */
    Semaphore_post(sem1);
    }
}

Void taskFx2(UArg a0, UArg a1)
{

    for(;;){
        Semaphore_pend(sem1, BIOS_WAIT_FOREVER);
        Task_sleep(1000);
        GPACLEAR = (1<<2);
        if(counter >= 10){
            counter = 0;
    System_printf("\tenter taskFx2()\n");
//    GPACLEAR = (1<<2);
//    Task_sleep(100);
    GPATOGGLE = (1<<1);
//    System_printf("Exit taskFxn()\n");

//    Task_yeild(&task);


    System_flush(); /* force SysMin output to console */
    }
        counter++;
        Semaphore_post(sem0);
    }
}

/*
 *  ======== main ========
 */
Int main()
{
    EALLOW;

    Task_Handle task,task2;
    SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
    (*ADC_Cal) ();
    SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 0;
    Error_Block eb;

    GPAMUX1     =   0;
    GPAQSEL1    |= 2;            // Sampling 6 times- If the state is same for 6 clocks it'll be registered on DSP
    GPADIR      = 0;
    GPADIR      |= (3<<1);      //PIN 2 as OUTPUT and rest are INPUT by default
    GPAPUD      = 0;            //Clear pull up register
    GPAPUD      |= 0xFFFE;      // Enable pull-up for GPIOA 2
    GPACTRL     = 0;            // Enable CLock for Pin 7-0
    GPACLEAR    |= (3<<1);
    EDIS;

    System_printf("enter main()\n");

    Error_init(&eb);

    task = Task_create(taskFx1, NULL, &eb);
    task2 = Task_create(taskFx2, NULL, &eb);
//    Semaphore_create(sem0, NULL, &eb);
//    Semaphore_create(sem1, NULL, &eb);
//    Semaphore_post(sem0);
    if (task == NULL || task2 == NULL) {
        System_printf("Task_create() failed!\n");
        BIOS_exit(0);
    }


    BIOS_start();    /* does not return */
    return(0);
}

这是.cfg 文件:

var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Diags = xdc.useModule('xdc.runtime.Diags');
var Error = xdc.useModule('xdc.runtime.Error');
var Log = xdc.useModule('xdc.runtime.Log');
var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
var Main = xdc.useModule('xdc.runtime.Main');
var Memory = xdc.useModule('xdc.runtime.Memory')
var SysMin = xdc.useModule('xdc.runtime.SysMin');
var System = xdc.useModule('xdc.runtime.System');
var Text = xdc.useModule('xdc.runtime.Text');

var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Swi = xdc.useModule('ti.sysbios.knl.Swi');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');

var Hwi = xdc.useModule('ti.sysbios.family.c28.Hwi');

/*
 * Uncomment this line to globally disable Asserts.
 * All modules inherit the default from the 'Defaults' module.  You
 * can override these defaults on a per-module basis using Module.common$. 
 * Disabling Asserts will save code space and improve runtime performance.
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
 */

/*
 * Uncomment this line to keep module names from being loaded on the target.
 * The module name strings are placed in the .const section. Setting this
 * parameter to false will save space in the .const section.  Error and
 * Assert messages will contain an "unknown module" prefix instead
 * of the actual module name.
Defaults.common$.namedModule = false;
 */

/*
 * Minimize exit handler array in System.  The System module includes
 * an array of functions that are registered with System_atexit() to be
 * called by System_exit().
 */
System.maxAtexitHandlers = 4;       

/* 
 * Uncomment this line to disable the Error print function.  
 * We lose error information when this is disabled since the errors are
 * not printed.  Disabling the raiseHook will save some code space if
 * your app is not using System_printf() since the Error_print() function
 * calls System_printf().
Error.raiseHook = null;
 */

/* 
 * Uncomment this line to keep Error, Assert, and Log strings from being
 * loaded on the target.  These strings are placed in the .const section.
 * Setting this parameter to false will save space in the .const section.
 * Error, Assert and Log message will print raw ids and args instead of
 * a formatted message.
Text.isLoaded = false;
 */

/*
 * Uncomment this line to disable the output of characters by SysMin
 * when the program exits.  SysMin writes characters to a circular buffer.
 * This buffer can be viewed using the SysMin Output view in ROV.
SysMin.flushAtExit = false;
 */

/*
 * The BIOS module will create the default heap for the system.
 * Specify the size of this default heap.
 */
BIOS.heapSize = 0x800;

/*
 * Build a custom SYS/BIOS library from sources.
 */
BIOS.libType = BIOS.LibType_Custom;

/* System stack size (used by ISRs and Swis) */
Program.stack = 0x100;

/* Circular buffer size for System_printf() */
SysMin.bufSize = 0x200;

/*
	USER CODE
*/
var sem0Params = new Semaphore.Params();
sem0Params.instance.name = "sem0";
Program.global.sem0 = Semaphore.create(1, sem0Params);

var sem1Params = new Semaphore.Params();
sem1Params.instance.name = "sem1";
Program.global.sem1 = Semaphore.create(1, sem1Params);

var task1Params = new Task.Params();
task1Params.instance.name = "task1";
Program.global.task1 = Task.create("&taskFx1", task1Params);
var task1Params = new Task.Params();
task1Params.instance.name = "task2";
Program.global.task2 = Task.create("&taskFx2", task1Params);

/* 
 * Create and install logger for the whole system
 */
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 32;
var logger0 = LoggerBuf.create(loggerBufParams);
Defaults.common$.logger = logger0;
Main.common$.diags_INFO = Diags.ALWAYS_ON;

System.SupportProxy = SysMin;

错误:

我想要的是使用 ePWM 触发 ADC SoC、或者假设我要对220V 的交流50Hz 波进行采样、至少为2uS。 我只是想从头开始了解它。 我用中断(不是 TI-RTOS)在 TM4C123GH6PM 上完成了相同的任务、一切都运行正常。 但 C2000的数据表不太友好。

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

    该错误消息是关于无法找到 SysCtrlRegs、因此我想您将 C2000Ware 头文件集成到 SYS/BIOS 工程的方式存在问题。 C2000Ware 中有一个文档(device_support\f2833x\docs\F2833x_dev_user_guide.pdf)、其中包含"2.2 Project Creation (2.2项目创建)"部分。 步骤3-6介绍了需要添加到工程以使用头文件(例如包含 SysCtrlRegs 的工程)的工程属性和文件。

    惠特尼

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

    我按照该指南设置了起作用的项目。 但我现在遇到了重叠误差。 请参阅下面随附的错误。

    Description	Resource	Path	Location	Type
    #10264 PIE_VECT memory range overlaps existing memory range PIEVECT	.ccsproject	/typical	line 47, external location: C:\ti\controlSUITE\device_support\f2833x\v142\DSP2833x_headers\cmd\DSP2833x_Headers_nonBIOS.cmd	C/C++ Problem
    

    重叠的因素有很多、因此我删除了 ram_lnk.cmd 文件、这样就解决了问题。 但我认为这不是一个好的做法。 比如、我将上传闪存中的固件、使其独立工作。因此、这可能是个问题。 就像我之前说的、我对它不了解太多。

    是否有人可以为 ADC 提供初始化模式?

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

    而不是使用 DSP2833x_Headers_ 非 BIOS .cmd、使用 DSP2833x_Headers_ BIOS .cmd。 本常见问题解答中提供了一些有关 SYS/BIOS 和 C2000Ware 软件之间冲突的指导。 遗憾的是、我没有 ControlSUITE 头文件的等效指南、但想法是一样的-您需要确保您在的应用中放置的代码不会与 SYS/BIOS 相冲突(PIE 矢量表初始化、时钟初始化等)

    但是、SYS/BIOS 不会影响 ADC 寄存器的配置、因此您应该能够仅重复使用 controlSUITE 示例中的 ADC 寄存器初始化序列。

    惠特尼