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.
After day of work I have managed to run SFO() function from assembler program. If someone needs it, I want to discribe it, it would be nice if TI put also assembler posibility into documentation, at least some important information about setting AMODE aetc. befor calling library functions.
1. It is good to compile first TI example for HRPWM what is described everywere. If it is running it is a good base to compare to your assembler. Also MAP file with memory location and all other needed things, which can inspire you.
2. I created small sfo.c file with:
#include "SFO_V6.h" // HRPWM calibration SFO() function need this
#define Uint16 unsigned int
#define Uint32 unsigned long
#include "DSP2803x_EPwm.h" // HRPWM calibration SFO() function need this
#pragma DATA_SECTION(EPwm1Regs,"EPwm1RegsFile");
#pragma DATA_SECTION(EPwm2Regs,"EPwm2RegsFile");
#pragma DATA_SECTION(EPwm3Regs,"EPwm3RegsFile");
volatile struct EPWM_REGS EPwm1Regs;
volatile struct EPWM_REGS EPwm2Regs;
volatile struct EPWM_REGS EPwm3Regs;
// volatile struct EPWM_REGS *ePWM[PWM_CH] = {&EPwm1Regs, &EPwm1Regs, &EPwm2Regs, &EPwm3Regs};
// I use not initialized ePWM[] structure because _c_init00 is not running to initialize it, I do it myself in startup.asm
volatile struct EPWM_REGS *ePWM[PWM_CH];
3. in assebler define globals:
; SFO() globals
.global _EPwm1Regs
.global _ePWM
.global _SFO
4. I am not running any C-code so I do not run standart stratup.asm, .cinit sections to be initialized, unfortunately SFO library has it's own variables, all together 11x16-bit:
size= 0x000b SFO_TI_Build_V6b.lib : SFO_V6b.obj (.ebss)
One of these variables has to be initialized to 0x0000, so I filled zeros to all 11x16-bit adresses of these variables
5. If you do not use automatic .cinit initialization you have to initialize also ePWM, in my case:
MOVL XAR0, #_ePWM
MOV *XAR0++, #0x6800 ;&EPwm1Regs
MOV *XAR0++, #0x0000
MOV *XAR0++, #0x6800 ;&EPwm1Regs
MOV *XAR0++, #0x0000
MOV *XAR0++, #0x6840 ;&EPwm2Regs
MOV *XAR0++, #0x0000
MOV *XAR0++, #0x6880 ;&EPwm3Regs
MOV *XAR0++, #0x0000
6. Then you define _MEP_ScaleFactor variable, e.g.:
_MEP_ScaleFactor .usect ".ebss", 1, 0, 0 ; used by external SFO() function in sfo_v6b.lib
7. Last step you call SFO() subroutine in your main program:
; SFO() executes EDIS, EALLOW is needed, ! DP, SPM is also changed
CLRC AMODE ; AMODE = 0 => C28x mode needed for SFO()
.c28_amode ; tell assembler that AMODE = 0
LCR _SFO
; return result of SFO() is in AL register, so you can take it as: MOV @SFO_Result, AL
! AMODE = 0 is the most improtant thing to make it working. I do not know what other ST0 and ST1 settings are needed for you, if it is not working you can run C-example (see 1.), make breakpoint to call of SFO() and see what setting is for you needed.
If SFO() runs correctly it should after some small time (10ms = mayby even more calls of SFO()) return AL = 0x0001, and set correctly ePWM1.HRMSTEP register with expected value of steps.
This is all needed if you want to make small program with HRPWM running fast in assembler without any C-language. Please note all setings = number of ePWMs you use, adresses you have to check in documentation, I did it for F28035 chip.
Dusko P said:After day of work I have managed to run SFO() function from assembler program. If someone needs it, I want to discribe it, it would be nice if TI put also assembler posibility into documentation, at least some important information about setting AMODE aetc. befor calling library functions.
Dusko,
Thank you for sharing this. I'm sorry that you didn't find the information you needed to implement this easily. We don't often see assembly only projects on the C28x platform. I'll take your feedback to the team. Also I may write up a wiki article based on your feedback.
Best Regards & Happy Coding
Lori