Update repo
This commit is contained in:
1 parent
749dab5721
commit
ce65a0f59a
14950 files changed
+4408250
-1
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex1_soc_software"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../adc_ex1_soc_software.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,30 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex2_soc_epwm"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../adc_ex2_soc_epwm.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex3_soc_epwm_tempsensor"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_tempsensorconv.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../adc_ex3_soc_epwm_tempsensor.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex4_soc_software_sync"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../adc_ex4_soc_software_sync.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex5_soc_continuous"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../adc_ex5_soc_continuous.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex6_soc_continuous_dma"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../adc_ex6_soc_continuous_dma.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,30 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex7_ppb_offset"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../adc_ex7_ppb_offset.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,30 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex8_ppb_limits"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../adc_ex8_ppb_limits.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,30 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="adc_ex9_ppb_delay"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../adc_ex9_ppb_delay.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,276 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex1_soc_software.c
|
||||
//
|
||||
// TITLE: ADC software triggering for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> ADC SOC Software Force (adc_soc_software)</h1>
|
||||
//!
|
||||
//! This example converts some voltages on ADCA and ADCB based on a software
|
||||
//! trigger.
|
||||
//!
|
||||
//! After the program runs, the memory will contain:
|
||||
//!
|
||||
//! - \b AdcaResult0 \b: a digital representation of the voltage on pin A2\n
|
||||
//! - \b AdcaResult1 \b: a digital representation of the voltage on pin A3\n
|
||||
//! - \b AdcbResult0 \b: a digital representation of the voltage on pin B2\n
|
||||
//! - \b AdcbResult1 \b: a digital representation of the voltage on pin B3\n
|
||||
//!
|
||||
//! Note: The software triggers for the two ADCs happen sequentially, so the
|
||||
//! two ADCs will run asynchronously.
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void ConfigureADC(void);
|
||||
void SetupADCSoftware(void);
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 AdcaResult0;
|
||||
Uint16 AdcaResult1;
|
||||
Uint16 AdcbResult0;
|
||||
Uint16 AdcbResult1;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitGpio();
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Configure the ADCs and power them up
|
||||
//
|
||||
ConfigureADC();
|
||||
|
||||
//
|
||||
// Setup the ADCs for software conversions
|
||||
//
|
||||
SetupADCSoftware();
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Convert, wait for completion, and store results
|
||||
// start conversions immediately via software, ADCA
|
||||
//
|
||||
AdcaRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
|
||||
|
||||
//
|
||||
// Start conversions immediately via software, ADCB
|
||||
//
|
||||
AdcbRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
|
||||
|
||||
//
|
||||
// Wait for ADCA to complete, then acknowledge flag
|
||||
//
|
||||
while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0);
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
|
||||
//
|
||||
// Wait for ADCB to complete, then acknowledge flag
|
||||
//
|
||||
while(AdcbRegs.ADCINTFLG.bit.ADCINT1 == 0);
|
||||
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
|
||||
//
|
||||
// Store results
|
||||
//
|
||||
AdcaResult0 = AdcaResultRegs.ADCRESULT0;
|
||||
AdcaResult1 = AdcaResultRegs.ADCRESULT1;
|
||||
AdcbResult0 = AdcbResultRegs.ADCRESULT0;
|
||||
AdcbResult1 = AdcbResultRegs.ADCRESULT1;
|
||||
|
||||
//
|
||||
// At this point, conversion results are stored in
|
||||
// AdcaResult0, AdcaResult1, AdcbResult0, and AdcbResult1
|
||||
//
|
||||
|
||||
//
|
||||
// Software breakpoint, hit run again to get updated conversions
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
|
||||
}while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureADC - Write ADC configurations and power up the ADC for both
|
||||
// ADC A and ADC B
|
||||
//
|
||||
void ConfigureADC(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Write configurations
|
||||
//
|
||||
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
|
||||
AdcbRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
|
||||
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
|
||||
//
|
||||
// Power up the ADCs
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DELAY_US(1000);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// SetupADCSoftware - Setup ADC channels and acquisition window
|
||||
//
|
||||
void SetupADCSoftware(void)
|
||||
{
|
||||
Uint16 acqps;
|
||||
|
||||
//
|
||||
// Determine minimum acquisition window (in SYSCLKS) based on resolution
|
||||
//
|
||||
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
|
||||
{
|
||||
acqps = 14; //75ns
|
||||
}
|
||||
else //resolution is 16-bit
|
||||
{
|
||||
acqps = 63; //320ns
|
||||
}
|
||||
|
||||
//
|
||||
// Select the channels to convert and end of conversion flag
|
||||
// ADCA
|
||||
//
|
||||
EALLOW;
|
||||
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2; //SOC0 will convert pin A2
|
||||
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 3; //SOC1 will convert pin A3
|
||||
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
|
||||
//ADCB
|
||||
AdcbRegs.ADCSOC0CTL.bit.CHSEL = 2; //SOC0 will convert pin B2
|
||||
AdcbRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcbRegs.ADCSOC1CTL.bit.CHSEL = 3; //SOC1 will convert pin B3
|
||||
AdcbRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
|
||||
AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
|
||||
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,321 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex2_soc_epwm.c
|
||||
//
|
||||
// TITLE: ADC triggering via epwm for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> ADC ePWM Triggering (adc_soc_epwm)</h1>
|
||||
//!
|
||||
//! This example sets up the ePWM to periodically trigger the ADC.
|
||||
//!
|
||||
//! After the program runs, the memory will contain:\n
|
||||
//! - \b AdcaResults \b: A sequence of analog-to-digital conversion samples from
|
||||
//! pin A0. The time between samples is determined based on the period
|
||||
//! of the ePWM timer.
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void ConfigureADC(void);
|
||||
void ConfigureEPWM(void);
|
||||
void SetupADCEpwm(Uint16 channel);
|
||||
interrupt void adca1_isr(void);
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define RESULTS_BUFFER_SIZE 256
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 AdcaResults[RESULTS_BUFFER_SIZE];
|
||||
Uint16 resultsIndex;
|
||||
volatile Uint16 bufferFull;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitGpio(); // Skipped for this example
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Map ISR functions
|
||||
//
|
||||
EALLOW;
|
||||
PieVectTable.ADCA1_INT = &adca1_isr; //function for ADCA interrupt 1
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Configure the ADC and power it up
|
||||
//
|
||||
ConfigureADC();
|
||||
|
||||
//
|
||||
// Configure the ePWM
|
||||
//
|
||||
ConfigureEPWM();
|
||||
|
||||
//
|
||||
// Setup the ADC for ePWM triggered conversions on channel 0
|
||||
//
|
||||
SetupADCEpwm(0);
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
IER |= M_INT1; //Enable group 1 interrupts
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Initialize results buffer
|
||||
//
|
||||
for(resultsIndex = 0; resultsIndex < RESULTS_BUFFER_SIZE; resultsIndex++)
|
||||
{
|
||||
AdcaResults[resultsIndex] = 0;
|
||||
}
|
||||
resultsIndex = 0;
|
||||
bufferFull = 0;
|
||||
|
||||
//
|
||||
// Enable PIE interrupt
|
||||
//
|
||||
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
|
||||
|
||||
//
|
||||
// Sync ePWM
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Start ePWM
|
||||
//
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 1; //enable SOCA
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 0; //unfreeze, and enter up count mode
|
||||
|
||||
//
|
||||
// Wait while ePWM causes ADC conversions, which then cause interrupts,
|
||||
// which fill the results buffer, eventually setting the bufferFull
|
||||
// flag
|
||||
//
|
||||
while(!bufferFull);
|
||||
bufferFull = 0; //clear the buffer full flag
|
||||
|
||||
//
|
||||
// Stop ePWM
|
||||
//
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 0; //disable SOCA
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 3; //freeze counter
|
||||
|
||||
//
|
||||
// At this point, AdcaResults[] contains a sequence of conversions
|
||||
// from the selected channel
|
||||
//
|
||||
|
||||
//
|
||||
// Software breakpoint, hit run again to get updated conversions
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
} while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureADC - Write ADC configurations and power up the ADC for both
|
||||
// ADC A and ADC B
|
||||
//
|
||||
void ConfigureADC(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Write configurations
|
||||
//
|
||||
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
|
||||
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
|
||||
//
|
||||
// Power up the ADC
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DELAY_US(1000);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureEPWM - Configure EPWM SOC and compare values
|
||||
//
|
||||
void ConfigureEPWM(void)
|
||||
{
|
||||
EALLOW;
|
||||
// Assumes ePWM clock is already enabled
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 0; // Disable SOC on A group
|
||||
EPwm1Regs.ETSEL.bit.SOCASEL = 4; // Select SOC on up-count
|
||||
EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
|
||||
EPwm1Regs.CMPA.bit.CMPA = 0x0800; // Set compare A value to 2048 counts
|
||||
EPwm1Regs.TBPRD = 0x1000; // Set period to 4096 counts
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 3; // freeze counter
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// SetupADCEpwm - Setup ADC EPWM acquisition window
|
||||
//
|
||||
void SetupADCEpwm(Uint16 channel)
|
||||
{
|
||||
Uint16 acqps;
|
||||
|
||||
//
|
||||
// Determine minimum acquisition window (in SYSCLKS) based on resolution
|
||||
//
|
||||
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
|
||||
{
|
||||
acqps = 14; //75ns
|
||||
}
|
||||
else //resolution is 16-bit
|
||||
{
|
||||
acqps = 63; //320ns
|
||||
}
|
||||
|
||||
//
|
||||
// Select the channels to convert and end of conversion flag
|
||||
//
|
||||
EALLOW;
|
||||
AdcaRegs.ADCSOC0CTL.bit.CHSEL = channel; //SOC0 will convert pin A0
|
||||
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is 100 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC0 will set INT1 flag
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// adca1_isr - Read ADC Buffer in ISR
|
||||
//
|
||||
interrupt void adca1_isr(void)
|
||||
{
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT0;
|
||||
if(RESULTS_BUFFER_SIZE <= resultsIndex)
|
||||
{
|
||||
resultsIndex = 0;
|
||||
bufferFull = 1;
|
||||
}
|
||||
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
|
||||
|
||||
//
|
||||
// Check if overflow has occurred
|
||||
//
|
||||
if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT1)
|
||||
{
|
||||
AdcaRegs.ADCINTOVFCLR.bit.ADCINT1 = 1; //clear INT1 overflow flag
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
|
||||
}
|
||||
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,279 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex3_soc_epwm_tempsensor.c
|
||||
//
|
||||
// TITLE: Sample temperature sensor and convert to temperature for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> ADC temperature sensor conversion (adc_soc_epwm_tempsensor)</h1>
|
||||
//!
|
||||
//! This example sets up the ePWM to periodically trigger the ADC. The
|
||||
//! ADC converts the internal connection to the temperature sensor,
|
||||
//! which is then interpreted as a temperature by calling the
|
||||
//! GetTemperatureC function.
|
||||
//!
|
||||
//! After the program runs, the memory will contain:\n
|
||||
//! - \b sensorSample \b : The raw reading from the temperature sensor. \n
|
||||
//! - \b sensorTemp \b : The interpretation of the sensor sample as a
|
||||
//! temperature in degrees Celsius.
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void ConfigureADC(void);
|
||||
void ConfigureEPWM(void);
|
||||
void SetupADCEpwm(void);
|
||||
interrupt void adca1_isr(void);
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 sensorSample;
|
||||
int16 sensorTemp;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitGpio(); // Skipped for this example
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Map ISR functions
|
||||
//
|
||||
EALLOW;
|
||||
PieVectTable.ADCA1_INT = &adca1_isr; //function for ADCA interrupt 1
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Configure the ADC and power it up
|
||||
//
|
||||
ConfigureADC();
|
||||
|
||||
//
|
||||
// Initialize the temperature sensor
|
||||
// Note: The argument needs to change if using a VREFHI voltage other than 3.0V
|
||||
//
|
||||
InitTempSensor(3.0);
|
||||
|
||||
//
|
||||
// Configure the ePWM
|
||||
//
|
||||
ConfigureEPWM();
|
||||
|
||||
//
|
||||
// Setup the ADC for ePWM triggered conversions on temperature sensor
|
||||
//
|
||||
SetupADCEpwm();
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
IER |= M_INT1; //Enable group 1 interrupts
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Enable PIE interrupt
|
||||
//
|
||||
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
|
||||
|
||||
//
|
||||
// Sync ePWM
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
|
||||
//
|
||||
// Start ePWM
|
||||
//
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 1; //enable SOCA
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 0; //unfreeze, and enter up count mode
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureADC - Write ADC configurations and power up the ADC for both
|
||||
// ADC A and ADC B
|
||||
//
|
||||
void ConfigureADC(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Write configurations
|
||||
//
|
||||
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
|
||||
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
|
||||
//
|
||||
// Power up the ADC
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DELAY_US(1000);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureEPWM - Configure EPWM SOC and compare values
|
||||
//
|
||||
void ConfigureEPWM(void)
|
||||
{
|
||||
EALLOW;
|
||||
//
|
||||
// Assumes ePWM clock is already enabled
|
||||
//
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 0; // Disable SOC on A group
|
||||
EPwm1Regs.ETSEL.bit.SOCASEL = 4; // Select SOC on up-count
|
||||
EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
|
||||
EPwm1Regs.CMPA.bit.CMPA = 0x0800; // Set compare A value to 2048 counts
|
||||
EPwm1Regs.TBPRD = 0x1000; // Set period to 4096 counts
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 3; // freeze counter
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// SetupADCEpwm - Configure ADC EPWM acquisition window and trigger
|
||||
//
|
||||
void SetupADCEpwm(void)
|
||||
{
|
||||
Uint16 tempsensor_acqps;
|
||||
|
||||
tempsensor_acqps = 139; //temperature sensor needs at least 700ns
|
||||
//acquisition time
|
||||
|
||||
//
|
||||
// Select the channels to convert and end of conversion flag
|
||||
//
|
||||
EALLOW;
|
||||
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 13; //SOC0 will convert internal
|
||||
//connection A13
|
||||
AdcaRegs.ADCSOC0CTL.bit.ACQPS = tempsensor_acqps; //sample window is 100
|
||||
//SYSCLK cycles
|
||||
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC0 will set INT1 flag
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// adca1_isr - Read Temperature ISR
|
||||
//
|
||||
interrupt void adca1_isr(void)
|
||||
{
|
||||
sensorSample = AdcaResultRegs.ADCRESULT0;
|
||||
sensorTemp = GetTemperatureC(sensorSample);
|
||||
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
|
||||
|
||||
//
|
||||
// Check if overflow has occurred
|
||||
//
|
||||
if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT1)
|
||||
{
|
||||
AdcaRegs.ADCINTOVFCLR.bit.ADCINT1 = 1; //clear INT1 overflow flag
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
|
||||
}
|
||||
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,301 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex4_soc_software_sync.c
|
||||
//
|
||||
// TITLE: ADC synchronous software triggering for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> ADC Synchronous SOC Software Force (adc_soc_software_sync)</h1>
|
||||
//!
|
||||
//! This example converts some voltages on ADCA and ADCB using input 5 of the
|
||||
//! input X-BAR as a software force. Input 5 is triggered by toggling GPIO0,
|
||||
//! but any spare GPIO could be used. This method will ensure that both ADCs
|
||||
//! start converting at exactly the same time.
|
||||
//!
|
||||
//! After the program runs, the memory will contain:
|
||||
//!
|
||||
//! - \b AdcaResult0 \b: a digital representation of the voltage on pin A2\n
|
||||
//! - \b AdcaResult1 \b: a digital representation of the voltage on pin A3\n
|
||||
//! - \b AdcbResult0 \b: a digital representation of the voltage on pin B2\n
|
||||
//! - \b AdcbResult1 \b: a digital representation of the voltage on pin B3\n
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void ConfigureADC(void);
|
||||
void SetupADCSoftwareSync(void);
|
||||
void SetupInputXBAR5(void);
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 AdcaResult0;
|
||||
Uint16 AdcaResult1;
|
||||
Uint16 AdcbResult0;
|
||||
Uint16 AdcbResult1;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitGpio();
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Configure the ADCs and power them up
|
||||
//
|
||||
ConfigureADC();
|
||||
|
||||
//
|
||||
// Setup the ADCs for software conversions
|
||||
//
|
||||
SetupADCSoftwareSync();
|
||||
SetupInputXBAR5();
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Convert, wait for completion, and store results
|
||||
//
|
||||
|
||||
//
|
||||
// Toggle GPIO0 in software. This will cause a trigger to
|
||||
// both ADCs via input XBAR, line 5.
|
||||
//
|
||||
GpioDataRegs.GPADAT.bit.GPIO0 = 1;
|
||||
GpioDataRegs.GPADAT.bit.GPIO0 = 0;
|
||||
|
||||
//
|
||||
// Wait for ADCA to complete, then acknowledge the flag.
|
||||
// Since both ADCs are running synchronously, it isn't necessary
|
||||
// to wait for completion notification from both ADCs
|
||||
//
|
||||
while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0);
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
|
||||
//
|
||||
// Store results
|
||||
//
|
||||
AdcaResult0 = AdcaResultRegs.ADCRESULT0;
|
||||
AdcaResult1 = AdcaResultRegs.ADCRESULT1;
|
||||
AdcbResult0 = AdcbResultRegs.ADCRESULT0;
|
||||
AdcbResult1 = AdcbResultRegs.ADCRESULT1;
|
||||
|
||||
//
|
||||
// At this point, conversion results are stored in
|
||||
// AdcaResult0, AdcaResult1, AdcbResult0, and AdcbResult1
|
||||
//
|
||||
|
||||
//
|
||||
// Software breakpoint, hit run again to get updated conversions
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
|
||||
} while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureADC - Write ADC configurations and power up the ADC for both
|
||||
// ADC A and ADC B
|
||||
//
|
||||
void ConfigureADC(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Write configurations
|
||||
//
|
||||
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
|
||||
AdcbRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
|
||||
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
|
||||
//
|
||||
// power up the ADCs
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DELAY_US(1000);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// SetupInputXBAR5 - Setup GPIO 0 to trigger input XBAR line 5. GPIO0 is used
|
||||
// as an example, but any spare GPIO could be used. The
|
||||
// physical GPIO pin should be allowed to float, since the
|
||||
// code configures it as an output and changes the value.
|
||||
//
|
||||
void SetupInputXBAR5(void)
|
||||
{
|
||||
EALLOW;
|
||||
InputXbarRegs.INPUT5SELECT = 0; //GPIO0 will trigger the input XBAR line 5
|
||||
|
||||
//
|
||||
// GPIO0 as an output
|
||||
//
|
||||
GPIO_SetupPinOptions(0, GPIO_OUTPUT, GPIO_PUSHPULL);
|
||||
GPIO_SetupPinMux(0, GPIO_MUX_CPU1, 0);
|
||||
|
||||
//
|
||||
// GPIO0 set as low
|
||||
//
|
||||
GpioDataRegs.GPADAT.bit.GPIO0 = 0;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// SetupADCSoftwareSync - Setup ADC acquisition window and compare values
|
||||
//
|
||||
void SetupADCSoftwareSync(void)
|
||||
{
|
||||
Uint16 acqps;
|
||||
|
||||
//
|
||||
// Determine minimum acquisition window (in SYSCLKS) based on resolution
|
||||
//
|
||||
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
|
||||
{
|
||||
acqps = 14; //75ns
|
||||
}
|
||||
else //resolution is 16-bit
|
||||
{
|
||||
acqps = 63; //320ns
|
||||
}
|
||||
|
||||
//
|
||||
// Select the channels to convert and end of conversion flag
|
||||
// ADCA
|
||||
//
|
||||
EALLOW;
|
||||
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2; //SOC0 will convert pin A2
|
||||
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 4; //line 5 of the input X-BAR will
|
||||
//trigger the ADC
|
||||
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 3; //SOC1 will convert pin A3
|
||||
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = 4; //line 5 of the input X-BAR will
|
||||
//trigger the ADC
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
|
||||
//
|
||||
//ADCB
|
||||
//
|
||||
AdcbRegs.ADCSOC0CTL.bit.CHSEL = 2; //SOC0 will convert pin B2
|
||||
AdcbRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 4; //line 5 of the input X-BAR will
|
||||
//trigger the ADC
|
||||
AdcbRegs.ADCSOC1CTL.bit.CHSEL = 3; //SOC1 will convert pin B3
|
||||
AdcbRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcbRegs.ADCSOC1CTL.bit.TRIGSEL = 4; //line 5 of the input X-BAR will
|
||||
//trigger the ADC
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,404 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex5_soc_continuous.c
|
||||
//
|
||||
// TITLE: ADC continuous self-triggering for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> ADC Continuous Triggering (adc_soc_continuous)</h1>
|
||||
//!
|
||||
//! This example sets up the ADC to convert continuously, achieving maximum
|
||||
//! sampling rate.\n
|
||||
//!
|
||||
//! After the program runs, the memory will contain:
|
||||
//!
|
||||
//! - \b AdcaResults \b: A sequence of analog-to-digital conversion samples
|
||||
//! from pin A0. The time between samples is the minimum possible based on the
|
||||
//! ADC speed.
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void ConfigureADC(void);
|
||||
void SetupADCContinuous(Uint16 channel);
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define RESULTS_BUFFER_SIZE 256 //buffer for storing conversion results
|
||||
//(size must be multiple of 16)
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 AdcaResults[RESULTS_BUFFER_SIZE];
|
||||
Uint16 resultsIndex;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitGpio(); // Skipped for this example
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Configure the ADC and power it up
|
||||
//
|
||||
ConfigureADC();
|
||||
|
||||
//
|
||||
// Setup the ADC for continuous conversions on channel 0
|
||||
//
|
||||
SetupADCContinuous(0);
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Initialize results buffer
|
||||
//
|
||||
for(resultsIndex = 0; resultsIndex < RESULTS_BUFFER_SIZE; resultsIndex++)
|
||||
{
|
||||
AdcaResults[resultsIndex] = 0;
|
||||
}
|
||||
resultsIndex = 0;
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Enable ADCINT flags
|
||||
//
|
||||
EALLOW;
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT2E = 1;
|
||||
AdcaRegs.ADCINTSEL3N4.bit.INT3E = 1;
|
||||
AdcaRegs.ADCINTSEL3N4.bit.INT4E = 1;
|
||||
AdcaRegs.ADCINTFLGCLR.all = 0x000F;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Initialize results index
|
||||
//
|
||||
resultsIndex = 0;
|
||||
|
||||
//
|
||||
// Software force start SOC0 to SOC7
|
||||
//
|
||||
AdcaRegs.ADCSOCFRC1.all = 0x00FF;
|
||||
|
||||
//
|
||||
// Keep taking samples until the results buffer is full
|
||||
//
|
||||
while(resultsIndex < RESULTS_BUFFER_SIZE)
|
||||
{
|
||||
//
|
||||
// Wait for first set of 8 conversions to complete
|
||||
//
|
||||
while(0 == AdcaRegs.ADCINTFLG.bit.ADCINT3);
|
||||
|
||||
//
|
||||
// Clear both INT flags generated by first 8 conversions
|
||||
//
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT3 = 1;
|
||||
|
||||
//
|
||||
// Save results for first 8 conversions
|
||||
//
|
||||
// Note that during this time, the second 8 conversions have
|
||||
// already been triggered by EOC6->ADCIN1 and will be actively
|
||||
// converting while first 8 results are being saved
|
||||
//
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT0;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT1;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT2;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT3;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT4;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT5;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT6;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT7;
|
||||
|
||||
//
|
||||
// Wait for the second set of 8 conversions to complete
|
||||
//
|
||||
while(0 == AdcaRegs.ADCINTFLG.bit.ADCINT4);
|
||||
|
||||
//
|
||||
// Clear both INT flags generated by second 8 conversions
|
||||
//
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1;
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT4 = 1;
|
||||
|
||||
//
|
||||
// Save results for second 8 conversions
|
||||
//
|
||||
// Note that during this time, the first 8 conversions have
|
||||
// already been triggered by EOC14->ADCIN2 and will be actively
|
||||
// converting while second 8 results are being saved
|
||||
//
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT8;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT9;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT10;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT11;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT12;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT13;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT14;
|
||||
AdcaResults[resultsIndex++] = AdcaResultRegs.ADCRESULT15;
|
||||
}
|
||||
|
||||
//
|
||||
// Disable all ADCINT flags to stop sampling
|
||||
//
|
||||
EALLOW;
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 0;
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT2E = 0;
|
||||
AdcaRegs.ADCINTSEL3N4.bit.INT3E = 0;
|
||||
AdcaRegs.ADCINTSEL3N4.bit.INT4E = 0;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// At this point, AdcaResults[] contains a sequence of conversions
|
||||
// from the selected channel
|
||||
//
|
||||
|
||||
//
|
||||
// Software breakpoint, hit run again to get updated conversions
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
} while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureADC - Write ADC configurations and power up the ADC for both
|
||||
// ADC A and ADC B
|
||||
//
|
||||
void ConfigureADC(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Write configurations
|
||||
//
|
||||
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
|
||||
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
|
||||
//
|
||||
// Power up the ADC
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DELAY_US(1000);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// SetupADCContinuous - setup the ADC to continuously convert on one channel
|
||||
//
|
||||
void SetupADCContinuous(Uint16 channel)
|
||||
{
|
||||
Uint16 acqps;
|
||||
|
||||
//
|
||||
// Determine minimum acquisition window (in SYSCLKS) based on resolution
|
||||
//
|
||||
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
|
||||
{
|
||||
acqps = 14; //75ns
|
||||
}
|
||||
else //resolution is 16-bit
|
||||
{
|
||||
acqps = 63; //320ns
|
||||
}
|
||||
|
||||
EALLOW;
|
||||
AdcaRegs.ADCSOC0CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC1CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC2CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC3CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC4CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC5CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC6CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC7CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC8CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC9CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC10CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC11CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC12CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC13CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC14CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
AdcaRegs.ADCSOC15CTL.bit.CHSEL = channel; //SOC will convert on channel
|
||||
|
||||
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC2CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC3CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC4CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC5CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC6CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC7CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC8CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC9CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC10CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC11CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC12CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC13CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC14CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC15CTL.bit.ACQPS = acqps; //sample window is acqps +
|
||||
//1 SYSCLK cycles
|
||||
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 0; //disable INT1 flag
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT2E = 0; //disable INT2 flag
|
||||
AdcaRegs.ADCINTSEL3N4.bit.INT3E = 0; //disable INT3 flag
|
||||
AdcaRegs.ADCINTSEL3N4.bit.INT4E = 0; //disable INT4 flag
|
||||
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 0;
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT2CONT = 0;
|
||||
AdcaRegs.ADCINTSEL3N4.bit.INT3CONT = 0;
|
||||
AdcaRegs.ADCINTSEL3N4.bit.INT4CONT = 0;
|
||||
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 6; //end of SOC6 will set INT1 flag
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT2SEL = 14; //end of SOC14 will set INT2 flag
|
||||
AdcaRegs.ADCINTSEL3N4.bit.INT3SEL = 7; //end of SOC7 will set INT3 flag
|
||||
AdcaRegs.ADCINTSEL3N4.bit.INT4SEL = 15; //end of SOC15 will set INT4 flag
|
||||
|
||||
//
|
||||
// ADCINT2 will trigger first 8 SOCs
|
||||
//
|
||||
AdcaRegs.ADCINTSOCSEL1.bit.SOC0 = 2;
|
||||
AdcaRegs.ADCINTSOCSEL1.bit.SOC1 = 2;
|
||||
AdcaRegs.ADCINTSOCSEL1.bit.SOC2 = 2;
|
||||
AdcaRegs.ADCINTSOCSEL1.bit.SOC3 = 2;
|
||||
AdcaRegs.ADCINTSOCSEL1.bit.SOC4 = 2;
|
||||
AdcaRegs.ADCINTSOCSEL1.bit.SOC5 = 2;
|
||||
AdcaRegs.ADCINTSOCSEL1.bit.SOC6 = 2;
|
||||
AdcaRegs.ADCINTSOCSEL1.bit.SOC7 = 2;
|
||||
|
||||
//
|
||||
// ADCINT1 will trigger second 8 SOCs
|
||||
//
|
||||
AdcaRegs.ADCINTSOCSEL2.bit.SOC8 = 1;
|
||||
AdcaRegs.ADCINTSOCSEL2.bit.SOC9 = 1;
|
||||
AdcaRegs.ADCINTSOCSEL2.bit.SOC10 = 1;
|
||||
AdcaRegs.ADCINTSOCSEL2.bit.SOC11 = 1;
|
||||
AdcaRegs.ADCINTSOCSEL2.bit.SOC12 = 1;
|
||||
AdcaRegs.ADCINTSOCSEL2.bit.SOC13 = 1;
|
||||
AdcaRegs.ADCINTSOCSEL2.bit.SOC14 = 1;
|
||||
AdcaRegs.ADCINTSOCSEL2.bit.SOC15 = 1;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,543 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex6_soc_continuous_dma.c
|
||||
//
|
||||
// TITLE: ADC continuous conversions read by DMA for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> ADC Continuous Conversions Read by DMA (adc_soc_continuous_dma)</h1>
|
||||
//!
|
||||
//! This example sets up two ADC channels to convert simultaneously. The
|
||||
//! results will be transferred by the DMA into a buffer in RAM.
|
||||
//!
|
||||
//! After the program runs, the memory will contain:
|
||||
//!
|
||||
//! - \b adcData0 \b: a digital representation of the voltage on pin A3\n
|
||||
//! - \b adcData1 \b: a digital representation of the voltage on pin B3\n
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
__interrupt void adca1_isr(void);
|
||||
__interrupt void dmach1_isr(void);
|
||||
|
||||
void ConfigureEPWM(void);
|
||||
void ConfigureADC(void);
|
||||
void SetupADCContinuous(volatile struct ADC_REGS * adcRegs, Uint16 channel);
|
||||
void DMAInit(void);
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define RESULTS_BUFFER_SIZE 1024 // Buffer for storing conversion results
|
||||
// (size must be multiple of 16)
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
#pragma DATA_SECTION(adcData0, "ramgs0");
|
||||
#pragma DATA_SECTION(adcData1, "ramgs0");
|
||||
Uint16 adcData0[RESULTS_BUFFER_SIZE];
|
||||
Uint16 adcData1[RESULTS_BUFFER_SIZE];
|
||||
volatile Uint16 done;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
Uint16 resultsIndex;
|
||||
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitGpio();
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Set up ISRs used by this example
|
||||
//
|
||||
// ISR for ADCA INT1 - occurs after first conversion
|
||||
// ISR for DMA ch1 - occurs when DMA transfer is complete
|
||||
//
|
||||
EALLOW;
|
||||
PieVectTable.ADCA1_INT = &adca1_isr;
|
||||
PieVectTable.DMA_CH1_INT = &dmach1_isr;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Enable specific CPU interrupts: INT1 for ADCs and INT7 for DMA
|
||||
//
|
||||
IER |= M_INT1;
|
||||
IER |= M_INT7;
|
||||
|
||||
//
|
||||
// Enable specific PIE interrupts
|
||||
//
|
||||
// ADCA INT1 - Group 1, interrupt 1
|
||||
// DMA interrupt - Group 7, interrupt 1
|
||||
//
|
||||
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
|
||||
PieCtrlRegs.PIEIER7.bit.INTx1 = 1;
|
||||
|
||||
//
|
||||
// Stop the ePWM clock
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Call the set up function for ePWM 2
|
||||
//
|
||||
ConfigureEPWM();
|
||||
|
||||
//
|
||||
// Start the ePWM clock
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Configure the ADC and power it up
|
||||
//
|
||||
ConfigureADC();
|
||||
|
||||
//
|
||||
// Setup the ADC for continuous conversions on channels A3 and B3
|
||||
//
|
||||
SetupADCContinuous(&AdcaRegs, 3);
|
||||
SetupADCContinuous(&AdcbRegs, 3);
|
||||
|
||||
//
|
||||
// Initialize the DMA
|
||||
//
|
||||
DMAInit();
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Initialize results buffer
|
||||
//
|
||||
for(resultsIndex = 0; resultsIndex < RESULTS_BUFFER_SIZE; resultsIndex++)
|
||||
{
|
||||
adcData0[resultsIndex] = 0;
|
||||
adcData1[resultsIndex] = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Clearing all pending interrupt flags
|
||||
//
|
||||
EALLOW;
|
||||
|
||||
DmaRegs.CH1.CONTROL.bit.PERINTCLR = 1;
|
||||
DmaRegs.CH2.CONTROL.bit.PERINTCLR = 1;
|
||||
AdcaRegs.ADCINTFLGCLR.all = 0x3;
|
||||
AdcbRegs.ADCINTFLGCLR.all = 0x3;
|
||||
EPwm2Regs.ETCNTINITCTL.bit.SOCAINITFRC = 1;
|
||||
EPwm2Regs.ETCLR.bit.SOCA = 1;
|
||||
|
||||
//
|
||||
// Enable continuous operation by setting the last SOC to re-trigger the first
|
||||
//
|
||||
AdcaRegs.ADCINTSOCSEL1.bit.SOC0 = 2;
|
||||
AdcbRegs.ADCINTSOCSEL1.bit.SOC0 = 2;
|
||||
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Start DMA
|
||||
//
|
||||
done = 0;
|
||||
StartDMACH1();
|
||||
StartDMACH2();
|
||||
|
||||
//
|
||||
// Finally, enable the SOCA trigger from ePWM. This will kick off
|
||||
// conversions at the next ePWM event.
|
||||
//
|
||||
EPwm2Regs.ETSEL.bit.SOCAEN = 1;
|
||||
|
||||
//
|
||||
// Loop until the ISR signals the transfer is complete
|
||||
//
|
||||
while(done == 0)
|
||||
{
|
||||
__asm(" NOP");
|
||||
}
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// adca1_isr - This is called after the very first conversion and will disable
|
||||
// the ePWM SOC to avoid re-triggering problems.
|
||||
//
|
||||
#pragma CODE_SECTION(adca1_isr, ".TI.ramfunc");
|
||||
__interrupt void adca1_isr(void)
|
||||
{
|
||||
//
|
||||
// Remove ePWM trigger
|
||||
//
|
||||
EPwm2Regs.ETSEL.bit.SOCAEN = 0;
|
||||
|
||||
//
|
||||
// Disable this interrupt from happening again
|
||||
//
|
||||
PieCtrlRegs.PIEIER1.bit.INTx1 = 0;
|
||||
|
||||
//
|
||||
// Acknowledge
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
}
|
||||
|
||||
//
|
||||
// dmach1_isr - This is called at the end of the DMA transfer, the conversions
|
||||
// are stopped by removing the trigger of the first SOC from
|
||||
// the last.
|
||||
//
|
||||
#pragma CODE_SECTION(dmach1_isr, ".TI.ramfunc");
|
||||
__interrupt void dmach1_isr(void)
|
||||
{
|
||||
//
|
||||
// Stop the ADC by removing the trigger for SOC0
|
||||
//
|
||||
EALLOW;
|
||||
AdcaRegs.ADCINTSOCSEL1.bit.SOC0 = 0;
|
||||
AdcbRegs.ADCINTSOCSEL1.bit.SOC0 = 0;
|
||||
EDIS;
|
||||
|
||||
done = 1;
|
||||
|
||||
//
|
||||
// Acknowledge
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP7;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ConfigureEPWM - Set up the ePWM2 module so that the A output has a period
|
||||
// of 40us with a 50% duty. The SOCA signal is coincident with
|
||||
// the rising edge of this.
|
||||
//
|
||||
void ConfigureEPWM(void)
|
||||
{
|
||||
//
|
||||
// Make the timer count up with a period of 40us
|
||||
//
|
||||
EPwm2Regs.TBCTL.all = 0x0000;
|
||||
EPwm2Regs.TBPRD = 4000;
|
||||
|
||||
//
|
||||
// Set the A output on zero and reset on CMPA
|
||||
//
|
||||
EPwm2Regs.AQCTLA.bit.ZRO = AQ_SET;
|
||||
EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR;
|
||||
|
||||
//
|
||||
// Set CMPA to 20us to get a 50% duty
|
||||
//
|
||||
EPwm2Regs.CMPA.bit.CMPA = 2000;
|
||||
|
||||
//
|
||||
// Start ADC when timer equals zero (note: don't enable yet)
|
||||
//
|
||||
EPwm2Regs.ETSEL.bit.SOCASEL = ET_CTR_ZERO;
|
||||
EPwm2Regs.ETPS.bit.SOCAPRD = ET_1ST;
|
||||
|
||||
//
|
||||
// Enable initialization of the SOCA event counter. Since we are
|
||||
// disabling the ETSEL.SOCAEN bit, we need a way to reset the SOCACNT.
|
||||
// Hence, enable the counter initialize control.
|
||||
//
|
||||
EPwm2Regs.ETCNTINITCTL.bit.SOCAINITEN = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureADC - Write ADC configurations and power up the ADC for both
|
||||
// ADC A and ADC B
|
||||
//
|
||||
void ConfigureADC(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Write prescale configurations
|
||||
//
|
||||
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; // Set ADCCLK divider to /4
|
||||
AdcbRegs.ADCCTL2.bit.PRESCALE = 6;
|
||||
|
||||
//
|
||||
// Set mode
|
||||
//
|
||||
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
|
||||
//
|
||||
// Power up the ADC
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADCs time to power up
|
||||
//
|
||||
DELAY_US(1000);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// SetupADCContinuous - setup the ADC to continuously convert on one channel
|
||||
//
|
||||
void SetupADCContinuous(volatile struct ADC_REGS * adcRegs, Uint16 channel)
|
||||
{
|
||||
Uint16 acqps;
|
||||
|
||||
//
|
||||
// Determine minimum acquisition window (in SYSCLKS) based on resolution
|
||||
//
|
||||
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
|
||||
{
|
||||
acqps = 14; // 75ns
|
||||
}
|
||||
else // Resolution is 16-bit
|
||||
{
|
||||
acqps = 63; // 320ns
|
||||
}
|
||||
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// SOCs will convert on same specified channel
|
||||
//
|
||||
adcRegs->ADCSOC0CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC1CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC2CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC3CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC4CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC5CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC6CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC7CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC8CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC9CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC10CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC11CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC12CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC13CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC14CTL.bit.CHSEL = channel;
|
||||
adcRegs->ADCSOC15CTL.bit.CHSEL = channel;
|
||||
|
||||
//
|
||||
// Sample window is acqps + 1 SYSCLK cycles
|
||||
//
|
||||
adcRegs->ADCSOC0CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC1CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC2CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC3CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC4CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC5CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC6CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC7CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC9CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC10CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC11CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC12CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC13CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC14CTL.bit.ACQPS = acqps;
|
||||
adcRegs->ADCSOC15CTL.bit.ACQPS = acqps;
|
||||
|
||||
//
|
||||
// Trigger SCO0 from EPWM2SOCA
|
||||
//
|
||||
adcRegs->ADCSOC0CTL.bit.TRIGSEL = 7;
|
||||
|
||||
//
|
||||
// Trigger all other SOCs from INT1 (EOC on SOC0)
|
||||
//
|
||||
adcRegs->ADCINTSOCSEL1.bit.SOC1 = 1;
|
||||
adcRegs->ADCINTSOCSEL1.bit.SOC2 = 1;
|
||||
adcRegs->ADCINTSOCSEL1.bit.SOC3 = 1;
|
||||
adcRegs->ADCINTSOCSEL1.bit.SOC4 = 1;
|
||||
adcRegs->ADCINTSOCSEL1.bit.SOC5 = 1;
|
||||
adcRegs->ADCINTSOCSEL1.bit.SOC6 = 1;
|
||||
adcRegs->ADCINTSOCSEL1.bit.SOC7 = 1;
|
||||
adcRegs->ADCINTSOCSEL2.bit.SOC8 = 1;
|
||||
adcRegs->ADCINTSOCSEL2.bit.SOC9 = 1;
|
||||
adcRegs->ADCINTSOCSEL2.bit.SOC10 = 1;
|
||||
adcRegs->ADCINTSOCSEL2.bit.SOC11 = 1;
|
||||
adcRegs->ADCINTSOCSEL2.bit.SOC12 = 1;
|
||||
adcRegs->ADCINTSOCSEL2.bit.SOC13 = 1;
|
||||
adcRegs->ADCINTSOCSEL2.bit.SOC14 = 1;
|
||||
adcRegs->ADCINTSOCSEL2.bit.SOC15 = 1;
|
||||
|
||||
adcRegs->ADCINTSEL1N2.bit.INT1E = 1; // Enable INT1 flag
|
||||
adcRegs->ADCINTSEL1N2.bit.INT2E = 1; // Enable INT2 flag
|
||||
adcRegs->ADCINTSEL3N4.bit.INT3E = 0; // Disable INT3 flag
|
||||
adcRegs->ADCINTSEL3N4.bit.INT4E = 0; // Disable INT4 flag
|
||||
|
||||
adcRegs->ADCINTSEL1N2.bit.INT1CONT = 1;
|
||||
adcRegs->ADCINTSEL1N2.bit.INT2CONT = 1;
|
||||
|
||||
adcRegs->ADCINTSEL1N2.bit.INT1SEL = 0; // End of SOC0
|
||||
adcRegs->ADCINTSEL1N2.bit.INT2SEL = 15; // End of SOC15
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// DMAInit - Initialize DMA ch 1 to transfer ADCA results and DMA ch 2 to
|
||||
// transfer ADCB results
|
||||
//
|
||||
void DMAInit(void)
|
||||
{
|
||||
//
|
||||
// Initialize DMA
|
||||
//
|
||||
DMAInitialize();
|
||||
|
||||
//
|
||||
// DMA set up for first ADC
|
||||
//
|
||||
DMACH1AddrConfig(adcData0, &AdcaResultRegs.ADCRESULT0);
|
||||
|
||||
//
|
||||
// Perform enough 16-word bursts to fill the results buffer. Data will be
|
||||
// transferred 32 bits at a time hence the address steps below.
|
||||
//
|
||||
// Enable the DMA channel 1 interrupt
|
||||
//
|
||||
DMACH1BurstConfig(15, 2, 2);
|
||||
DMACH1TransferConfig((RESULTS_BUFFER_SIZE >> 4) - 1, -14, 2);
|
||||
DMACH1ModeConfig(
|
||||
DMA_ADCAINT2,
|
||||
PERINT_ENABLE,
|
||||
ONESHOT_DISABLE,
|
||||
CONT_DISABLE,
|
||||
SYNC_DISABLE,
|
||||
SYNC_SRC,
|
||||
OVRFLOW_DISABLE,
|
||||
THIRTYTWO_BIT,
|
||||
CHINT_END,
|
||||
CHINT_ENABLE
|
||||
);
|
||||
|
||||
//
|
||||
// DMA set up for second ADC
|
||||
//
|
||||
DMACH2AddrConfig(adcData1, &AdcbResultRegs.ADCRESULT0);
|
||||
|
||||
//
|
||||
// Perform enough 16-word bursts to fill the results buffer. Data will be
|
||||
// transferred 32 bits at a time hence the address steps below.
|
||||
//
|
||||
DMACH2BurstConfig(15, 2, 2);
|
||||
DMACH2TransferConfig((RESULTS_BUFFER_SIZE >> 4) - 1, -14, 2);
|
||||
DMACH2ModeConfig(
|
||||
DMA_ADCAINT2,
|
||||
PERINT_ENABLE,
|
||||
ONESHOT_DISABLE,
|
||||
CONT_DISABLE,
|
||||
SYNC_DISABLE,
|
||||
SYNC_SRC,
|
||||
OVRFLOW_DISABLE,
|
||||
THIRTYTWO_BIT,
|
||||
CHINT_END,
|
||||
CHINT_DISABLE
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,291 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex7_ppb_offset.c
|
||||
//
|
||||
// TITLE: ADC offset adjust using post-processing block for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> ADC PPB Offset (adc_ppb_offset)</h1>
|
||||
//!
|
||||
//! This example software triggers the ADC. Some SOCs have automatic offset
|
||||
//! adjustment applied by the post-processing block.
|
||||
//!
|
||||
//! After the program runs, the memory will contain:\n
|
||||
//!
|
||||
//! - \b AdcaResult \b: a digital representation of the voltage on pin A0
|
||||
//! - \b AdcaResult_offsetAdjusted \b : a digital representation of the voltage
|
||||
//! on pin A0, minus 100 LSBs of automatically added offset
|
||||
//! - \b AdcbResult \b: a digital representation of the voltage on pin B0
|
||||
//! - \b AdcbResult_offsetAdjusted \b : a digital representation of the voltage
|
||||
//! on pin B0 plus 100 LSBs of automatically added offset
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void ConfigureADC(void);
|
||||
void SetupADCSoftware(void);
|
||||
void SetupPPBOffset(int16 aOffset, int16 bOffset);
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 AdcaResult;
|
||||
Uint16 AdcaResult_offsetAdjusted;
|
||||
Uint16 AdcbResult;
|
||||
Uint16 AdcbResult_offsetAdjusted;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitGpio();
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Configure the ADCs and power them up
|
||||
//
|
||||
ConfigureADC();
|
||||
|
||||
//
|
||||
// Setup the ADCs for software conversions
|
||||
//
|
||||
SetupADCSoftware();
|
||||
|
||||
//
|
||||
// Setup PPB offset correction.
|
||||
// conversion on channel A will subtract 100.
|
||||
// conversion on channel B will add 100.
|
||||
//
|
||||
SetupPPBOffset(100, -100);
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Convert, wait for completion, and store results.
|
||||
// Start conversions immediately via software, ADCA
|
||||
//
|
||||
AdcaRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
|
||||
|
||||
//
|
||||
// Start conversions immediately via software, ADCB
|
||||
//
|
||||
AdcbRegs.ADCSOCFRC1.all = 0x0003; //SOC0 and SOC1
|
||||
|
||||
//
|
||||
// Wait for ADCA to complete, then acknowledge flag
|
||||
//
|
||||
while(AdcaRegs.ADCINTFLG.bit.ADCINT1 == 0);
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
|
||||
//
|
||||
// Wait for ADCB to complete, then acknowledge flag
|
||||
//
|
||||
while(AdcbRegs.ADCINTFLG.bit.ADCINT1 == 0);
|
||||
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
|
||||
//
|
||||
// Store results
|
||||
//
|
||||
AdcaResult = AdcaResultRegs.ADCRESULT0;
|
||||
AdcaResult_offsetAdjusted = AdcaResultRegs.ADCRESULT1;
|
||||
AdcbResult = AdcbResultRegs.ADCRESULT0;
|
||||
AdcbResult_offsetAdjusted = AdcbResultRegs.ADCRESULT1;
|
||||
|
||||
//
|
||||
// Software breakpoint, hit run again to get updated conversions
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
|
||||
} while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureADC - Write ADC configurations and power up the ADC for both
|
||||
// ADC A and ADC B
|
||||
//
|
||||
void ConfigureADC(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Write configurations
|
||||
//
|
||||
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
|
||||
AdcbRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
|
||||
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
|
||||
//
|
||||
// Power up the ADCs
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DELAY_US(1000);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// SetupADCSoftware - Configure ADC SOC and acquisition window
|
||||
//
|
||||
void SetupADCSoftware(void)
|
||||
{
|
||||
Uint16 acqps;
|
||||
|
||||
//
|
||||
// Determine minimum acquisition window (in SYSCLKS) based on resolution
|
||||
//
|
||||
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
|
||||
{
|
||||
acqps = 14; //75ns
|
||||
}
|
||||
else //resolution is 16-bit
|
||||
{
|
||||
acqps = 63; //320ns
|
||||
}
|
||||
|
||||
//
|
||||
// Select the channels to convert and end of conversion flag
|
||||
// ADCA
|
||||
//
|
||||
EALLOW;
|
||||
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A0
|
||||
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is 100 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 0; //SOC1 will convert pin A0
|
||||
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is 100 SYSCLK cycles
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
|
||||
//
|
||||
// ADCB
|
||||
//
|
||||
AdcbRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin B0
|
||||
AdcbRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is 100 SYSCLK cycles
|
||||
AdcbRegs.ADCSOC1CTL.bit.CHSEL = 0; //SOC1 will convert pin B0
|
||||
AdcbRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is 100 SYSCLK cycles
|
||||
AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
|
||||
AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
|
||||
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// SetupPPBOffset - Configure PPB for SOC
|
||||
//
|
||||
void SetupPPBOffset(int16 aOffset, int16 bOffset)
|
||||
{
|
||||
EALLOW;
|
||||
AdcaRegs.ADCPPB1CONFIG.bit.CONFIG = 1; //PPB1 is associated with SOC1
|
||||
AdcaRegs.ADCPPB1OFFCAL.all = aOffset; //PPB1 will subtract OFFCAL value
|
||||
//to associated SOC
|
||||
|
||||
AdcbRegs.ADCPPB1CONFIG.bit.CONFIG = 1; //PPB1 is associated with SOC1
|
||||
AdcbRegs.ADCPPB1OFFCAL.all = bOffset; //PPB1 will subtract OFFCAL value
|
||||
//to associated SOC
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,323 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex8_ppb_limits.c
|
||||
//
|
||||
// TITLE: ADC limits check using post-processing block for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> ADC PPB Limits (adc_ppb_limits)</h1>
|
||||
//!
|
||||
//! This example sets up the ePWM to periodically trigger the ADC. If the
|
||||
//! results are outside of the defined range, the post-processing block
|
||||
//! will generate an interrupt.
|
||||
//!
|
||||
//! The default limits are 1000LSBs and 3000LSBs. With VREFHI set to 3.3V, the
|
||||
//! PPB will generate an interrupt if the input voltage goes above about
|
||||
//! 2.4V or below about 0.8V.
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Functional Prototypes
|
||||
//
|
||||
void ConfigureADC(void);
|
||||
void ConfigureEPWM(void);
|
||||
void ConfigurePPB1Limits(Uint16 soc, Uint16 limitHigh, Uint16 limitLow);
|
||||
void SetupADCEpwm(Uint16 channel);
|
||||
interrupt void adca_ppb_isr(void);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitGpio(); // Skipped for this example
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Map ISR functions
|
||||
//
|
||||
EALLOW;
|
||||
PieVectTable.ADCA_EVT_INT = &adca_ppb_isr; //function for ADCA PPB
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Configure the ADC and power it up
|
||||
//
|
||||
ConfigureADC();
|
||||
|
||||
//
|
||||
// Configure the ePWM
|
||||
//
|
||||
ConfigureEPWM();
|
||||
|
||||
//
|
||||
// Setup the ADC for ePWM triggered conversions on channel 0
|
||||
//
|
||||
SetupADCEpwm(0);
|
||||
|
||||
//
|
||||
// Configure ADC post-processing limits
|
||||
// SOC0 will generate an interrupt if conversion is above or below limits
|
||||
//
|
||||
ConfigurePPB1Limits(0,3000,1000);
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
IER |= M_INT10; //Enable group 10 interrupts
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Enable PIE interrupt
|
||||
//
|
||||
PieCtrlRegs.PIEIER10.bit.INTx1 = 1;
|
||||
|
||||
//
|
||||
// Start ePWM
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 1; //enable SOCA
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 0; //unfreeze, and enter up count mode
|
||||
|
||||
//
|
||||
// Take conversions indefinitely in loop
|
||||
//
|
||||
do
|
||||
{
|
||||
//
|
||||
// Wait while ePWM causes ADC conversions.
|
||||
// If the ADC conversions exceed the PPB limits, then an interrupt
|
||||
// will be generated
|
||||
//
|
||||
} while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureADC - Write ADC configurations and power up the ADC for both
|
||||
// ADC A and ADC B
|
||||
//
|
||||
void ConfigureADC(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Write configurations
|
||||
//
|
||||
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
|
||||
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
|
||||
//
|
||||
// Power up the ADC
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DELAY_US(1000);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureEPWM - Setup SOC and compare values for EPWM
|
||||
//
|
||||
void ConfigureEPWM(void)
|
||||
{
|
||||
EALLOW;
|
||||
//
|
||||
// Assumes ePWM clock is already enabled
|
||||
//
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 0; // Disable SOC on A group
|
||||
EPwm1Regs.ETSEL.bit.SOCASEL = 4; // Select SOC on up-count
|
||||
EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
|
||||
EPwm1Regs.CMPA.bit.CMPA = 0x0800; // Set compare A value to 2048 counts
|
||||
EPwm1Regs.TBPRD = 0x1000; // Set period to 4096 counts
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 3; // freeze counter
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigurePPB1Limits - Configure high and low limits for ADCPPB
|
||||
//
|
||||
void ConfigurePPB1Limits(Uint16 soc, Uint16 limitHigh, Uint16 limitLow)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
AdcaRegs.ADCPPB1CONFIG.bit.CONFIG = soc; //PPB1 is associated with soc
|
||||
|
||||
//
|
||||
// Set high and low limits
|
||||
//
|
||||
AdcaRegs.ADCPPB1TRIPHI.bit.LIMITHI = limitHigh;
|
||||
AdcaRegs.ADCPPB1TRIPLO.bit.LIMITLO = limitLow;
|
||||
|
||||
//
|
||||
// Enable high and low limit events to generate interrupt
|
||||
//
|
||||
AdcaRegs.ADCEVTINTSEL.bit.PPB1TRIPHI = 1;
|
||||
AdcaRegs.ADCEVTINTSEL.bit.PPB1TRIPLO = 1;
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// SetupADCEpwm - Setup ADC EPWM channel and trigger settings
|
||||
//
|
||||
void SetupADCEpwm(Uint16 channel)
|
||||
{
|
||||
Uint16 acqps;
|
||||
|
||||
//
|
||||
// Determine minimum acquisition window (in SYSCLKS) based on resolution
|
||||
//
|
||||
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
|
||||
{
|
||||
acqps = 14; //75ns
|
||||
}
|
||||
else //resolution is 16-bit
|
||||
{
|
||||
acqps = 63; //320ns
|
||||
}
|
||||
|
||||
//
|
||||
// Select the channels to convert and setup end of conversion flag
|
||||
// ADCA
|
||||
//
|
||||
EALLOW;
|
||||
AdcaRegs.ADCSOC0CTL.bit.CHSEL = channel; //SOC0 will convert pin A0
|
||||
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is 100 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC0 will set INT1 flag
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// adca_ppb_isr - ISR for ADCA PPB
|
||||
//
|
||||
interrupt void adca_ppb_isr(void)
|
||||
{
|
||||
//
|
||||
// Warning, you are outside of PPB limits
|
||||
//
|
||||
if(AdcaRegs.ADCEVTSTAT.bit.PPB1TRIPHI)
|
||||
{
|
||||
//
|
||||
// Voltage exceeded high limit
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
|
||||
//
|
||||
// Clear the trip flag and continue
|
||||
//
|
||||
AdcaRegs.ADCEVTCLR.bit.PPB1TRIPHI = 1;
|
||||
}
|
||||
if(AdcaRegs.ADCEVTSTAT.bit.PPB1TRIPLO)
|
||||
{
|
||||
//
|
||||
// Voltage exceeded low limit
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
|
||||
//
|
||||
// Clear the trip flag and continue
|
||||
//
|
||||
AdcaRegs.ADCEVTCLR.bit.PPB1TRIPLO = 1;
|
||||
}
|
||||
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP10;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,390 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: adc_ex9_ppb_delay.c
|
||||
//
|
||||
// TITLE: Post-Processing delay capture for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> ADC PPB Delay Capture (adc_ppb_delay)</h1>
|
||||
//!
|
||||
//! This example demonstrates delay capture using the post-processing block.
|
||||
//!
|
||||
//! Two asynchronous ADC triggers are setup:\n
|
||||
//! - ePWM1, with period 2048, triggering SOC0 to convert on pin A0\n
|
||||
//! - ePWM1, with period 9999, triggering SOC1 to convert on pin A1\n
|
||||
//!
|
||||
//! Each conversion generates an ISR at the end of the conversion. In the
|
||||
//! ISR for SOC0, a conversion counter is incremented and the PPB is checked
|
||||
//! to determine if the sample was delayed.\n
|
||||
//!
|
||||
//! After the program runs, the memory will contain:\n
|
||||
//! - \b conversion \b: the sequence of conversions using SOC0 that were delayed
|
||||
//! - \b delay \b: the corresponding delay of each of the delayed conversions
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void ConfigureADC(void);
|
||||
void ConfigureEPWM(void);
|
||||
void SetupADCEpwm(Uint16 channel1, Uint16 channel2);
|
||||
interrupt void adca1_isr(void);
|
||||
interrupt void adca2_isr(void);
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define DELAY_BUFFER_SIZE 30
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint32 conversion_count;
|
||||
Uint32 conversion[DELAY_BUFFER_SIZE];
|
||||
Uint16 delay[DELAY_BUFFER_SIZE];
|
||||
volatile Uint16 delay_index;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitGpio(); // Skipped for this example
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Map ISR functions
|
||||
//
|
||||
EALLOW;
|
||||
PieVectTable.ADCA1_INT = &adca1_isr; //function for ADCA interrupt 1
|
||||
PieVectTable.ADCA2_INT = &adca2_isr; //function for ADCA interrupt 2
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Configure the ADC and power it up
|
||||
//
|
||||
ConfigureADC();
|
||||
|
||||
//
|
||||
// Configure ePWM1 and ePWM2 with asynchronous periods
|
||||
//
|
||||
ConfigureEPWM();
|
||||
|
||||
//
|
||||
// Setup the ADC for ePWM triggered conversions on channel 0 and 1
|
||||
//
|
||||
SetupADCEpwm(0,1);
|
||||
|
||||
//
|
||||
// Setup the post-processing block to be associated with SOC0
|
||||
//
|
||||
AdcaRegs.ADCPPB1CONFIG.bit.CONFIG = 0;
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
IER |= M_INT1; //Enable group 1 interrupts
|
||||
IER |= M_INT10; //Enable group 1 interrupts
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Enable PIE interrupt
|
||||
//
|
||||
PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
|
||||
PieCtrlRegs.PIEIER10.bit.INTx2 = 1;
|
||||
|
||||
//
|
||||
// Initialize program variables
|
||||
//
|
||||
conversion_count = 0;
|
||||
for(delay_index = 0; delay_index < DELAY_BUFFER_SIZE; delay_index++)
|
||||
{
|
||||
delay[delay_index] = 0;
|
||||
conversion[delay_index] = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Start ePWMs
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 1; //enable SOCA
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 0; //unfreeze, and enter up count mode
|
||||
EPwm2Regs.ETSEL.bit.SOCAEN = 1; //enable SOCA
|
||||
EPwm2Regs.TBCTL.bit.CTRMODE = 0; //unfreeze, and enter up count mode
|
||||
|
||||
do
|
||||
{
|
||||
delay_index = 0;
|
||||
|
||||
//
|
||||
// Wait for list of delayed conversions to fill via interrupts
|
||||
//
|
||||
while(DELAY_BUFFER_SIZE > delay_index){}
|
||||
|
||||
//
|
||||
// Software breakpoint
|
||||
//
|
||||
asm(" ESTOP0");
|
||||
|
||||
//
|
||||
// conversion[] will show which conversions were delayed
|
||||
// delay[] will show how long each conversion was delayed
|
||||
// conversion_count will show total number of conversions
|
||||
// conversion_count - DELAY_BUFFER_SIZE is the number of samples
|
||||
// that started immediately without any delay
|
||||
//
|
||||
} while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureADC - Write ADC configurations and power up the ADC for both
|
||||
// ADC A and ADC B
|
||||
//
|
||||
void ConfigureADC(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Write configurations
|
||||
//
|
||||
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
|
||||
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
|
||||
//
|
||||
// Power up the ADC
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
|
||||
//
|
||||
// Delay for 1ms to allow ADC time to power up
|
||||
//
|
||||
DELAY_US(1000);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// ConfigureEPWM - setup PWM1 and PWM2 with asynchronous periods
|
||||
//
|
||||
void ConfigureEPWM(void)
|
||||
{
|
||||
EALLOW;
|
||||
//
|
||||
// Assumes ePWM clock is already enabled
|
||||
//
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 0; // Disable SOC on A group
|
||||
EPwm1Regs.ETSEL.bit.SOCASEL = 4; // Select SOC on up-count
|
||||
EPwm1Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
|
||||
EPwm1Regs.CMPA.bit.CMPA = 0x0400; // Set compare A value to 1024 counts
|
||||
EPwm1Regs.TBPRD = 0x0800; // Set period to 2048 counts
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 3; // freeze counter
|
||||
|
||||
//
|
||||
// Assumes ePWM clock is already enabled
|
||||
//
|
||||
EPwm2Regs.ETSEL.bit.SOCAEN = 0; // Disable SOC on A group
|
||||
EPwm2Regs.ETSEL.bit.SOCASEL = 4; // Select SOC on up-count
|
||||
EPwm2Regs.ETPS.bit.SOCAPRD = 1; // Generate pulse on 1st event
|
||||
EPwm2Regs.CMPA.bit.CMPA = 0x0400; // Set compare A value to 1024 counts
|
||||
EPwm2Regs.TBPRD = 9999; // Set period to 9999 counts
|
||||
EPwm2Regs.TBCTL.bit.CTRMODE = 3; // freeze counter
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// SetupADCEpwm - Setup ADC SOC for EPWM
|
||||
//
|
||||
void SetupADCEpwm(Uint16 channel1, Uint16 channel2)
|
||||
{
|
||||
Uint16 acqps;
|
||||
|
||||
//
|
||||
// Determine minimum acquisition window (in SYSCLKS) based on resolution
|
||||
//
|
||||
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
|
||||
{
|
||||
acqps = 14; //75ns
|
||||
}
|
||||
else //resolution is 16-bit
|
||||
{
|
||||
acqps = 63; //320ns
|
||||
}
|
||||
|
||||
//
|
||||
//Select the channels to convert and setup the end of conversion flag
|
||||
//ADCA
|
||||
//
|
||||
EALLOW;
|
||||
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A0
|
||||
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 1; //SOC1 will convert pin A1
|
||||
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is 100 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is 100 SYSCLK cycles
|
||||
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
|
||||
AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = 7; //trigger on ePWM2 SOCA/C
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC0 will set INT1 flag
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT2SEL = 1; //end of SOC1 will set INT1 flag
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT2E = 1; //enable INT2 flag
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// adca1_isr - ADCA1 Interrupt Service Routine
|
||||
//
|
||||
interrupt void adca1_isr(void)
|
||||
{
|
||||
//
|
||||
// DLYSTAMP will read 2 if the sample was not delayed
|
||||
//
|
||||
if(2 < AdcaRegs.ADCPPB1STAMP.bit.DLYSTAMP)
|
||||
{
|
||||
//
|
||||
// If DLYSTAMP > 2, then the sample was delayed by (DLYSTAMP - 2)
|
||||
// cycles (SYSCLK)
|
||||
//
|
||||
conversion[delay_index] = conversion_count;
|
||||
delay[delay_index] = AdcaRegs.ADCPPB1STAMP.bit.DLYSTAMP - 2;
|
||||
delay_index++;
|
||||
|
||||
//
|
||||
// Corrective action(s) for delayed sample can occur here
|
||||
//...
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// Read ADC sample here
|
||||
//...
|
||||
//
|
||||
|
||||
conversion_count++;
|
||||
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
|
||||
|
||||
//
|
||||
// Check if overflow has occurred
|
||||
//
|
||||
if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT1)
|
||||
{
|
||||
AdcaRegs.ADCINTOVFCLR.bit.ADCINT1 = 1; //clear INT1 overflow flag
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
|
||||
}
|
||||
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
}
|
||||
|
||||
//
|
||||
// adca2_isr - ADCA2 Interrupt Service Routine
|
||||
//
|
||||
interrupt void adca2_isr(void)
|
||||
{
|
||||
//
|
||||
// Read ADC sample here
|
||||
//...
|
||||
//
|
||||
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; //clear INT2 flag
|
||||
|
||||
//
|
||||
// Check if overflow has occurred
|
||||
//
|
||||
if(1 == AdcaRegs.ADCINTOVF.bit.ADCINT2)
|
||||
{
|
||||
AdcaRegs.ADCINTOVFCLR.bit.ADCINT2 = 1; //clear INT2 overflow flag
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT2 = 1; //clear INT2 flag
|
||||
}
|
||||
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP10;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,31 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex1_asin"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../cla_ex1_asin.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex1_asin_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex1_asin_shared.h" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,31 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex2_atan"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../cla_ex2_atan.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex2_atan_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex2_atan_shared.h" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cla_ex3_background_task"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --cla_signed_compare_workaround=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --cla_signed_compare_workaround=on --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_adc.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../cla_ex3_background_task.c" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex3_background_task_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../cla_ex3_background_task_shared.h" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,536 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: cla_ex1_asin.c
|
||||
//
|
||||
// TITLE: CLA Arcsine Example
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1>CLA \f$arcsine(x)\f$ using a lookup table (cla_asin_cpu01)</h1>
|
||||
//!
|
||||
//! In this example, Task 1 of the CLA will calculate the arcsine of
|
||||
//! an input argument in the range (-1.0 to 1.0) using a lookup table.
|
||||
//!
|
||||
//! \b Memory \b Allocation \n
|
||||
//! - CLA1 Math Tables (RAMLS0)
|
||||
//! - CLAasinTable - Lookup table
|
||||
//! - CLA1 to CPU Message RAM
|
||||
//! - fResult - Result of the lookup algorithm
|
||||
//! - CPU to CLA1 Message RAM
|
||||
//! - fVal - Sample input to the lookup algorithm
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - fVal - Argument to task 1
|
||||
//! - fResult - Result of \f$arcsin(fVal)\f$
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "cla_ex1_asin_shared.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define WAITSTEP asm(" RPT #255 || NOP")
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
// NOTE: Do not initialize the Message RAM variables globally, they will be
|
||||
// reset during the message ram initialization phase in the CLA memory
|
||||
// configuration routine
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
#pragma DATA_SECTION("CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION("Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
#else
|
||||
#pragma DATA_SECTION(fVal,"CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION(fResult,"Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
#endif //__cplusplus
|
||||
float y[BUFFER_SIZE];
|
||||
|
||||
//
|
||||
//Task 2 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 3 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 4 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 5 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 6 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 7 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 8 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Common (C) Variables
|
||||
//The Exponential table
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
#pragma DATA_SECTION("CLADataLS0")
|
||||
#else
|
||||
#pragma DATA_SECTION(CLAasinTable,"CLADataLS0")
|
||||
#endif //__cplusplus
|
||||
float CLAasinTable[]={
|
||||
0.0, 1.0, 0.0,
|
||||
0.000000636202, 0.999877862610, 0.007815361896,
|
||||
0.000005099694, 0.999510644409, 0.015647916155,
|
||||
0.000017268312, 0.998895919094, 0.023514960332,
|
||||
0.000041121765, 0.998029615282, 0.031434003631,
|
||||
0.000080794520, 0.996905974725, 0.039422875916,
|
||||
0.000140631089, 0.995517492804, 0.047499840611,
|
||||
0.000225244584, 0.993854840311, 0.055683712914,
|
||||
0.000339579512, 0.991906765146, 0.063993984848,
|
||||
0.000488979852, 0.989659972212, 0.072450958820,
|
||||
0.000679263611, 0.987098979366, 0.081075891529,
|
||||
0.000916805182, 0.984205946802, 0.089891150305,
|
||||
0.001208627040, 0.980960476685, 0.098920384204,
|
||||
0.001562502549, 0.977339379243, 0.108188712551,
|
||||
0.001987071928, 0.973316400729, 0.117722933997,
|
||||
0.002491973784, 0.968861907789, 0.127551759665,
|
||||
0.003087995053, 0.963942521723, 0.137706074532,
|
||||
0.003787242692, 0.958520694794, 0.148219231941,
|
||||
0.004603341138, 0.952554219267, 0.159127386977,
|
||||
0.005551660294, 0.945995657913, 0.170469875522,
|
||||
0.006649579796, 0.938791682505, 0.182289647088,
|
||||
0.007916796475, 0.930882303984, 0.194633761132,
|
||||
0.009375683410, 0.922199974574, 0.207553958472,
|
||||
0.011051710808, 0.912668537890, 0.221107321885,
|
||||
0.012973941175, 0.902201997769, 0.235357042896,
|
||||
0.015175614174, 0.890703070035, 0.250373315541,
|
||||
0.017694840102, 0.878061473098, 0.266234382514,
|
||||
0.020575425537, 0.864151902887, 0.283027765009,
|
||||
0.023867860513, 0.848831624374, 0.300851714968,
|
||||
0.027630504055, 0.831937595031, 0.319816937941,
|
||||
0.031931014547, 0.813283013821, 0.340048646894,
|
||||
0.036848083955, 0.792653161200, 0.361689022958,
|
||||
0.042473551274, 0.769800358920, 0.384900179460,
|
||||
0.048914992206, 0.744437830278, 0.409867752228,
|
||||
0.056298910750, 0.716232177740, 0.436805274317,
|
||||
0.064774696786, 0.684794109766, 0.465959540059,
|
||||
0.074519565699, 0.649666934178, 0.497617226179,
|
||||
0.085744766889, 0.610312179660, 0.532113122767,
|
||||
0.098703445606, 0.566091493186, 0.569840443472,
|
||||
0.113700678529, 0.516243664372, 0.611263845480,
|
||||
0.131106395009, 0.459855210927, 0.656936015611,
|
||||
0.151372169232, 0.395822366759, 0.707518998893,
|
||||
0.175053263659, 0.322801460177, 0.763811905770,
|
||||
0.202837883870, 0.239143420888, 0.826787304376,
|
||||
0.235586468765, 0.142806299514, 0.897639596948,
|
||||
0.274385149825, 0.031236880585, 0.977850174820,
|
||||
0.320619535938, -0.098791845166, 1.069276441800,
|
||||
0.376078169620, -0.251407364538, 1.174275392129,
|
||||
0.443100143614, -0.431959397725, 1.295878193174,
|
||||
0.524789871827, -0.647485610469, 1.438041695773,
|
||||
0.625336471263, -0.907400624736, 1.606018804842,
|
||||
0.750500589935, -1.224540947101, 1.806917563896,
|
||||
0.908377657341, -1.616794995066, 2.050569262035,
|
||||
1.110633894185, -2.109729648039, 2.350920816737,
|
||||
1.374584721437, -2.740985157716, 2.728353889708,
|
||||
1.726848242753, -3.567962877198, 3.213722960014,
|
||||
2.210117561056, -4.682006534082, 3.855770086891,
|
||||
2.896554011854, -6.236312386687, 4.735651038017,
|
||||
3.916505715382, -8.505488022524, 5.997790945975,
|
||||
5.526855868703, -12.026617159136, 7.922628470498,
|
||||
8.298197116322, -17.983705080358, 11.123941286820,
|
||||
13.741706072449, -29.488929624542, 17.203344479111,
|
||||
27.202707817485, -57.466598393615, 31.741016484669,
|
||||
83.158101335898, -171.803399517566, 90.149831709374
|
||||
};
|
||||
|
||||
float asin_expected[BUFFER_SIZE]={
|
||||
1.570796, 1.393789, 1.320141, 1.263401, 1.215375,
|
||||
1.172892, 1.134327, 1.098718, 1.065436, 1.034046,
|
||||
1.004232, 0.9757544, 0.9484279, 0.9221048, 0.8966658,
|
||||
0.8720123, 0.8480621, 0.8247454, 0.8020028, 0.7797828,
|
||||
0.7580408, 0.7367374, 0.7158381, 0.6953120, 0.6751316,
|
||||
0.6552721, 0.6357113, 0.6164289, 0.5974064, 0.5786270,
|
||||
0.5600753, 0.5417370, 0.5235988, 0.5056486, 0.4878751,
|
||||
0.4702678, 0.4528166, 0.4355124, 0.4183464, 0.4013104,
|
||||
0.3843968, 0.3675981, 0.3509074, 0.3343180, 0.3178237,
|
||||
0.3014185, 0.2850964, 0.2688521, 0.2526802, 0.2365756,
|
||||
0.2205333, 0.2045484, 0.1886164, 0.1727327, 0.1568929,
|
||||
0.1410927, 0.1253278, 0.1095943, 0.09388787, 0.07820469,
|
||||
0.06254076, 0.04689218, 0.03125509, 0.01562564
|
||||
};
|
||||
|
||||
uint16_t pass=0;
|
||||
uint16_t fail=0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void CLA_runTest(void);
|
||||
void CLA_configClaMemory(void);
|
||||
void CLA_initCpu1Cla1(void);
|
||||
__interrupt void cla1Isr1();
|
||||
__interrupt void cla1Isr2();
|
||||
__interrupt void cla1Isr3();
|
||||
__interrupt void cla1Isr4();
|
||||
__interrupt void cla1Isr5();
|
||||
__interrupt void cla1Isr6();
|
||||
__interrupt void cla1Isr7();
|
||||
__interrupt void cla1Isr8();
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the <device>_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the <device>_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the default Interrupt
|
||||
// Service Routines (ISR).
|
||||
// The default ISR routines are found in <device>_defaultisr.c.
|
||||
// This function is found in <device>_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Step 3. Configure the CLA memory spaces first followed by
|
||||
// the CLA task vectors
|
||||
//
|
||||
CLA_configClaMemory();
|
||||
CLA_initCpu1Cla1();
|
||||
|
||||
//
|
||||
// Step 4. Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Step 5. Run the test
|
||||
//
|
||||
CLA_runTest();
|
||||
|
||||
for(;;)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CLA_runTest - Execute CLA task tests for specified vectors
|
||||
//
|
||||
void CLA_runTest(void)
|
||||
{
|
||||
int16_t i;
|
||||
float error;
|
||||
|
||||
for(i=0; i < BUFFER_SIZE; i++)
|
||||
{
|
||||
fVal= (float)(BUFFER_SIZE - i)/(float)BUFFER_SIZE;
|
||||
Cla1ForceTask1andWait();
|
||||
|
||||
y[i] = fResult;
|
||||
error = fabsf(asin_expected[i]-y[i]);
|
||||
|
||||
if(error < 0.1f)
|
||||
{
|
||||
pass++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CLA tasks 2-8 are not used in this example
|
||||
//
|
||||
#if 0
|
||||
Cla1ForceTask2andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask3andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask4andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask5andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask6andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask7andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask8andWait();
|
||||
WAITSTEP;
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// CLA_configClaMemory - Configure CLA memory sections
|
||||
//
|
||||
void CLA_configClaMemory(void)
|
||||
{
|
||||
extern uint32_t Cla1funcsRunStart, Cla1funcsLoadStart, Cla1funcsLoadSize;
|
||||
EALLOW;
|
||||
|
||||
#ifdef _FLASH
|
||||
//
|
||||
// Copy over code from FLASH to RAM
|
||||
//
|
||||
memcpy((uint32_t *)&Cla1funcsRunStart, (uint32_t *)&Cla1funcsLoadStart,
|
||||
(uint32_t)&Cla1funcsLoadSize);
|
||||
#endif //_FLASH
|
||||
|
||||
//
|
||||
// Initialize and wait for CLA1ToCPUMsgRAM
|
||||
//
|
||||
MemCfgRegs.MSGxINIT.bit.INIT_CLA1TOCPU = 1;
|
||||
while(MemCfgRegs.MSGxINITDONE.bit.INITDONE_CLA1TOCPU != 1){};
|
||||
|
||||
//
|
||||
// Initialize and wait for CPUToCLA1MsgRAM
|
||||
//
|
||||
MemCfgRegs.MSGxINIT.bit.INIT_CPUTOCLA1 = 1;
|
||||
while(MemCfgRegs.MSGxINITDONE.bit.INITDONE_CPUTOCLA1 != 1){};
|
||||
|
||||
//
|
||||
// Select LS5RAM to be the programming space for the CLA
|
||||
// First configure the CLA to be the master for LS5 and then
|
||||
// set the space to be a program block
|
||||
//
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS5 = 1;
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS5 = 1;
|
||||
|
||||
//
|
||||
// Next configure LS0RAM and LS1RAM as data spaces for the CLA
|
||||
// First configure the CLA to be the master for LS0(1) and then
|
||||
// set the spaces to be code blocks
|
||||
//
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS0 = 1;
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS0 = 0;
|
||||
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS1 = 1;
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS1 = 0;
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// CLA_initCpu1Cla1 - Initialize CLA1 task vectors and end of task interrupts
|
||||
//
|
||||
void CLA_initCpu1Cla1(void)
|
||||
{
|
||||
//
|
||||
// Suppressing #770-D conversion from pointer to smaller integer
|
||||
// The CLA address range is 16 bits so the addresses passed to the MVECT
|
||||
// registers will be in the lower 64KW address space. Turn the warning
|
||||
// back on after the MVECTs are assigned addresses
|
||||
//
|
||||
#pragma diag_suppress=770
|
||||
EALLOW;
|
||||
Cla1Regs.MVECT1 = (uint16_t)(&Cla1Task1);
|
||||
Cla1Regs.MVECT2 = (uint16_t)(&Cla1Task2);
|
||||
Cla1Regs.MVECT3 = (uint16_t)(&Cla1Task3);
|
||||
Cla1Regs.MVECT4 = (uint16_t)(&Cla1Task4);
|
||||
Cla1Regs.MVECT5 = (uint16_t)(&Cla1Task5);
|
||||
Cla1Regs.MVECT6 = (uint16_t)(&Cla1Task6);
|
||||
Cla1Regs.MVECT7 = (uint16_t)(&Cla1Task7);
|
||||
Cla1Regs.MVECT8 = (uint16_t)(&Cla1Task8);
|
||||
#pragma diag_warning=770
|
||||
|
||||
//
|
||||
// Enable the IACK instruction to start a task on CLA in software
|
||||
// for all 8 CLA tasks. Also, globally enable all 8 tasks (or a
|
||||
// subset of tasks) by writing to their respective bits in the
|
||||
// MIER register
|
||||
//
|
||||
Cla1Regs.MCTL.bit.IACKE = 1;
|
||||
Cla1Regs.MIER.all = 0x00FF;
|
||||
|
||||
//
|
||||
// Configure the vectors for the end-of-task interrupt for all
|
||||
// 8 tasks
|
||||
//
|
||||
PieVectTable.CLA1_1_INT = &cla1Isr1;
|
||||
PieVectTable.CLA1_2_INT = &cla1Isr2;
|
||||
PieVectTable.CLA1_3_INT = &cla1Isr3;
|
||||
PieVectTable.CLA1_4_INT = &cla1Isr4;
|
||||
PieVectTable.CLA1_5_INT = &cla1Isr5;
|
||||
PieVectTable.CLA1_6_INT = &cla1Isr6;
|
||||
PieVectTable.CLA1_7_INT = &cla1Isr7;
|
||||
PieVectTable.CLA1_8_INT = &cla1Isr8;
|
||||
|
||||
//
|
||||
// Enable CLA interrupts at the group and subgroup levels
|
||||
//
|
||||
PieCtrlRegs.PIEIER11.all = 0xFFFF;
|
||||
IER |= (M_INT11 );
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 1
|
||||
//
|
||||
__interrupt void cla1Isr1 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 1
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = M_INT11;
|
||||
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr2 - CLA1 ISR 2
|
||||
//
|
||||
__interrupt void cla1Isr2 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr3 - CLA1 ISR 3
|
||||
//
|
||||
__interrupt void cla1Isr3 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr4 - CLA1 ISR 4
|
||||
//
|
||||
__interrupt void cla1Isr4 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr5 - CLA1 ISR 5
|
||||
//
|
||||
__interrupt void cla1Isr5 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr6 - CLA1 ISR 6
|
||||
//
|
||||
__interrupt void cla1Isr6 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr7 - CLA1 ISR 7
|
||||
//
|
||||
__interrupt void cla1Isr7 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr8 - CLA1 ISR 8
|
||||
//
|
||||
__interrupt void cla1Isr8 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 8
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = M_INT11;
|
||||
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,165 @@
|
||||
//#############################################################################
|
||||
// \file cla_ex1_asin_cla.cla
|
||||
//
|
||||
// \brief Arc Sine Example
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "cla_ex1_asin_shared.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
// Note that the globals defined in the .cla source are global to the cla source
|
||||
// file. i.e. they may be shared across tasks. All of the data shared between
|
||||
// the CLA and the C28x CPU must be defined in the C (or C++) code, and not the
|
||||
// CLA code.
|
||||
//
|
||||
|
||||
//
|
||||
// Function Definitions
|
||||
//
|
||||
//Task 1 : Calculate asin(X)
|
||||
// Description:
|
||||
// Step(1): Calculate absolute of the input X
|
||||
//
|
||||
// Step(2): Use the upper 6-bits of input "X" value as an
|
||||
// index into the table to obtain the coefficients
|
||||
// for a second order equation:
|
||||
//
|
||||
// _FPUasinTable:
|
||||
// CoeffA0[0]
|
||||
// CoeffA1[0]
|
||||
// CoeffA2[0]
|
||||
// .
|
||||
// .
|
||||
// CoeffA0[63]
|
||||
// CoeffA1[63]
|
||||
// CoeffA2[63]
|
||||
//
|
||||
// Step(3): Calculate the angle using the following equation:
|
||||
//
|
||||
// arctan(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
// arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
//
|
||||
// Step(4): The final angle is determined as follows:
|
||||
//
|
||||
// if( X < 0 )
|
||||
// Angle = -Angle
|
||||
__interrupt void Cla1Task1 ( void )
|
||||
{
|
||||
//
|
||||
//Local Variables
|
||||
//
|
||||
int xTblIdx; //integer valued Table index
|
||||
float A0,A1,A2; //Table coefficients
|
||||
float *entry;
|
||||
float result;
|
||||
|
||||
//
|
||||
//Preprocessing
|
||||
//
|
||||
__mdebugstop();
|
||||
xTblIdx = fVal * TABLE_SIZE_M_1; //convert table index to u16-bits
|
||||
xTblIdx = xTblIdx * 3; //Table is ordered as 3 32-bit coefficients, the
|
||||
//index points to these triplets, hence the *3*sizeof(float)
|
||||
entry = &CLAasinTable[xTblIdx];
|
||||
A0 = *entry++;
|
||||
A1 = *entry++;
|
||||
A2 = *entry;
|
||||
|
||||
|
||||
result = A0 + fVal*(A1 + A2*fVal);
|
||||
|
||||
//
|
||||
//Post processing
|
||||
//
|
||||
if(fVal < 0)
|
||||
{
|
||||
result = - result;
|
||||
}
|
||||
|
||||
fResult = result;
|
||||
}
|
||||
|
||||
interrupt void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task8 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,135 @@
|
||||
#ifndef _CLA_ASIN_SHARED_H_
|
||||
#define _CLA_ASIN_SHARED_H_
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex1_asin_shared.h
|
||||
//
|
||||
// TITLE: CLA arcsine example header file.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f2838x_cla_defines.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define BUFFER_SIZE 64
|
||||
#define TABLE_SIZE 64
|
||||
#define TABLE_SIZE_M_1 TABLE_SIZE-1
|
||||
#define PIBYTWO 1.570796327
|
||||
#define PI 3.141592653589
|
||||
#define INV2PI 0.159154943
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
//
|
||||
extern float y[]; //Result vector
|
||||
extern float fVal; //Holds the input argument to the task
|
||||
extern float fResult; //The arsine of the input argument
|
||||
|
||||
//
|
||||
//Task 2 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 3 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 4 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 5 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 6 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 7 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 8 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Common (C) Variables
|
||||
//
|
||||
extern float CLAasinTable[]; //The arcsine lookup table
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
// The following are symbols defined in the CLA assembly code
|
||||
// Including them in the shared header file makes them
|
||||
// .global and the main CPU can make use of them.
|
||||
//
|
||||
__interrupt void Cla1Task1();
|
||||
__interrupt void Cla1Task2();
|
||||
__interrupt void Cla1Task3();
|
||||
__interrupt void Cla1Task4();
|
||||
__interrupt void Cla1Task5();
|
||||
__interrupt void Cla1Task6();
|
||||
__interrupt void Cla1Task7();
|
||||
__interrupt void Cla1Task8();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif //end of _CLA_ASIN_SHARED_H_ definition
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,555 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: cla_ex2_atan.c
|
||||
//
|
||||
// TITLE: CLA ArcTan Example
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1>CLA \f$arctangent(x)\f$ using a lookup table (cla_atan_cpu01)</h1>
|
||||
//!
|
||||
//! In this example, Task 1 of the CLA will calculate the arctangent of
|
||||
//! an input argument using a lookup table.
|
||||
//!
|
||||
//! \b Memory \b Allocation \n
|
||||
//! - CLA1 Math Tables (RAMLS0)
|
||||
//! - CLAatan2Table - Lookup table
|
||||
//! - CLA1 to CPU Message RAM
|
||||
//! - fResult - Result of the lookup algorithm
|
||||
//! - CPU to CLA1 Message RAM
|
||||
//! - fNum - Numerator of sample input
|
||||
//! - fDen - Denominator of sample input
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - fVal - Argument to task 1
|
||||
//! - fResult - Result of \f$arctan(fVal)\f$
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "cla_ex2_atan_shared.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define WAITSTEP asm(" RPT #255 || NOP")
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
// NOTE: Do not initialize the Message RAM variables globally, they will be
|
||||
// reset during the message ram initialization phase in the CLA memory
|
||||
// configuration routine
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
|
||||
#pragma DATA_SECTION("CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION("CpuToCla1MsgRAM")
|
||||
float PIBYTWO;
|
||||
#pragma DATA_SECTION("Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
|
||||
#else
|
||||
|
||||
#pragma DATA_SECTION(fVal,"CpuToCla1MsgRAM");
|
||||
float fVal;
|
||||
#pragma DATA_SECTION(PIBYTWO,"CpuToCla1MsgRAM")
|
||||
float PIBYTWO = 1.570796327;
|
||||
#pragma DATA_SECTION(fResult,"Cla1ToCpuMsgRAM");
|
||||
float fResult;
|
||||
#endif //__cplusplus
|
||||
float y[BUFFER_SIZE];
|
||||
|
||||
//
|
||||
//Task 2 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 3 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 4 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 5 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 6 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 7 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 8 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Common (C) Variables
|
||||
//The Exponential table
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
#pragma DATA_SECTION("CLADataLS0")
|
||||
#else
|
||||
#pragma DATA_SECTION(CLAatan2Table,"CLADataLS0")
|
||||
#endif //__cplusplus
|
||||
float CLAatan2Table[]={
|
||||
0.000000000000, 1.000040679675, -0.007811069750,
|
||||
-0.000003807022, 1.000528067772, -0.023410345493,
|
||||
-0.000018968310, 1.001498568106, -0.038941197075,
|
||||
-0.000052831927, 1.002943680965, -0.054358563160,
|
||||
-0.000112417996, 1.004850785788, -0.069618206649,
|
||||
-0.000204295885, 1.007203293243, -0.084677028723,
|
||||
-0.000334469493, 1.009980843501, -0.099493367628,
|
||||
-0.000508272606, 1.013159547023, -0.114027278430,
|
||||
-0.000730276035, 1.016712263449, -0.128240790343,
|
||||
-0.001004207980, 1.020608913557, -0.142098138715,
|
||||
-0.001332888717, 1.024816818801, -0.155565969259,
|
||||
-0.001718180431, 1.029301062569, -0.168613512667,
|
||||
-0.002160952612, 1.034024867135, -0.181212728329,
|
||||
-0.002661063159, 1.038949980222, -0.193338416410,
|
||||
-0.003217354977, 1.044037065160, -0.204968298146,
|
||||
-0.003827667546, 1.049246088868, -0.216083064706,
|
||||
-0.004488862702, 1.054536702192, -0.226666395507,
|
||||
-0.005196863579, 1.059868607573, -0.236704947279,
|
||||
-0.005946705500, 1.065201909527, -0.246188315613,
|
||||
-0.006732597422, 1.070497443994, -0.255108971022,
|
||||
-0.007547992413, 1.075717083222, -0.263462171840,
|
||||
-0.008385665599, 1.080824013499, -0.271245856476,
|
||||
-0.009237797924, 1.085782983693, -0.278460517693,
|
||||
-0.010096064139, 1.090560523211, -0.285109061650,
|
||||
-0.010951723407, 1.095125128557, -0.291196654447,
|
||||
-0.011795711029, 1.099447418304, -0.296730558920,
|
||||
-0.012618729873, 1.103500256784, -0.301719964310,
|
||||
-0.013411340199, 1.107258847274, -0.306175811325,
|
||||
-0.014164046711, 1.110700795887, -0.310110614947,
|
||||
-0.014867381831, 1.113806147717, -0.313538287176,
|
||||
-0.015511984298, 1.116557397059, -0.316473961655,
|
||||
-0.016088672395, 1.118939473766, -0.318933821948,
|
||||
-0.016588511229, 1.120939707956, -0.320934934991,
|
||||
-0.017002873645, 1.122547775367, -0.322495091022,
|
||||
-0.017323494499, 1.123755625749, -0.323632651068,
|
||||
-0.017542518140, 1.124557396633, -0.324366402860,
|
||||
-0.017652539065, 1.124949314810, -0.324715425833,
|
||||
-0.017646635823, 1.124929587773, -0.324698965683,
|
||||
-0.017518398344, 1.124498287266, -0.324336318787,
|
||||
-0.017261948920, 1.123657226955, -0.323646726613,
|
||||
-0.016871957164, 1.122409836098, -0.322649280139,
|
||||
-0.016343649294, 1.120761030918, -0.321362834119,
|
||||
-0.015672812166, 1.118717085258, -0.319805931024,
|
||||
-0.014855792451, 1.116285501852, -0.317996734279,
|
||||
-0.013889491441, 1.113474885484, -0.315952970460,
|
||||
-0.012771355912, 1.110294819035, -0.313691879968,
|
||||
-0.011499365513, 1.106755743329, -0.311230175714,
|
||||
-0.010072017131, 1.102868841531, -0.308584009287,
|
||||
-0.008488306656, 1.098645928648, -0.305768944066,
|
||||
-0.006747708579, 1.094099346648, -0.302799934724,
|
||||
-0.004850153815, 1.089241865523, -0.299691312610,
|
||||
-0.002796006119, 1.084086590517, -0.296456776409,
|
||||
-0.000586037441, 1.078646875666, -0.293109387609,
|
||||
0.001778597452, 1.072936243727, -0.289661570229,
|
||||
0.004296386804, 1.066968312440, -0.286125114351,
|
||||
0.006965487894, 1.060756727064, -0.282511182960,
|
||||
0.009783753017, 1.054315099009, -0.278830321668,
|
||||
0.012748755207, 1.047656950440, -0.275092470943,
|
||||
0.015857813546, 1.040795664582, -0.271306980411,
|
||||
0.019108017893, 1.033744441476, -0.267482624928,
|
||||
0.022496252887, 1.026516258989, -0.263627622089,
|
||||
0.026019221162, 1.019123838651, -0.259749650860,
|
||||
0.029673465636, 1.011579616186, -0.255855871106,
|
||||
0.033455390838, 1.003895716322, -0.251952943763,
|
||||
0.037361283212, 0.996083931611, -0.248047051426
|
||||
};
|
||||
|
||||
float atan_expected[BUFFER_SIZE]={
|
||||
1.5395565, 1.5385494, 1.5374753, 1.5363272,
|
||||
1.5350972, 1.5337762, 1.5323538, 1.5308176,
|
||||
1.5291537, 1.5273454, 1.5253731, 1.5232133,
|
||||
1.5208379, 1.5182133, 1.5152978, 1.5120405,
|
||||
1.5083776, 1.5042281, 1.4994888, 1.4940244,
|
||||
1.4876550, 1.4801364, 1.4711276, 1.4601392,
|
||||
1.4464413, 1.4288993, 1.4056476, 1.3734008,
|
||||
1.3258177, 1.2490457, 1.1071488, 0.7853982,
|
||||
0.0000000, -0.7853982, -1.1071488, -1.2490457,
|
||||
-1.3258177, -1.3734008, -1.4056476, -1.4288993,
|
||||
-1.4464413, -1.4601392, -1.4711276, -1.4801364,
|
||||
-1.4876550, -1.4940244, -1.4994888, -1.5042281,
|
||||
-1.5083776, -1.5120405, -1.5152978, -1.5182133,
|
||||
-1.5208379, -1.5232133, -1.5253731, -1.5273454,
|
||||
-1.5291537, -1.5308176, -1.5323538, -1.5337762,
|
||||
-1.5350972, -1.5363272, -1.5374753, -1.5385494
|
||||
};
|
||||
|
||||
uint16_t pass=0;
|
||||
uint16_t fail=0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void CLA_runTest(void);
|
||||
void CLA_configClaMemory(void);
|
||||
void CLA_initCpu1Cla1(void);
|
||||
__interrupt void cla1Isr1();
|
||||
__interrupt void cla1Isr2();
|
||||
__interrupt void cla1Isr3();
|
||||
__interrupt void cla1Isr4();
|
||||
__interrupt void cla1Isr5();
|
||||
__interrupt void cla1Isr6();
|
||||
__interrupt void cla1Isr7();
|
||||
__interrupt void cla1Isr8();
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the <device>_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the <device>_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the default Interrupt
|
||||
// Service Routines (ISR).
|
||||
// The default ISR routines are found in <device>_defaultisr.c.
|
||||
// This function is found in <device>_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Step 3. Configure the CLA memory spaces first followed by
|
||||
// the CLA task vectors
|
||||
//
|
||||
CLA_configClaMemory();
|
||||
CLA_initCpu1Cla1();
|
||||
|
||||
//
|
||||
// Step 4. Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Step 5. Run the test
|
||||
//
|
||||
CLA_runTest();
|
||||
|
||||
for(;;)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CLA_runTest - Execute CLA task tests for specified vectors
|
||||
//
|
||||
void CLA_runTest(void)
|
||||
{
|
||||
int16_t i;
|
||||
float error;
|
||||
|
||||
//
|
||||
// Initialize the CPUToCLA1MsgRam variables here
|
||||
//
|
||||
PIBYTWO = 1.570796327;
|
||||
|
||||
for(i=0; i < BUFFER_SIZE; i++)
|
||||
{
|
||||
fVal = (float)((BUFFER_SIZE/2) - i);
|
||||
|
||||
Cla1ForceTask1andWait();
|
||||
|
||||
y[i] = fResult;
|
||||
error = fabsf(atan_expected[i]-y[i]);
|
||||
|
||||
if(error < 0.1f)
|
||||
{
|
||||
pass++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fail++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// CLA tasks 2-8 are not used in this example
|
||||
//
|
||||
#if 0
|
||||
|
||||
Cla1ForceTask2andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask3andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask4andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask5andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask6andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask7andWait();
|
||||
WAITSTEP;
|
||||
|
||||
Cla1ForceTask8andWait();
|
||||
WAITSTEP;
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// CLA_configClaMemory - Configure CLA memory sections
|
||||
//
|
||||
void CLA_configClaMemory(void)
|
||||
{
|
||||
extern uint32_t Cla1funcsRunStart, Cla1funcsLoadStart, Cla1funcsLoadSize;
|
||||
EALLOW;
|
||||
|
||||
#ifdef _FLASH
|
||||
//
|
||||
// Copy over code from FLASH to RAM
|
||||
//
|
||||
memcpy((uint32_t *)&Cla1funcsRunStart, (uint32_t *)&Cla1funcsLoadStart,
|
||||
(uint32_t)&Cla1funcsLoadSize);
|
||||
#endif //_FLASH
|
||||
|
||||
//
|
||||
// Initialize and wait for CLA1ToCPUMsgRAM
|
||||
//
|
||||
MemCfgRegs.MSGxINIT.bit.INIT_CLA1TOCPU = 1;
|
||||
while(MemCfgRegs.MSGxINITDONE.bit.INITDONE_CLA1TOCPU != 1){};
|
||||
|
||||
//
|
||||
// Initialize and wait for CPUToCLA1MsgRAM
|
||||
//
|
||||
MemCfgRegs.MSGxINIT.bit.INIT_CPUTOCLA1 = 1;
|
||||
while(MemCfgRegs.MSGxINITDONE.bit.INITDONE_CPUTOCLA1 != 1){};
|
||||
|
||||
//
|
||||
// Select LS5RAM to be the programming space for the CLA
|
||||
// First configure the CLA to be the master for LS5 and then
|
||||
// set the space to be a program block
|
||||
//
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS5 = 1;
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS5 = 1;
|
||||
|
||||
//
|
||||
// Next configure LS0RAM and LS1RAM as data spaces for the CLA
|
||||
// First configure the CLA to be the master for LS0(1) and then
|
||||
// set the spaces to be code blocks
|
||||
//
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS0 = 1;
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS0 = 0;
|
||||
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS1 = 1;
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS1 = 0;
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// CLA_initCpu1Cla1 - Initialize CLA1 task vectors and end of task interrupts
|
||||
//
|
||||
void CLA_initCpu1Cla1(void)
|
||||
{
|
||||
//
|
||||
// Suppressing #770-D conversion from pointer to smaller integer
|
||||
// The CLA address range is 16 bits so the addresses passed to the MVECT
|
||||
// registers will be in the lower 64KW address space. Turn the warning
|
||||
// back on after the MVECTs are assigned addresses
|
||||
//
|
||||
#pragma diag_suppress=770
|
||||
EALLOW;
|
||||
Cla1Regs.MVECT1 = (uint16_t)(&Cla1Task1);
|
||||
Cla1Regs.MVECT2 = (uint16_t)(&Cla1Task2);
|
||||
Cla1Regs.MVECT3 = (uint16_t)(&Cla1Task3);
|
||||
Cla1Regs.MVECT4 = (uint16_t)(&Cla1Task4);
|
||||
Cla1Regs.MVECT5 = (uint16_t)(&Cla1Task5);
|
||||
Cla1Regs.MVECT6 = (uint16_t)(&Cla1Task6);
|
||||
Cla1Regs.MVECT7 = (uint16_t)(&Cla1Task7);
|
||||
Cla1Regs.MVECT8 = (uint16_t)(&Cla1Task8);
|
||||
#pragma diag_warning=770
|
||||
|
||||
//
|
||||
// Enable the IACK instruction to start a task on CLA in software
|
||||
// for all 8 CLA tasks. Also, globally enable all 8 tasks (or a
|
||||
// subset of tasks) by writing to their respective bits in the
|
||||
// MIER register
|
||||
//
|
||||
Cla1Regs.MCTL.bit.IACKE = 1;
|
||||
Cla1Regs.MIER.all = 0x00FF;
|
||||
|
||||
//
|
||||
// Configure the vectors for the end-of-task interrupt for all
|
||||
// 8 tasks
|
||||
//
|
||||
PieVectTable.CLA1_1_INT = &cla1Isr1;
|
||||
PieVectTable.CLA1_2_INT = &cla1Isr2;
|
||||
PieVectTable.CLA1_3_INT = &cla1Isr3;
|
||||
PieVectTable.CLA1_4_INT = &cla1Isr4;
|
||||
PieVectTable.CLA1_5_INT = &cla1Isr5;
|
||||
PieVectTable.CLA1_6_INT = &cla1Isr6;
|
||||
PieVectTable.CLA1_7_INT = &cla1Isr7;
|
||||
PieVectTable.CLA1_8_INT = &cla1Isr8;
|
||||
|
||||
//
|
||||
// Enable CLA interrupts at the group and subgroup levels
|
||||
//
|
||||
PieCtrlRegs.PIEIER11.all = 0xFFFF;
|
||||
IER |= (M_INT11 );
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 1
|
||||
//
|
||||
__interrupt void cla1Isr1 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 1
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = M_INT11;
|
||||
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr2 - CLA1 ISR 2
|
||||
//
|
||||
__interrupt void cla1Isr2 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr3 - CLA1 ISR 3
|
||||
//
|
||||
__interrupt void cla1Isr3 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr4 - CLA1 ISR 4
|
||||
//
|
||||
__interrupt void cla1Isr4 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr5 - CLA1 ISR 5
|
||||
//
|
||||
__interrupt void cla1Isr5 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr6 - CLA1 ISR 6
|
||||
//
|
||||
__interrupt void cla1Isr6 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr7 - CLA1 ISR 7
|
||||
//
|
||||
__interrupt void cla1Isr7 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr8 - CLA1 ISR 8
|
||||
//
|
||||
__interrupt void cla1Isr8 ()
|
||||
{
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 8
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = M_INT11;
|
||||
|
||||
//
|
||||
// Uncomment to halt debugger and stop here
|
||||
//
|
||||
// asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,191 @@
|
||||
//#############################################################################
|
||||
// \file cla_ex2_atan_cla.cla
|
||||
//
|
||||
// \brief Arc Tangent Example
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "cla_ex2_atan_shared.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
// Note that the globals defined in the .cla source are global to the cla source
|
||||
// file. i.e. they may be shared across tasks. All of the data shared between
|
||||
// the CLA and the C28x CPU must be defined in the C (or C++) code, and not the
|
||||
// CLA code.
|
||||
//
|
||||
|
||||
//
|
||||
// Function Definitions
|
||||
//
|
||||
//Task 1 : Calculate atan(Y)
|
||||
// Description:
|
||||
// Step(1): if( 1.0 >= abs(Y) )
|
||||
// Numerator = abs(Y)
|
||||
// Denominator = 1.0
|
||||
// else
|
||||
// Numerator = 1.0
|
||||
// Denominator = abs(Y)
|
||||
//
|
||||
// Step(2): Ratio = Numerator/Denominator
|
||||
//
|
||||
// Note: Ratio range = 0.0 to 1.0
|
||||
//
|
||||
// Step(3): Use the upper 6-bits of the "Ratio" value as an
|
||||
// index into the table to obtain the coefficients
|
||||
// for a second order equation:
|
||||
//
|
||||
// _FPUatan2Table:
|
||||
// CoeffA0[0]
|
||||
// CoeffA1[0]
|
||||
// CoeffA2[0]
|
||||
// .
|
||||
// .
|
||||
// CoeffA0[63]
|
||||
// CoeffA1[63]
|
||||
// CoeffA2[63]
|
||||
//
|
||||
// Step(4): Calculate the angle using the following equation:
|
||||
//
|
||||
// arctan(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
// arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
//
|
||||
// Step(5): The final angle is determined as follows:
|
||||
//
|
||||
// if( Y >= 0 and 1.0 >= abs(Y) )
|
||||
// Angle = arctan(abs(Y)/1.0)
|
||||
// if( Y >= 0 and 1.0 < abs(Y) )
|
||||
// Angle = PI/2 - arctan(1.0/abs(Y))
|
||||
// if( Y < 0 )
|
||||
// Angle = -Angle
|
||||
__interrupt void Cla1Task1 ( void )
|
||||
{
|
||||
//
|
||||
//Local Variables
|
||||
//
|
||||
unsigned int uxTblIdx; //unsigned integer valued Table index
|
||||
float ratio;
|
||||
float num,den;
|
||||
float A0,A1,A2; //Table coefficients
|
||||
float *base;
|
||||
float result;
|
||||
|
||||
//
|
||||
//Preprocessing
|
||||
//
|
||||
__mdebugstop();
|
||||
num = __mminf32(fabsf(fVal),1.0f);
|
||||
den = __mmaxf32(fabsf(fVal),1.0f);
|
||||
|
||||
ratio = (num/den); //Expected the newton raphson algo for better
|
||||
//accuracy on the divide
|
||||
uxTblIdx = ratio * TABLE_SIZE_M_1 * 3; //convert table index to u16-bits
|
||||
uxTblIdx = uxTblIdx * 3; //Table is ordered as 3 32-bit coefficients, the
|
||||
//index points to these triplets, hence the *3*sizeof(float)
|
||||
|
||||
base = &CLAatan2Table[uxTblIdx];
|
||||
A0 = *base++;
|
||||
A1 = *base++;
|
||||
A2 = *base;
|
||||
|
||||
result = A0 + ratio*(A1 + A2*ratio);
|
||||
|
||||
//
|
||||
//Post processing
|
||||
//
|
||||
if(fabsf(fVal) > 1.0f)
|
||||
{
|
||||
result = PIBYTWO - result;
|
||||
}
|
||||
|
||||
if(fVal < 0.0f)
|
||||
{
|
||||
result = -result;
|
||||
}
|
||||
|
||||
fResult = result;
|
||||
}
|
||||
|
||||
interrupt void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task7 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
interrupt void Cla1Task8 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
#ifndef _CLA_ATAN_SHARED_H_
|
||||
#define _CLA_ATAN_SHARED_H_
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex2_atan_shared.h
|
||||
//
|
||||
// TITLE: CLA arctangent example header file.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f2838x_cla_defines.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define BUFFER_SIZE 64
|
||||
#define TABLE_SIZE 64
|
||||
#define TABLE_SIZE_M_1 TABLE_SIZE-1
|
||||
#define INV2PI 0.159154943
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
//
|
||||
extern float y[]; //Result vector
|
||||
extern float fVal; //Holds the input argument to the task
|
||||
extern float fResult; //The arsine of the input argument
|
||||
|
||||
//
|
||||
//Task 2 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 3 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 4 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 5 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 6 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 7 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Task 8 (C) Variables
|
||||
//
|
||||
|
||||
//
|
||||
//Common (C) Variables
|
||||
//
|
||||
extern float PIBYTWO;
|
||||
extern float CLAatan2Table[];
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
// The following are symbols defined in the CLA assembly code
|
||||
// Including them in the shared header file makes them
|
||||
// .global and the main CPU can make use of them.
|
||||
//
|
||||
__interrupt void Cla1Task1();
|
||||
__interrupt void Cla1Task2();
|
||||
__interrupt void Cla1Task3();
|
||||
__interrupt void Cla1Task4();
|
||||
__interrupt void Cla1Task5();
|
||||
__interrupt void Cla1Task6();
|
||||
__interrupt void Cla1Task7();
|
||||
__interrupt void Cla1Task8();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif //end of _CLA_ATAN_SHARED_H_ definition
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,479 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex3_background_task.c
|
||||
//
|
||||
// TITLE: CLA ADC Sampling and Filtering with Buffering in a Background Task
|
||||
//
|
||||
//! \addtogroup bitfield_example_list
|
||||
//! <h1> CLA ADC Sampling and Filtering with Buffering in a Background
|
||||
//! Task </h1>
|
||||
//!
|
||||
//! This example configures EPWM1A to run at 1 KHz (period = 1 ms) to
|
||||
//! trigger a start-of-conversion on ADC channel A0. This channel will,
|
||||
//! in turn, sample EPWM4A which is set to run at 100Hz.
|
||||
//! At the end-of-conversion the ADC interrupt is fired. The interrupt signal
|
||||
//! will be used to trigger a CLA task that runs an FIR filter. The filter
|
||||
//! is designed to be low pass with a cutoff frequency of 100Hz; it will remove
|
||||
//! the odd harmonics in the input signal smoothing the square wave to a
|
||||
//! sinusoidal shape.
|
||||
//! The CLA background task will continuously buffer the filtered output in a
|
||||
//! circular buffer.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - connect A0 to EPWM4A
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - None
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "cla_ex3_background_task_shared.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define SYS_FREQ 100000000UL
|
||||
#define EPWM_CLKDIV 64UL
|
||||
|
||||
#define EPWM1_FREQ 1000UL
|
||||
#define EPWM4_FREQ 100UL
|
||||
#define EPWM1_PERIOD (uint16_t)(SYS_FREQ/(EPWM_CLKDIV*EPWM1_FREQ))
|
||||
#define EPWM4_PERIOD (uint16_t)(SYS_FREQ/(EPWM_CLKDIV*EPWM4_FREQ))
|
||||
#define EPWM4_DUTY_CYCLE (EPWM4_PERIOD/2)
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
|
||||
// Background Task (C) Variables
|
||||
// Circular buffer to store filtered output
|
||||
#pragma DATA_SECTION(buffer, "CLADataLS0");
|
||||
volatile float buffer[BUFFER_SIZE];
|
||||
|
||||
// Linker Defined variables
|
||||
extern uint32_t Cla1funcsRunStart, Cla1funcsLoadStart, Cla1funcsLoadSize;
|
||||
extern uint32_t Cla1ConstRunStart, Cla1ConstLoadStart, Cla1ConstLoadSize;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void initADC( void );
|
||||
void initADCSOC( void );
|
||||
void initEPWM( void );
|
||||
void initCLA( void );
|
||||
__attribute__((interrupt)) void cla1Isr1( void );
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// GPIO0 is set to EPWM1A
|
||||
//
|
||||
InitGpio();
|
||||
GPIO_SetupPinMux(0U, GPIO_MUX_CPU1, 1);
|
||||
GPIO_SetupPinOptions(0U, GPIO_OUTPUT, GPIO_PUSHPULL);
|
||||
|
||||
//
|
||||
// GPIO6 is set to EPWM4A
|
||||
//
|
||||
GPIO_SetupPinMux(6U, GPIO_MUX_CPU1, 1);
|
||||
GPIO_SetupPinOptions(6U, GPIO_OUTPUT, GPIO_PUSHPULL);
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
InitPieCtrl();
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the default Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Map the ISR to the CLA end-of-task interrupt.
|
||||
//
|
||||
EALLOW;
|
||||
PieVectTable.CLA1_1_INT = &cla1Isr1;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Setup the CLA and ADC
|
||||
//
|
||||
initCLA();
|
||||
initADC();
|
||||
initADCSOC();
|
||||
|
||||
//
|
||||
// Disable sync(Freeze clock to PWM as well)
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0U;
|
||||
EDIS;
|
||||
initEPWM();
|
||||
|
||||
//
|
||||
// Enable the interrupts in the PIE: Group 11 interrupt 1.
|
||||
//
|
||||
PieCtrlRegs.PIEIER11.bit.INTx1 = 1U;
|
||||
IER |= 0x0400U;
|
||||
PieCtrlRegs.PIEACK.bit.ACK11 = 1U;
|
||||
|
||||
//
|
||||
// Enable global interrupts.
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Enable sync and clock to PWM
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1U;
|
||||
EDIS;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ADC Initialization
|
||||
//
|
||||
// Function to configure and power up ADC A
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void initADC(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Set ADCCLK divider to /4
|
||||
//
|
||||
AdcaRegs.ADCCTL2.bit.PRESCALE = 6;
|
||||
|
||||
//
|
||||
// Set pulse positions to late
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
|
||||
|
||||
//
|
||||
// Power up the ADCs and then delay for 1 ms
|
||||
//
|
||||
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
|
||||
|
||||
EDIS;
|
||||
|
||||
DELAY_US(1000);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// ADC SOC Initialization
|
||||
//
|
||||
// Description: This function will configure the ADC, channel A0 to start
|
||||
// its conversion on a trigger from EPWM1 (EPMW1SOCA). The ADC will sample this
|
||||
// channel continuously. After each conversion it will assert ADCINT1, which
|
||||
// is then used to trigger task 1 of the CLA (the filter)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void initADCSOC( void )
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Configure SOC0 of ADCA
|
||||
// - SOC0 will be triggered by EPWM1SOCA
|
||||
// - SOC0 will convert pin A0 with a sample window of 100 SYSCLK cycles.
|
||||
// - EOC0 will be generated at the end of conversion
|
||||
// - SOC0 will sample on each trigger regardless of the interrupt flag
|
||||
//
|
||||
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0;
|
||||
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 100U - 1U;
|
||||
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5;
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 1;
|
||||
|
||||
//
|
||||
// Set SOC0 to set the interrupt 1 flag. Enable the interrupt and make
|
||||
// sure its flag is cleared.
|
||||
//
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0;
|
||||
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// EPWM Initialization
|
||||
//
|
||||
// Description: EPWM1A will run at EPWM1_FREQ Hz and serves as the sampling
|
||||
// clock for ADC channel A1 which will be sampling the slower running EPWM4A
|
||||
// (at EPWM4_FREQ Hz). The default time base for the EPWM module is half the
|
||||
// system clock i.e.
|
||||
// TBCLK = SYSCLKOUT/2
|
||||
// EPWM1A will be setup in count-up mode and an event generated every period
|
||||
// this event will trigger the ADC to start sampling on channel A1
|
||||
// EPWM4A is setup for updown count mode with CMPA level at the half period
|
||||
// point giving a 50% duty cycle square wave at EPWM4_FREQ Hz
|
||||
// For a desired PWM frequency F_pwm (1/T_pwm), we have
|
||||
// T_pwm = 2 x TBPRD / TBCLK
|
||||
// TBPRD = TBCLK/(2*F_pwm)
|
||||
// For e.g. F_pwm = 10KHz, TBCLK = 50e6
|
||||
// TBPRD = 50e6/(2*10e3)
|
||||
// = 2500
|
||||
// For e.g. F_pwm = 1KHz, TBCLK = 50e6
|
||||
// TBPRD = 50e6/(2*1e3)
|
||||
// = 25000
|
||||
// For e.g. F_pwm = 100Hz, TBCLK = 50e6
|
||||
// TBPRD = 50e6/(2*1e2)
|
||||
// = 250000
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void initEPWM( void )
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Set up EPWM1 to
|
||||
// - run on a base clock of SYSCLK/128
|
||||
// - have a period of EPWM1_PERIOD
|
||||
// - run in count up mode
|
||||
//
|
||||
EPwm1Regs.TBCTL.bit.CLKDIV = 2U; // EPWM_CLOCK_DIVIDER_4
|
||||
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 4U; // EPWM_HSCLOCK_DIVIDER_8
|
||||
EPwm1Regs.TBPRD = EPWM1_PERIOD;
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = 0U;
|
||||
EPwm1Regs.TBCTR = 0U;
|
||||
|
||||
//
|
||||
// Enable SOC-A and set it to assert when the counter hits
|
||||
// zero. It asserts on every event
|
||||
//
|
||||
EPwm1Regs.ETSEL.bit.SOCAEN = 1U;
|
||||
EPwm1Regs.ETSEL.bit.SOCASEL = 1U;
|
||||
EPwm1Regs.ETPS.bit.SOCPSSEL = 1U;
|
||||
EPwm1Regs.ETSOCPS.bit.SOCAPRD2 = 1U;
|
||||
|
||||
//
|
||||
// EPWM1 should toggle each time its counter hits zero
|
||||
//
|
||||
EPwm1Regs.AQCTLA.bit.ZRO = 3U;
|
||||
|
||||
//
|
||||
// Set up EPWM4 to
|
||||
// - run on a base clock of SYSCLK/32
|
||||
// - have a period of EPWM4_PERIOD
|
||||
// - run in count up/down mode
|
||||
// - have its CMPA value set for a 50% duty cycle
|
||||
//
|
||||
EPwm4Regs.TBCTL.bit.CLKDIV = 2U; // EPWM_CLOCK_DIVIDER_4
|
||||
EPwm4Regs.TBCTL.bit.HSPCLKDIV = 4U; // EPWM_HSCLOCK_DIVIDER_8
|
||||
|
||||
|
||||
EPwm4Regs.TBPRD = EPWM4_PERIOD;
|
||||
EPwm4Regs.TBCTL.bit.CTRMODE = 2U;
|
||||
EPwm4Regs.TBCTR = 0U;
|
||||
EPwm4Regs.CMPA. all = EPWM4_DUTY_CYCLE;
|
||||
|
||||
//
|
||||
// On compare A, when counting up, pull the EPWM A output high
|
||||
// On compare A, when counting down, pull the EPWM A output low
|
||||
//
|
||||
EPwm4Regs.AQCTLA.bit.CAU = 2U;
|
||||
EPwm4Regs.AQCTLA.bit.CAD = 1U;
|
||||
|
||||
//
|
||||
// EPWM 1 and 4 should run freely in emulation mode
|
||||
//
|
||||
EPwm1Regs.TBCTL.bit.FREE_SOFT = 2U;
|
||||
EPwm4Regs.TBCTL.bit.FREE_SOFT = 2U;
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// CLA Initialization
|
||||
//
|
||||
// Description: This function will
|
||||
// - copy over code and const from flash to CLA program and data ram
|
||||
// respectively
|
||||
// - Initialize the task vectors (MVECTx)
|
||||
// - setup each task's trigger
|
||||
// - enable each individual task
|
||||
// - map program and data spaces to the CLA
|
||||
// - run any one-time initialization task
|
||||
// Please note that the CLA can only run code and access data that is in RAM.
|
||||
// the user must assign constants (tables) to FLASH, and copy them over to
|
||||
// RAM at run-time. They must be copied to a RAM that lies in the address space
|
||||
// of the CLA, and prior to giving the CLA control over that space
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void initCLA( void )
|
||||
{
|
||||
//
|
||||
// Copy the program and constants from FLASH to RAM before configuring
|
||||
// the CLA
|
||||
//
|
||||
#if defined(_FLASH)
|
||||
memcpy((uint32_t *)&Cla1funcsRunStart, (uint32_t *)&Cla1funcsLoadStart,
|
||||
(uint32_t)&Cla1funcsLoadSize );
|
||||
memcpy((uint32_t *)&Cla1ConstRunStart, (uint32_t *)&Cla1ConstLoadStart,
|
||||
(uint32_t)&Cla1ConstLoadSize );
|
||||
#endif //defined(_FLASH)
|
||||
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// CLA Program will reside in RAMLS5 and data in RAMLS0, RAMLS1
|
||||
//
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS5 = 1U;
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS0 = 0U;
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS1 = 0U;
|
||||
|
||||
//
|
||||
// Select CLA as the master of RAMLS0, RAMSL1, RAMLS5
|
||||
//
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS0 = 1U;
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS1 = 1U;
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS5 = 1U;
|
||||
|
||||
//
|
||||
// Suppressing #770-D conversion from pointer to smaller integer
|
||||
// The CLA address range is 16 bits so the addresses passed to the MVECT
|
||||
// registers will be in the lower 64KW address space. Turn the warning
|
||||
// back on after the MVECTs are assigned addresses
|
||||
//
|
||||
#pragma diag_suppress=770
|
||||
//
|
||||
// Assign the task vectors and set the triggers for task 1 and 7
|
||||
//
|
||||
Cla1Regs.MVECT1 = (uint16_t)&Cla1Task1;
|
||||
Cla1Regs.MVECT7 = (uint16_t)&Cla1Task7;
|
||||
|
||||
DmaClaSrcSelRegs.CLA1TASKSRCSEL1.bit.TASK1 = 1U; //ADCA1
|
||||
DmaClaSrcSelRegs.CLA1TASKSRCSEL2.bit.TASK7 = 0U; //Software
|
||||
|
||||
//
|
||||
// Enable Tasks 1 and 7. Since task 7 is forced in software, we must
|
||||
// enable software forcing (IACKE)
|
||||
//
|
||||
Cla1Regs.MIER.bit.INT1 = 1U;
|
||||
Cla1Regs.MIER.bit.INT7 = 1U;
|
||||
|
||||
Cla1Regs.MCTL.bit.IACKE = 1U;
|
||||
|
||||
//
|
||||
// The background task will be triggered by software; it shares
|
||||
// the same trigger source as task 8. Disable the hardware triggering
|
||||
// mechanism for the background task (if it is enabled) and then
|
||||
// set the trigger source for task 8 to 0 indicating a software
|
||||
// trigger.
|
||||
//
|
||||
// Enable the background task and start it. Enabling the background
|
||||
// task disables task 8.
|
||||
//
|
||||
Cla1Regs._MVECTBGRND = (uint16_t)&Cla1BackgroundTask;
|
||||
#pragma diag_warning=770
|
||||
|
||||
Cla1Regs._MCTLBGRND.bit.TRIGEN = 0U;
|
||||
|
||||
DmaClaSrcSelRegs.CLA1TASKSRCSEL2.bit.TASK8 = 0U; //Software
|
||||
|
||||
Cla1Regs._MCTLBGRND.bit.BGEN = 1U;
|
||||
|
||||
Cla1Regs._MCTLBGRND.bit.BGSTART = 1U;
|
||||
|
||||
//
|
||||
// Force task 7, the one time initialization task
|
||||
//
|
||||
Cla1Regs.MIFRC.bit.INT7 = 1U;
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// CLA Task 1 End-of-Task Interrupt Service Routine
|
||||
//
|
||||
// Description: This ISR is run every time task 1 completes. It continuously
|
||||
// takes the filtered values from the CLA and stores it to a circular buffer
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifdef __cplusplus
|
||||
#pragma CODE_SECTION(".TI.ramfunc");
|
||||
#else
|
||||
#pragma CODE_SECTION(cla1Isr1, ".TI.ramfunc")
|
||||
#endif
|
||||
__attribute__((interrupt)) void cla1Isr1 ()
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Clear the ADC interrupt flag so the next SOC can occur
|
||||
//
|
||||
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1U;
|
||||
|
||||
//
|
||||
// Acknowledge the end-of-task interrupt for task 1
|
||||
//
|
||||
PieCtrlRegs.PIEACK.bit.ACK11 = 1U;
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,254 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex3_background_task_cla.cla
|
||||
//
|
||||
// TITLE: CLA ADC Sampling and Filtering with Buffering in a Background Task
|
||||
//
|
||||
// Task 1 implements a Finite Impulse Response Filter while the background
|
||||
// task simply buffers the filtered output in a circular buffer
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include <stdint.h>
|
||||
#include "f2838x_device.h"
|
||||
#include "cla_ex3_background_task_shared.h"
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
// Generated using fdatool
|
||||
// LPF FIR Equiripple (Minimum order)
|
||||
// Fs = 1 KHz
|
||||
// Fp = 100 Hz
|
||||
// Fs = 150 Hz
|
||||
// Ap = 1dB
|
||||
// As = 40dB
|
||||
const float coeffs[FILTER_LENGTH] = {
|
||||
-0.00626161322, 0.004758020397, 0.01360770315, 0.02281877026,
|
||||
0.02540917136, 0.01582550257,-0.005789283663, -0.03123718128,
|
||||
-0.04604700953, -0.03544506058, 0.007868565619, 0.07814154029,
|
||||
0.1567010134, 0.2183543742, 0.2416974753, 0.2183543742,
|
||||
0.1567010134, 0.07814154029, 0.007868565619, -0.03544506058,
|
||||
-0.04604700953, -0.03123718128,-0.005789283663, 0.01582550257,
|
||||
0.02540917136, 0.02281877026, 0.01360770315, 0.004758020397,
|
||||
-0.00626161322
|
||||
};
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
// Note that the globals defined in the .cla source are global to the cla source
|
||||
// file. i.e. they may be shared across tasks. All of the data shared between
|
||||
// the CLA and the C28x CPU must be defined in the C (or C++) code, and not the
|
||||
// CLA code.
|
||||
//
|
||||
|
||||
// Filter output
|
||||
float filter_out;
|
||||
|
||||
// Filter delay line
|
||||
float D[FILTER_LENGTH];
|
||||
|
||||
// Circular buffer index
|
||||
uint16_t index;
|
||||
|
||||
// Flag to indicate filtered value is available
|
||||
bool f_filteredValueReady;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 1 - FIR Filter
|
||||
//
|
||||
// Description: A low pass Finite Impulse Response (FIR) filter.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task1 ( void )
|
||||
{
|
||||
//Local Variables
|
||||
int16_t i, filter_in;
|
||||
|
||||
__mdebugstop();
|
||||
|
||||
filter_out = 0.0;
|
||||
filter_in = AdcaResultRegs.ADCRESULT0;
|
||||
#if 1
|
||||
filter_in = filter_in - (1 << 11); // Read ADC value minus bias
|
||||
//Shift the delay line to the right by 1
|
||||
#pragma UNROLL(FILTER_LENGTH-1)
|
||||
for(i = FILTER_LENGTH-1; i > 0; i--){
|
||||
D[i] = D[i-1];
|
||||
//Multiply coefficients with the delay line and accumulate
|
||||
filter_out += coeffs[i] * D[i];
|
||||
}
|
||||
|
||||
__mdebugstop();
|
||||
//Get adc input into start of the delay line
|
||||
D[0] = (float)filter_in; //convert to single precision float
|
||||
filter_out += coeffs[0] * D[0];
|
||||
f_filteredValueReady = true;
|
||||
#else
|
||||
// Pass through unfiltered
|
||||
filter_out = (float)filter_in;
|
||||
f_filteredValueReady = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 2 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task2 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 3 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task3 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 4 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task4 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 5 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task5 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 6 - Title Here
|
||||
//
|
||||
// Description: Description/steps here.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task6 ( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Task 7 - One Time Initialization Task
|
||||
//
|
||||
// Description: This task will clear out the delay line and reset the index
|
||||
// and any flags
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt)) void Cla1Task7 ( void )
|
||||
{
|
||||
// Locals
|
||||
int16_t i;
|
||||
|
||||
__mdebugstop();
|
||||
for(i = 0; i < FILTER_LENGTH; i++){
|
||||
D[i] = 0.0;
|
||||
}
|
||||
|
||||
index = 0U;
|
||||
f_filteredValueReady = false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Background Task
|
||||
//
|
||||
// Description: This task will buffer the filtered output in a circular buffer
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
__attribute__((interrupt("background"))) void Cla1BackgroundTask ( void )
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
if (f_filteredValueReady == true)
|
||||
{
|
||||
//
|
||||
// Reset the flag
|
||||
//
|
||||
f_filteredValueReady = false;
|
||||
|
||||
//
|
||||
// store the filtered output. Make this portion un-interruptible
|
||||
//
|
||||
__disable_interrupts();
|
||||
buffer[index++] = filter_out;
|
||||
__enable_interrupts();
|
||||
|
||||
//
|
||||
// Since BUFFER_SIZE is a power of two, we can use unsigned modulo
|
||||
// arithmetic to wrap the index around
|
||||
//
|
||||
index = index & (BUFFER_SIZE - 1U);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,115 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: cla_ex3_background_task.h
|
||||
//
|
||||
// TITLE: CLA ADC Sampling and Filtering with Buffering in a Background Task
|
||||
//
|
||||
// This header file contains defines, variables and prototypes that are shared
|
||||
// among the C28x and the CLA
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
#ifndef _CLA_EX3_BACKGROUND_TASK_H_
|
||||
#define _CLA_EX3_BACKGROUND_TASK_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define BUFFER_SIZE 1024 // NOTE: keep to a power of 2
|
||||
#define FILTER_ORDER 28U
|
||||
#define FILTER_LENGTH (FILTER_ORDER + 1U)
|
||||
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
//Task 1 (C) Variables
|
||||
extern const float coeffs[FILTER_LENGTH];
|
||||
extern float filter_out;
|
||||
|
||||
//Task 2 (C) Variables
|
||||
|
||||
//Task 3 (C) Variables
|
||||
|
||||
//Task 4 (C) Variables
|
||||
|
||||
//Task 5 (C) Variables
|
||||
|
||||
//Task 6 (C) Variables
|
||||
|
||||
//Task 7 (C) Variables
|
||||
|
||||
//Background Task (C) Variables
|
||||
extern volatile float buffer[BUFFER_SIZE];
|
||||
|
||||
//Common (C) Variables
|
||||
extern float D[FILTER_LENGTH];
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
//CLA C Tasks defined in Cla1Tasks_C.cla
|
||||
__attribute__((interrupt)) void Cla1Task1();
|
||||
__attribute__((interrupt)) void Cla1Task2();
|
||||
__attribute__((interrupt)) void Cla1Task3();
|
||||
__attribute__((interrupt)) void Cla1Task4();
|
||||
__attribute__((interrupt)) void Cla1Task5();
|
||||
__attribute__((interrupt)) void Cla1Task6();
|
||||
__attribute__((interrupt)) void Cla1Task7();
|
||||
#if defined(__TMS320C28XX__)
|
||||
__attribute__((interrupt)) void Cla1BackgroundTask();
|
||||
#else
|
||||
__attribute__((interrupt("background"))) void Cla1BackgroundTask();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
#endif //_CLA_EX3_background_task_H_
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,29 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="buffdac_ex1_enable"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../buffdac_ex1_enable.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="buffdac_ex2_sine_dma"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_cputimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../buffdac_ex2_sine_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../buffdac_sine_dma_watch_variables.js" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,134 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: buffdac_ex1_enable.c
|
||||
//
|
||||
// TITLE: Buffered DAC Enable Output Example for F2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> Buffered DAC Enable (buffdac_enable) </h1>
|
||||
//!
|
||||
//! This example generates a voltage on the buffered DAC output,
|
||||
//! DACOUTA/ADCINA0 (HSEC Pin 9) and uses the default DAC reference setting
|
||||
//! of VDAC.
|
||||
//!
|
||||
//! When the DAC reference is set to VDAC, an external reference voltage
|
||||
//! must be applied to the VDAC pin. This can accomplished by connecting a
|
||||
//! jumper wire from 3.3V to ADCINB0 (HSEC pin 12).
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
volatile struct DAC_REGS* DAC_PTR[4] = {0x0,&DacaRegs,&DacbRegs,&DaccRegs};
|
||||
Uint16 dacval = 2048;
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define REFERENCE REFERENCE_VDAC
|
||||
#define DAC_NUM DACA
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void configureDAC(Uint16 dac_num);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags are cleared.
|
||||
// This function is found in the f2838x_pievect.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Clear all interrupts and initialize PIE vector table:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Configure DAC
|
||||
//
|
||||
configureDAC(DAC_NUM);
|
||||
|
||||
while(1)
|
||||
{
|
||||
DAC_PTR[DAC_NUM]->DACVALS.all = dacval;
|
||||
DELAY_US(2);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// configureDAC - Configure specified DAC output
|
||||
//
|
||||
void configureDAC(Uint16 dac_num)
|
||||
{
|
||||
EALLOW;
|
||||
DAC_PTR[dac_num]->DACCTL.bit.DACREFSEL = REFERENCE;
|
||||
DAC_PTR[dac_num]->DACOUTEN.bit.DACOUTEN = 1;
|
||||
DAC_PTR[dac_num]->DACVALS.all = 0;
|
||||
DELAY_US(10); // Delay for buffered DAC to power up
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,257 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: buffdac_ex2_sine_dma.c
|
||||
//
|
||||
// TITLE: Buffered DAC Sine Wave Output Using DMA Example
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> Buffered DAC Sine DMA (buffdac_sine_dma) </h1>
|
||||
//!
|
||||
//! This example generates a sine wave on the buffered DAC output using the DMA
|
||||
//! to transfer sine values stored in a sine table in GSRAM to DACVALS,
|
||||
//! DACOUTA/ADCINA0 (HSEC Pin 9) and uses the default DAC reference setting
|
||||
//! of VDAC.
|
||||
//!
|
||||
//! When the DAC reference is set to VDAC, an external reference voltage
|
||||
//! must be applied to the VDAC pin. This can accomplished by connecting a
|
||||
//! jumper wire from 3.3V to ADCINB0 (HSEC pin 12).
|
||||
//!
|
||||
//! Run the included .js file to add the watch variables.
|
||||
//!
|
||||
//! outputFreq_hz = (samplingFreq_hz/SINE_TBL_SIZE)*tableStep
|
||||
//!
|
||||
//! The generated waveform can be adjusted with the following variables/macros
|
||||
//! but require recompile:
|
||||
//! - \b waveformGain \b : Adjust the magnitude of the waveform.
|
||||
//! Range is from 0.0 to 1.0. The default value of 0.8003 centers the waveform
|
||||
//! within the linear range of the DAC.
|
||||
//! - \b waveformOffset \b : Adjust the offset of the waveform.
|
||||
//! Range is from -1.0 to 1.0. The default value of 0 centers the waveform.
|
||||
//! - \b samplingFreq_hz \b : Adjust the rate at which the DAC is updated.
|
||||
//! Range - Bounded by cpu timer maximum interrupt rate.
|
||||
//! - \b tableStep \b : The sine table step size.
|
||||
//! Range - Bounded by sine table size, should be much less than sine table size
|
||||
//! to have good resolution.
|
||||
//! - \b REFERENCE \b : The reference for the DAC.
|
||||
//! Range - REFERENCE_VDAC, REFERENCE_VREF
|
||||
//! - \b CPUFREQ_MHZ \b : The cpu frequency. This does not set the cpu frequency.
|
||||
//! Range - See device data manual
|
||||
//! - \b DAC_NUM \b : The DAC to use.
|
||||
//! Range - DACA, DACB, DACC
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "math.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define REFERENCE REFERENCE_VDAC
|
||||
#define CPUFREQ_MHZ 200
|
||||
#define DAC_NUM DACA
|
||||
#define PI 3.14159265
|
||||
#define SINE_TBL_SIZE 360
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 SINE_TBL[SINE_TBL_SIZE];
|
||||
#pragma DATA_SECTION(SINE_TBL, "ramgs0");
|
||||
volatile struct DAC_REGS* DAC_PTR[4] = {0x0,&DacaRegs,&DacbRegs,&DaccRegs};
|
||||
Uint32 samplingFreq_hz = 360000;
|
||||
Uint16 tableStep = 1;
|
||||
float waveformGain = 0.8003F; // Range 0.0 -> 1.0
|
||||
float waveformOffset = 0; // Range -1.0 -> 1.0
|
||||
|
||||
volatile Uint16 *DMADest;
|
||||
volatile Uint16 *DMASource;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void configureDAC(Uint16 dac_num);
|
||||
void configureDMA(Uint16 dac_num);
|
||||
void configureWaveform(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags are cleared.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Clear all interrupts and initialize PIE vector table:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Configure DAC
|
||||
//
|
||||
configureDAC(DAC_NUM);
|
||||
|
||||
//
|
||||
// Configure Waveform
|
||||
//
|
||||
configureWaveform();
|
||||
|
||||
//
|
||||
// Initialize Cpu Timers
|
||||
//
|
||||
InitCpuTimers();
|
||||
|
||||
//
|
||||
// Configure Cpu Timer0 to interrupt at specified sampling frequency
|
||||
//
|
||||
ConfigCpuTimer(&CpuTimer0, CPUFREQ_MHZ, 1000000.0F/samplingFreq_hz);
|
||||
|
||||
//
|
||||
// Configure DMA
|
||||
//
|
||||
configureDMA(DAC_NUM);
|
||||
|
||||
//
|
||||
// Start Cpu Timer0
|
||||
//
|
||||
CpuTimer0Regs.TCR.all = 0x4000;
|
||||
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// configureDAC - Enable and configure the requested DAC module
|
||||
//
|
||||
void configureDAC(Uint16 dac_num)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
DAC_PTR[dac_num]->DACCTL.bit.DACREFSEL = REFERENCE;
|
||||
DAC_PTR[dac_num]->DACOUTEN.bit.DACOUTEN = 1;
|
||||
DAC_PTR[dac_num]->DACVALS.all = 0;
|
||||
|
||||
DELAY_US(10); // Delay for buffered DAC to power up
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// configureDMA - Configures the DMA to read from the SINE table and write to the DAC
|
||||
//
|
||||
void configureDMA(Uint16 dac_num)
|
||||
{
|
||||
//
|
||||
// Initialize DMA
|
||||
//
|
||||
DMAInitialize();
|
||||
|
||||
DMASource = (volatile Uint16 *)&SINE_TBL[0];
|
||||
DMADest = (volatile Uint16 *)&DAC_PTR[dac_num]->DACVALS;
|
||||
|
||||
//
|
||||
// Configure DMA CH1
|
||||
//
|
||||
DMACH1AddrConfig(DMADest,DMASource);
|
||||
DMACH1BurstConfig(0,0,0);
|
||||
DMACH1TransferConfig(SINE_TBL_SIZE/tableStep-1,tableStep,0);
|
||||
DMACH1WrapConfig(SINE_TBL_SIZE/tableStep-1,0,0,0);
|
||||
DMACH1ModeConfig(0,PERINT_ENABLE,ONESHOT_DISABLE,CONT_ENABLE,
|
||||
SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,SIXTEEN_BIT,
|
||||
CHINT_END,CHINT_DISABLE);
|
||||
|
||||
EALLOW;
|
||||
DmaClaSrcSelRegs.DMACHSRCSEL1.bit.CH1 = DMA_TINT0; // Timer0 is DMA trigger
|
||||
EDIS;
|
||||
|
||||
StartDMACH1(); // Start DMA channel
|
||||
}
|
||||
|
||||
//
|
||||
// configureWaveform - Configure the SINE waveform
|
||||
//
|
||||
void configureWaveform(void)
|
||||
{
|
||||
Uint16 j;
|
||||
float offset;
|
||||
float waveformValue;
|
||||
|
||||
//
|
||||
// Fill Sine Table
|
||||
//
|
||||
for(j=0;j<SINE_TBL_SIZE;j++)
|
||||
{
|
||||
SINE_TBL[j] = (sin(j*PI/180.0F)+1.0F)*2047.5F;
|
||||
}
|
||||
|
||||
//
|
||||
// Adjust for Gain and Offset
|
||||
//
|
||||
offset = (SINE_TBL[0] - (SINE_TBL[0]*waveformGain)) + (SINE_TBL[0]*waveformOffset);
|
||||
|
||||
for(j=0;j<SINE_TBL_SIZE;j++)
|
||||
{
|
||||
waveformValue = (SINE_TBL[j]*waveformGain)+offset;
|
||||
SINE_TBL[j] = waveformValue < 0 ? 0 : waveformValue > 4095 ? 4095 : waveformValue;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,7 @@
|
||||
//Add Watch window Variables
|
||||
expRemoveAll()
|
||||
expAdd ("waveformGain")
|
||||
expAdd ("waveformOffset")
|
||||
expAdd ("samplingFreq_hz")
|
||||
expAdd ("tableStep")
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="dma_ex1_gsram_transfer"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_cputimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../dma_ex1_gsram_transfer.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,247 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: dma_gsram_transfer_cpu01.c
|
||||
//
|
||||
// TITLE: DMA GSRAM Transfer
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1>DMA GSRAM Transfer (dma_gsram_transfer)</h1>
|
||||
//!
|
||||
//! This example uses one DMA channel to transfer data from a buffer in
|
||||
//! RAMGS0 to a buffer in RAMGS1. The example sets the DMA channel
|
||||
//! PERINTFRC bit repeatedly until the transfer of 16 bursts (where each
|
||||
//! burst is 8 16-bit words) has been completed. When the whole transfer is
|
||||
//! complete, it will trigger the DMA interrupt.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b sdata - Data to send
|
||||
//! - \b rdata - Received data
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// DMA data sections
|
||||
//
|
||||
#pragma DATA_SECTION(sdata, "ramgs0"); // map the TX data to memory
|
||||
#pragma DATA_SECTION(rdata, "ramgs1"); // map the RX data to memory
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define BURST 7 // write 7 to the register for a burst size of 8
|
||||
#define TRANSFER 15 // [(MEM_BUFFER_SIZE/(BURST + 1)) - 1]
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 sdata[128]; // Send data buffer
|
||||
Uint16 rdata[128]; // Receive data buffer
|
||||
volatile Uint16 *DMADest;
|
||||
volatile Uint16 *DMASource;
|
||||
volatile Uint16 done;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
__interrupt void local_D_INTCH6_ISR(void);
|
||||
void dma_init(void);
|
||||
void error();
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
Uint16 i;
|
||||
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
// InitGpio(); // Skipped for this example
|
||||
|
||||
//
|
||||
// Step 3. Initialize PIE vector table:
|
||||
// Disable and clear all CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize PIE control registers to their default state:
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the default Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
//
|
||||
EALLOW; // This is needed to write to EALLOW protected registers
|
||||
PieVectTable.DMA_CH6_INT= &local_D_INTCH6_ISR;
|
||||
EDIS; // This is needed to disable write to EALLOW protected registers
|
||||
|
||||
//
|
||||
// Step 4. Initialize the Device Peripherals:
|
||||
//
|
||||
dma_init(); // set up the dma
|
||||
|
||||
//
|
||||
// Step 5. User specific code, enable interrupts:
|
||||
// Initialize the data buffers
|
||||
//
|
||||
for(i = 0; i < 128; i++)
|
||||
{
|
||||
sdata[i] = i;
|
||||
rdata[i] = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Enable interrupts required for this example
|
||||
//
|
||||
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
|
||||
PieCtrlRegs.PIEIER7.bit.INTx6 = 1; // Enable PIE Group 7, INT 2 (DMA CH2)
|
||||
IER= M_INT7; // Enable CPU INT6
|
||||
EINT; // Enable Global Interrupts
|
||||
|
||||
StartDMACH6(); // Start DMA channel
|
||||
|
||||
done = 0; // Test is not done yet
|
||||
|
||||
while(!done) // wait until the DMA transfer is complete
|
||||
{
|
||||
EALLOW;
|
||||
DmaRegs.CH6.CONTROL.bit.PERINTFRC = 1;
|
||||
EDIS;
|
||||
|
||||
DELAY_US(1000);
|
||||
}
|
||||
|
||||
//
|
||||
// When the DMA transfer is complete the program will stop here
|
||||
//
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// error - Error Function which will halt the debugger
|
||||
//
|
||||
void error(void)
|
||||
{
|
||||
asm(" ESTOP0"); //Test failed!! Stop!
|
||||
for (;;);
|
||||
}
|
||||
|
||||
//
|
||||
// dma_init - DMA setup for both TX and RX channels.
|
||||
//
|
||||
void dma_init()
|
||||
{
|
||||
//
|
||||
// Refer to dma.c for the descriptions of the following functions.
|
||||
//
|
||||
|
||||
//
|
||||
//Initialize DMA
|
||||
//
|
||||
DMAInitialize();
|
||||
|
||||
DMASource = (volatile Uint16 *)sdata;
|
||||
DMADest = (volatile Uint16 *)rdata;
|
||||
|
||||
//
|
||||
// configure DMA CH6
|
||||
//
|
||||
DMACH6AddrConfig(DMADest,DMASource);
|
||||
DMACH6BurstConfig(BURST,1,1);
|
||||
DMACH6TransferConfig(TRANSFER,1,1);
|
||||
DMACH6ModeConfig(0,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,
|
||||
SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,SIXTEEN_BIT,
|
||||
CHINT_END,CHINT_ENABLE);
|
||||
}
|
||||
|
||||
//
|
||||
// local_D_INTCH6_ISR - DMA Channel6 ISR
|
||||
//
|
||||
__interrupt void local_D_INTCH6_ISR(void)
|
||||
{
|
||||
Uint16 i;
|
||||
|
||||
EALLOW; // NEED TO EXECUTE EALLOW INSIDE ISR !!!
|
||||
DmaRegs.CH6.CONTROL.bit.HALT = 1;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP7; // ACK to receive more interrupts
|
||||
// from this PIE group
|
||||
EDIS;
|
||||
|
||||
for( i = 0; i < 128; i++ )
|
||||
{
|
||||
//
|
||||
// check for data integrity
|
||||
//
|
||||
if (rdata[i] != i)
|
||||
{
|
||||
error();
|
||||
}
|
||||
}
|
||||
|
||||
done = 1; // Test done.
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,30 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="ecap_apwm_cpu01"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_ecap.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../ecap_apwm_cpu01.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,182 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: ecap_apwm_cpu01.c
|
||||
//
|
||||
// TITLE: ECAP APWM Example
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1>ECAP APWM Example</h1>
|
||||
//!
|
||||
//! This program sets up the eCAP pins in the APWM mode.
|
||||
//! This program runs at 200 MHz SYSCLK assuming a 20 MHz
|
||||
//! OSCCLK.
|
||||
//!
|
||||
//! eCAP1 will come out on the GPIO5 pin
|
||||
//! This pin is configured to vary between frequencies using
|
||||
//! the shadow registers to load the next period/compare values
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Define for period count value 20000000U.
|
||||
//
|
||||
#define PERIODCOUNT 0x01312D00
|
||||
|
||||
//
|
||||
// Define for compare count value 10000000U.
|
||||
//
|
||||
#define COMPARECOUNT 0x00989680
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 direction = 0;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to its default state.
|
||||
//
|
||||
// InitGpio(); // Skipped for this example
|
||||
|
||||
//
|
||||
// Initialize the GPIO pins for APWM1.
|
||||
//
|
||||
InitAPwm1Gpio();
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// No interrupts used for this example.
|
||||
//
|
||||
|
||||
//
|
||||
// Step 4. User specific code
|
||||
//
|
||||
|
||||
//
|
||||
// Setup APWM mode on CAP1, set period and compare registers
|
||||
//
|
||||
ECap1Regs.ECCTL2.bit.CAP_APWM = 1; // Enable APWM mode
|
||||
ECap1Regs.CAP1 = PERIODCOUNT; // Set Period value
|
||||
ECap1Regs.CAP2 = COMPARECOUNT; // Set Compare value
|
||||
ECap1Regs.ECCLR.all = 0x0FF; // Clear pending interrupts
|
||||
ECap1Regs.ECEINT.bit.CTR_EQ_CMP = 1; // enable Compare Equal Int
|
||||
|
||||
//
|
||||
// Start counters
|
||||
//
|
||||
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// set next duty cycle to 50%
|
||||
//
|
||||
ECap1Regs.CAP4 = ECap1Regs.CAP1 >> 1;
|
||||
|
||||
//
|
||||
// vary freq
|
||||
//
|
||||
if(ECap1Regs.CAP1 >= PERIODCOUNT)
|
||||
{
|
||||
direction = 0;
|
||||
}
|
||||
else if (ECap1Regs.CAP1 <= COMPARECOUNT)
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
|
||||
if(direction == 0)
|
||||
{
|
||||
ECap1Regs.CAP3 = ECap1Regs.CAP1 - 500000;
|
||||
}
|
||||
else
|
||||
{
|
||||
ECap1Regs.CAP3 = ECap1Regs.CAP1 + 500000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="emif1_ex1_16bit_asram"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_emif.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../emif1_ex1_16bit_asram.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="emif1_ex2_16bit_sdram_far"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_emif.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1_far.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1_far.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../emif1_ex2_16bit_sdram_far.c" targetDirectory="" />
|
||||
<file action="copy" path="../fpu_types.h" targetDirectory="" />
|
||||
<file action="copy" path="../fpu_vector.h" targetDirectory="" />
|
||||
<file action="copy" path="../memcpy_fast_far.asm" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="emif1_ex3_16bit_sdram_dma"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_emif.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1_far.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1_far.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../emif1_ex3_16bit_sdram_dma.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="emif1_ex4_32bit_sdram"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_emif.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1_far.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1_far.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../emif1_ex4_32bit_sdram.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,476 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: emif1_ex1_16bit_asram.c
|
||||
//
|
||||
// TITLE: EMIF1 module accessing 16bit ASRAM.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> EMIF ASYNC module (emif1_16bit_asram)</h1>
|
||||
//!
|
||||
//! This example configures EMIF1 in 16bit ASYNC mode
|
||||
//! This example uses CS2 as chip enable.
|
||||
//!
|
||||
//! \b Watch \b Variables: \n
|
||||
//! - \b TEST_STATUS - Equivalent to \b TEST_PASS if test finished correctly,
|
||||
//! else the value is set to \b TEST_FAIL
|
||||
//! - \b ErrCount - Error counter
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
#define TEST_PASS 0xABCDABCD
|
||||
#define TEST_FAIL 0xDEADDEAD
|
||||
#define ASRAM_CS2_START_ADDR 0x100000
|
||||
#define ASRAM_CS2_SIZE 0x8000
|
||||
#define EMIF1 0
|
||||
#define EMIF2 1
|
||||
#define MEM_D_WIDTH 1 // 16Bit Memory Interface
|
||||
#define TURN_AROUND_TIME 0 // Turn Around time of 2 Emif Clock
|
||||
#define RD_SETUP_TIME 0 // Read Setup time of 1 Emif Clock
|
||||
#define RD_STROBE_TIME 3 // Read Strobe time of 4 Emif Clock
|
||||
#define RD_HOLD_TIME 0 // Read Hold time of 1 Emif Clock
|
||||
#define WR_SETUP_TIME 0 // Write Hold time of 1 Emif Clock
|
||||
#define WR_STROBE_TIME 0 // Write Setup time of 1 Emif Clock
|
||||
#define WR_HOLD_TIME 0 // Write Hold time of 1 Emif Clock
|
||||
#define EXTEND_WAIT 0 // Disable Extended Wait
|
||||
#define STROBE_SEL 0 // Disable Strobe Mode.
|
||||
#define WAIT_POLAR_INV 0
|
||||
#define WAIT_COUNT 0
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 ErrCount = 0;
|
||||
Uint32 TEST_STATUS;
|
||||
int i;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
extern void setup_emif1_pinmux_async_16bit(Uint16);
|
||||
|
||||
//
|
||||
// mem_read_write - This function performs simple read/write word accesses
|
||||
// to memory.
|
||||
//
|
||||
char
|
||||
mem_read_write(Uint32 start_addr, Uint32 mem_size)
|
||||
{
|
||||
unsigned long mem_rds;
|
||||
unsigned long mem_wds;
|
||||
long *XMEM_ps;
|
||||
unsigned int i;
|
||||
|
||||
//
|
||||
//Write data
|
||||
//
|
||||
XMEM_ps = (long *)start_addr;
|
||||
|
||||
//
|
||||
//Fill memory
|
||||
//
|
||||
mem_wds = 0x01234567;
|
||||
for (i=0; i < mem_size; i++)
|
||||
{
|
||||
*XMEM_ps++ = mem_wds;
|
||||
mem_wds += 0x11111111;
|
||||
}
|
||||
|
||||
//
|
||||
//Verify memory
|
||||
//
|
||||
mem_wds = 0x01234567;
|
||||
XMEM_ps = (long *)start_addr;
|
||||
for (i=0; i < mem_size; i++)
|
||||
{
|
||||
mem_rds = *XMEM_ps;
|
||||
if( mem_rds != mem_wds)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
XMEM_ps++;
|
||||
mem_wds += 0x11111111;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// mem_data_walk - This function performs a walking 0 & 1 on data lines for
|
||||
// SRAM RD & WR
|
||||
//
|
||||
char
|
||||
mem_data_walk(Uint32 start_addr, Uint32 mem_size)
|
||||
{
|
||||
unsigned long sram_rd;
|
||||
unsigned long sram_wd;
|
||||
unsigned long i;
|
||||
int k;
|
||||
int m;
|
||||
unsigned long *XM_p;
|
||||
unsigned long *XMEM_p;
|
||||
|
||||
XM_p = (unsigned long *)start_addr;
|
||||
|
||||
for (i=0; i < mem_size; i=i+64)
|
||||
{
|
||||
for (m=0; m < 2; m++)
|
||||
{
|
||||
//
|
||||
//Write loop
|
||||
//
|
||||
XMEM_p = XM_p;
|
||||
sram_wd = 0x01;
|
||||
for (k=0; k < 32; k++)
|
||||
{
|
||||
if(m==0)
|
||||
{
|
||||
*XMEM_p++ = sram_wd;
|
||||
}
|
||||
else
|
||||
{
|
||||
*XMEM_p++ = ~sram_wd;
|
||||
}
|
||||
sram_wd = sram_wd<<1;
|
||||
}
|
||||
|
||||
//
|
||||
//Read loop
|
||||
//
|
||||
XMEM_p = XM_p;
|
||||
sram_wd = 0x01;
|
||||
for (k=0; k < 32; k++)
|
||||
{
|
||||
sram_rd = *XMEM_p;
|
||||
if(m==1)
|
||||
{
|
||||
sram_rd = ~sram_rd;
|
||||
}
|
||||
if(sram_rd != sram_wd)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
XMEM_p++;
|
||||
sram_wd=sram_wd<<1;
|
||||
}
|
||||
}
|
||||
XM_p = XMEM_p;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// mem_addr_walk - This function performs a toggle on each address bit.
|
||||
//
|
||||
char
|
||||
mem_addr_walk(Uint32 start_addr, Uint32 addr_size)
|
||||
{
|
||||
unsigned long sram_rd;
|
||||
unsigned long sram_wd;
|
||||
unsigned int k;
|
||||
unsigned long xshift;
|
||||
unsigned long *XM_p;
|
||||
unsigned long *XMEM_p;
|
||||
|
||||
XM_p = (unsigned long *)start_addr;
|
||||
|
||||
//
|
||||
//Write loop
|
||||
//
|
||||
xshift = 0x00000001;
|
||||
sram_wd = 0x00;
|
||||
for (k=0; k < addr_size; k++)
|
||||
{
|
||||
XMEM_p = (unsigned long *)(start_addr + xshift);
|
||||
*XMEM_p = sram_wd++;
|
||||
xshift = xshift<<1;
|
||||
}
|
||||
|
||||
//
|
||||
//Read loop
|
||||
//
|
||||
XMEM_p = XM_p;
|
||||
xshift = 0x00000001;
|
||||
sram_wd = 0x00;
|
||||
for (k=0; k < addr_size; k++)
|
||||
{
|
||||
XMEM_p = (unsigned long *)(start_addr + xshift);
|
||||
sram_rd = *XMEM_p;
|
||||
if(sram_rd != sram_wd)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
|
||||
xshift = xshift<<1;
|
||||
sram_wd++;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// mem_data_size - This function performs different data type
|
||||
// (HALFWORD/WORD) access.
|
||||
//
|
||||
char
|
||||
mem_data_size(Uint32 start_addr, Uint32 size_to_check)
|
||||
{
|
||||
unsigned short mem_rds;
|
||||
unsigned long mem_rdl;
|
||||
unsigned short mem_wds;
|
||||
unsigned long mem_wdl;
|
||||
int i;
|
||||
|
||||
short *XMEM_ps;
|
||||
long *XMEM_pl;
|
||||
|
||||
//
|
||||
//Write data short
|
||||
//
|
||||
XMEM_ps = (short *)start_addr;
|
||||
mem_wds = 0x0605;
|
||||
|
||||
for (i=0; i < 2; i++)
|
||||
{
|
||||
*XMEM_ps++ = mem_wds;
|
||||
mem_wds += 0x0202;
|
||||
}
|
||||
|
||||
//
|
||||
//Write data long
|
||||
//
|
||||
XMEM_pl = (long *)XMEM_ps;
|
||||
mem_wdl = 0x0C0B0A09;
|
||||
for (i=0; i < 2; i++)
|
||||
{
|
||||
*XMEM_pl++ = mem_wdl;
|
||||
mem_wdl += 0x04040404;
|
||||
}
|
||||
|
||||
//
|
||||
//Read data short
|
||||
//
|
||||
XMEM_ps = (short *)start_addr;
|
||||
mem_wds = 0x0605;
|
||||
for (i=0; i < 6; i++)
|
||||
{
|
||||
mem_rds = *XMEM_ps;
|
||||
if( mem_rds != mem_wds)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
XMEM_ps++;
|
||||
mem_wds += 0x0202;
|
||||
}
|
||||
|
||||
//
|
||||
//Read data long
|
||||
//
|
||||
XMEM_pl = (long *)start_addr;
|
||||
mem_wdl = 0x08070605;
|
||||
for (i=0; i < 3; i++)
|
||||
{
|
||||
mem_rdl = *XMEM_pl;
|
||||
if(mem_rdl != mem_wdl)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
XMEM_pl++;
|
||||
mem_wdl += 0x04040404;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
char ErrCount_local;
|
||||
TEST_STATUS = TEST_FAIL;
|
||||
|
||||
//
|
||||
// Initialize system control
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
EALLOW;
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// GService Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
//Configure to run EMIF1 on full Rate (EMIF1CLK = CPU1SYSCLK)
|
||||
//
|
||||
EALLOW;
|
||||
ClkCfgRegs.PERCLKDIVSEL.bit.EMIF1CLKDIV = 0x0;
|
||||
EDIS;
|
||||
|
||||
EALLOW;
|
||||
//
|
||||
// Grab EMIF1 For CPU1
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1MSEL.all = 0x93A5CE71;
|
||||
if(Emif1ConfigRegs.EMIF1MSEL.all != 0x1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
//Disable Access Protection (CPU_FETCH/CPU_WR/DMA_WR)
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1ACCPROT0.all = 0x0;
|
||||
if(Emif1ConfigRegs.EMIF1ACCPROT0.all != 0x0)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Commit the configuration related to protection. Till this bit remains set
|
||||
// content of EMIF1ACCPROT0 register can't be changed.
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1COMMIT.all = 0x1;
|
||||
if(Emif1ConfigRegs.EMIF1COMMIT.all != 0x1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Lock the configuration so that EMIF1COMMIT register can't be
|
||||
// changed any more.
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1LOCK.all = 0x1;
|
||||
if(Emif1ConfigRegs.EMIF1LOCK.all != 1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
EDIS;
|
||||
|
||||
//
|
||||
//Configure GPIO pins for EMIF1
|
||||
//
|
||||
setup_emif1_pinmux_async_16bit(0);
|
||||
|
||||
//
|
||||
//Configure the access timing for CS2 space
|
||||
//
|
||||
Emif1Regs.ASYNC_CS2_CR.all = (EMIF_ASYNC_ASIZE_16 | // 16Bit Memory
|
||||
// Interface
|
||||
EMIF_ASYNC_TA_1 | // Turn Around time
|
||||
// of 2 Emif Clock
|
||||
EMIF_ASYNC_RHOLD_1 | // Read Hold time
|
||||
// of 1 Emif Clock
|
||||
EMIF_ASYNC_RSTROBE_4 | // Read Strobe time
|
||||
// of 4 Emif Clock
|
||||
EMIF_ASYNC_RSETUP_1 | // Read Setup time
|
||||
// of 1 Emif Clock
|
||||
EMIF_ASYNC_WHOLD_1 | // Write Hold time
|
||||
// of 1 Emif Clock
|
||||
EMIF_ASYNC_WSTROBE_1 | // Write Strobe time
|
||||
// of 1 Emif Clock
|
||||
EMIF_ASYNC_WSETUP_1 | // Write Setup time
|
||||
// of 1 Emif Clock
|
||||
EMIF_ASYNC_EW_DISABLE | // Extended Wait
|
||||
// Disable.
|
||||
EMIF_ASYNC_SS_DISABLE // Strobe Select Mode
|
||||
// Disable.
|
||||
);
|
||||
|
||||
//
|
||||
//Check basic RD/WR access to CS2 space
|
||||
//
|
||||
ErrCount_local = mem_read_write(ASRAM_CS2_START_ADDR, ASRAM_CS2_SIZE);
|
||||
ErrCount = ErrCount + ErrCount_local;
|
||||
|
||||
//
|
||||
//Address walk checks (Tested for Memory with address width of 16bit)
|
||||
//
|
||||
ErrCount_local = mem_addr_walk(ASRAM_CS2_START_ADDR, 16);
|
||||
ErrCount = ErrCount + ErrCount_local;
|
||||
|
||||
//
|
||||
//Data walk checks
|
||||
//
|
||||
ErrCount_local = mem_data_walk(ASRAM_CS2_START_ADDR, ASRAM_CS2_SIZE);
|
||||
ErrCount = ErrCount + ErrCount_local;
|
||||
|
||||
//
|
||||
//Data size checks
|
||||
//
|
||||
ErrCount_local = mem_data_size(ASRAM_CS2_START_ADDR, 4);
|
||||
ErrCount = ErrCount + ErrCount_local;
|
||||
|
||||
if (ErrCount == 0x0)
|
||||
{
|
||||
TEST_STATUS = TEST_PASS;
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,323 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: emif1_ex2_16bit_sdram_far.c
|
||||
//
|
||||
// TITLE: EMIF1 module accessing 32bit SDRAM using memcpy_fast_far()
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> EMIF1 SDRAM Module (emif1_16bit_sdram_far)</h1>
|
||||
//!
|
||||
//! This example configures EMIF1 in 16bit SDRAM mode and uses
|
||||
//! CS0 (SDRAM) as chip enable. It will first write to an array
|
||||
//! in the SDRAM and then read it back using the FPU function,
|
||||
//! memcpy_fast_far(), for both operations.
|
||||
//! The buffer in SDRAM will be placed in the .farbss memory on
|
||||
//! account of the fact that its assigned the attribute "far"
|
||||
//! indicating it lies beyond the 22-bit program address space.
|
||||
//! The compiler will take care to avoid using instructions such
|
||||
//! as PREAD, which uses the Program Read Bus, or addressing
|
||||
//! modes restricted to the lower 22-bit space when accessing
|
||||
//! data with the attribute "far"
|
||||
//! \note The memory space beyond 22-bits must be treated as data space
|
||||
//! for load/store operations only. The user is cautioned against using
|
||||
//! this space for either instructions or working memory.
|
||||
//!
|
||||
//! \b Watch \b Variables: \n
|
||||
//! - \b TEST_STATUS - Equivalent to \b TEST_PASS if test finished correctly,
|
||||
//! else the value is set to \b TEST_FAIL
|
||||
//! - \b ErrCount - Error counter
|
||||
//!
|
||||
//
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "fpu_vector.h" // FPU headerfile to access memcpy_fast_far()
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define TEST_PASS 0xABCDABCD
|
||||
#define TEST_FAIL 0xDEADDEAD
|
||||
#define MEM_BUFFER_SIZE 0x500 // 32-Bit Word
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
#pragma DATA_SECTION(g_ulLocalRAMBuf, "ramgs0");
|
||||
Uint32 g_ulLocalRAMBuf[MEM_BUFFER_SIZE]; //Buffer in local memory
|
||||
__attribute__((far)) volatile Uint32 g_ulSDRAMBuf[MEM_BUFFER_SIZE]; //Buffer in
|
||||
//far memory
|
||||
Uint16 ErrCount = 0;
|
||||
Uint32 TEST_STATUS;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
extern void setup_emif1_pinmux_sdram_16bit(Uint16);
|
||||
|
||||
//
|
||||
// DataBufferClear - Clear local and far memory buffers
|
||||
//
|
||||
void
|
||||
DataBufferClear(Uint32 mem_size)
|
||||
{
|
||||
Uint32 i;
|
||||
Uint32 mem_wdl = 0x0;
|
||||
|
||||
//
|
||||
// Clear far memory buffer
|
||||
//
|
||||
for (i=0; i < mem_size; i++)
|
||||
{
|
||||
memcpy_fast_far((g_ulSDRAMBuf + i), &mem_wdl, 2);
|
||||
}
|
||||
|
||||
//
|
||||
// Clear local memory buffer
|
||||
//
|
||||
for(i = 0; i < mem_size; i++)
|
||||
{
|
||||
g_ulLocalRAMBuf[i] = mem_wdl;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// sdram_read_write - Write data into far memory buffer, read far data into
|
||||
// local memory buffer and verify contents
|
||||
//
|
||||
char
|
||||
sdram_read_write(Uint32 mem_size)
|
||||
{
|
||||
Uint32 mem_wdl;
|
||||
Uint32 i;
|
||||
|
||||
//
|
||||
// Fill far memory buffer with data
|
||||
//
|
||||
mem_wdl = 0x0;
|
||||
for (i=0; i < mem_size; i++)
|
||||
{
|
||||
memcpy_fast_far((g_ulSDRAMBuf + i), &mem_wdl, 2);
|
||||
mem_wdl += 0x00050001;
|
||||
}
|
||||
|
||||
//
|
||||
// Read far memory buffer into local buffer and verify data
|
||||
//
|
||||
mem_wdl = 0x0;
|
||||
for (i=0; i < mem_size; i++)
|
||||
{
|
||||
memcpy_fast_far((g_ulLocalRAMBuf + i), (g_ulSDRAMBuf + i), 2);
|
||||
|
||||
//
|
||||
// Return error if read data is incorrect
|
||||
//
|
||||
if(g_ulLocalRAMBuf[i] != mem_wdl)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
mem_wdl += 0x00050001;
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
int i;
|
||||
char ErrCount_local;
|
||||
TEST_STATUS = TEST_FAIL;
|
||||
|
||||
//
|
||||
// Initialize the device system and clocking
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Disable interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
EALLOW;
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// GService Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
EALLOW;
|
||||
EINT;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Configure to run EMIF1 on half Rate (EMIF1CLK = CPU1SYSCLK/2)
|
||||
//
|
||||
EALLOW;
|
||||
ClkCfgRegs.PERCLKDIVSEL.bit.EMIF1CLKDIV = 0x1;
|
||||
EDIS;
|
||||
|
||||
EALLOW;
|
||||
//
|
||||
// Grab EMIF1 For CPU1
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1MSEL.all = 0x93A5CE71;
|
||||
if (Emif1ConfigRegs.EMIF1MSEL.all != 0x1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Disable Access Protection (CPU_FETCH/CPU_WR/DMA_WR)
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1ACCPROT0.all = 0x0;
|
||||
if (Emif1ConfigRegs.EMIF1ACCPROT0.all != 0x0)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Commit the configuration related to protection. Till this bit remains
|
||||
// set content of EMIF1ACCPROT0 register can't be changed.
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1COMMIT.all = 0x1;
|
||||
if(Emif1ConfigRegs.EMIF1COMMIT.all != 0x1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Lock the configuration so that EMIF1COMMIT register can't be changed
|
||||
// any more.
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1LOCK.all = 0x1;
|
||||
if (Emif1ConfigRegs.EMIF1LOCK.all != 1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Configure GPIO pins for EMIF1
|
||||
//
|
||||
setup_emif1_pinmux_sdram_16bit(0);
|
||||
|
||||
//
|
||||
// Configure SDRAM control registers
|
||||
//
|
||||
// Need to be programmed based on SDRAM Data-Sheet.
|
||||
//T_RFC = 60ns = 0x6
|
||||
//T_RP = 18ns = 0x1
|
||||
//T_RCD = 18ns = 0x1
|
||||
//T_WR = 1CLK + 6 ns = 0x1
|
||||
//T_RAS = 42ns = 0x4
|
||||
//T_RC = 60ns = 0x6
|
||||
//T_RRD = 12ns = 0x1
|
||||
//
|
||||
Emif1Regs.SDRAM_TR.all = 0x31114610;
|
||||
|
||||
//
|
||||
//Txsr = 70ns = 0x7
|
||||
//
|
||||
Emif1Regs.SDR_EXT_TMNG.all = 0x7;
|
||||
|
||||
//
|
||||
//Tref = 64ms for 8192 ROW, RR = 64000*100(Tfrq)/8192 = 781.25 (0x30E)
|
||||
//
|
||||
Emif1Regs.SDRAM_RCR.all = 0x30E;
|
||||
|
||||
//
|
||||
//PAGESIZE=2 (1024 elements per ROW), IBANK = 2 (4 BANK), CL = 3,
|
||||
//NM = 1 (16bit)
|
||||
//
|
||||
Emif1Regs.SDRAM_CR.all = 0x00015622;
|
||||
|
||||
//
|
||||
//Add some delay
|
||||
//
|
||||
for(i=0;i<123;i++) { }
|
||||
|
||||
//
|
||||
//Clear local and far memory buffers
|
||||
//
|
||||
DataBufferClear(MEM_BUFFER_SIZE);
|
||||
|
||||
//
|
||||
//Basic read/write check.
|
||||
//
|
||||
ErrCount_local = sdram_read_write(MEM_BUFFER_SIZE);
|
||||
ErrCount = ErrCount + ErrCount_local;
|
||||
|
||||
if (ErrCount == 0x0)
|
||||
{
|
||||
TEST_STATUS = TEST_PASS;
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,364 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: emif1_ex3_16bit_sdram_dma.c
|
||||
//
|
||||
// TITLE: EMIF1 module accessing 32bit SDRAM using the DMA.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> EMIF1 SDRAM Module (emif1_16bit_sdram_dma)</h1>
|
||||
//!
|
||||
//! This example configures EMIF1 in 16bit SDRAM mode and uses
|
||||
//! CS0 (SDRAM) as chip enable. It will first write to an array
|
||||
//! in the SDRAM and then read it back using the DMA for both
|
||||
//! operations.
|
||||
//! The buffer in SDRAM will be placed in the .farbss memory on
|
||||
//! account of the fact that its assigned the attribute "far"
|
||||
//! indicating it lies beyond the 22-bit program address space.
|
||||
//! The compiler will take care to avoid using instructions such
|
||||
//! as PREAD, which uses the Program Read Bus, or addressing
|
||||
//! modes restricted to the lower 22-bit space when accessing
|
||||
//! data with the attribute "far"
|
||||
//! \note The memory space beyond 22-bits must be treated as data space
|
||||
//! for load/store operations only. The user is cautioned against using
|
||||
//! this space for either instructions or working memory.
|
||||
//!
|
||||
//! Example has been tested using Micron 48LC32M16A2 "P -75 C" part.
|
||||
//!
|
||||
//! \b Watch \b Variables: \n
|
||||
//! - \b TEST_STATUS - Equivalent to \b TEST_PASS if test finished correctly,
|
||||
//! else the value is set to \b TEST_FAIL
|
||||
//! - \b ErrCount - Error counter
|
||||
//!
|
||||
//
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define TEST_PASS 0xABCDABCD
|
||||
#define TEST_FAIL 0xDEADDEAD
|
||||
#define SDRAM_CS0_START_ADDR 0x80000000
|
||||
#define SDRAM_CS0_SIZE 0x300000
|
||||
#define MEM_BUFFER_SIZE 1024 // 32-Bit Word
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
#pragma DATA_SECTION(g_ulSrcBuf0, "ramgs0");
|
||||
#pragma DATA_SECTION(g_ulDstBuf1, "ramgs1");
|
||||
Uint32 g_ulSrcBuf0[MEM_BUFFER_SIZE];
|
||||
Uint32 g_ulDstBuf1[MEM_BUFFER_SIZE];
|
||||
//Buffer in far memory
|
||||
__attribute__((far)) volatile Uint32 g_ulSDRAMBuf[MEM_BUFFER_SIZE];
|
||||
volatile Uint32 InitData = 0;
|
||||
volatile Uint32 *DMADest;
|
||||
volatile Uint32 *DMASource;
|
||||
Uint16 ErrCount = 0;
|
||||
Uint32 TEST_STATUS;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
extern void setup_emif1_pinmux_sdram_16bit(Uint16);
|
||||
|
||||
//
|
||||
// DMA_DstDataClear - Clear local and far memory buffers
|
||||
//
|
||||
void DMA_DstDataClear()
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MEM_BUFFER_SIZE; i++)
|
||||
{
|
||||
__addr32_write_uint32(((Uint32)g_ulSDRAMBuf + (i*2)), 0x0);
|
||||
}
|
||||
|
||||
for(i = 0; i < MEM_BUFFER_SIZE; i++)
|
||||
{
|
||||
g_ulDstBuf1[i] = 0x0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
int i;
|
||||
TEST_STATUS = TEST_FAIL;
|
||||
|
||||
//
|
||||
// Initialize System control
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
EALLOW;
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// GService Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
EALLOW;
|
||||
EINT;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
//Configure to run EMIF1 on half Rate (EMIF1CLK = CPU1SYSCLK/2)
|
||||
//
|
||||
EALLOW;
|
||||
ClkCfgRegs.PERCLKDIVSEL.bit.EMIF1CLKDIV = 0x1;
|
||||
EDIS;
|
||||
|
||||
EALLOW;
|
||||
//
|
||||
// Grab EMIF1 For CPU1
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1MSEL.all = 0x93A5CE71;
|
||||
if(Emif1ConfigRegs.EMIF1MSEL.all != 0x1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Disable Access Protection (CPU_FETCH/CPU_WR/DMA_WR)
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1ACCPROT0.all = 0x0;
|
||||
if(Emif1ConfigRegs.EMIF1ACCPROT0.all != 0x0)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Commit the configuration related to protection. Till this bit remains set
|
||||
// content of EMIF1ACCPROT0 register can't be changed.
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1COMMIT.all = 0x1;
|
||||
if(Emif1ConfigRegs.EMIF1COMMIT.all != 0x1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Lock the configuration so that EMIF1COMMIT register can't be changed any
|
||||
// more.
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1LOCK.all = 0x1;
|
||||
if(Emif1ConfigRegs.EMIF1LOCK.all != 1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Initialize source buffer for DMA transfer.
|
||||
//
|
||||
InitData = 0x12103456;
|
||||
for(i = 0; i < MEM_BUFFER_SIZE; i++)
|
||||
{
|
||||
InitData = InitData + 0x11111111;
|
||||
g_ulSrcBuf0[i] = InitData;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize DMA
|
||||
//
|
||||
DMAInitialize();
|
||||
|
||||
//
|
||||
// Configure DMA Channel 1 (16-bit datasize)
|
||||
//
|
||||
DMADest = g_ulSDRAMBuf;
|
||||
DMASource = (volatile Uint32 *)g_ulSrcBuf0;
|
||||
DMACH1AddrConfig32bit(DMADest,DMASource);
|
||||
|
||||
//
|
||||
//Will set up to use 16-bit datasize, pointers are based on 16-bit words
|
||||
//
|
||||
DMACH1BurstConfig(31,1,1);
|
||||
|
||||
DMACH1TransferConfig(((MEM_BUFFER_SIZE*2/32) -1),1,1);
|
||||
DMACH1WrapConfig(0xFFFF,0,0xFFFF,0);
|
||||
|
||||
//
|
||||
//Since this is a static copy use one shot mode, so only one trigger is needed
|
||||
//Also using 16-bit mode
|
||||
//
|
||||
DMACH1ModeConfig(0x0,PERINT_ENABLE,ONESHOT_ENABLE,
|
||||
CONT_DISABLE,SYNC_DISABLE,SYNC_SRC,
|
||||
OVRFLOW_DISABLE,SIXTEEN_BIT,CHINT_END,CHINT_ENABLE);
|
||||
|
||||
//
|
||||
// Configure DMA Channel 2 (32-bit datasize)
|
||||
//
|
||||
DMADest = (volatile Uint32 *)g_ulDstBuf1;
|
||||
DMASource = g_ulSDRAMBuf;
|
||||
DMACH2AddrConfig32bit(DMADest,DMASource);
|
||||
|
||||
//
|
||||
// Will set up to use 32-bit datasize, pointers are based on 32-bit words
|
||||
//
|
||||
DMACH2BurstConfig(31,2,2);
|
||||
|
||||
DMACH2TransferConfig(((MEM_BUFFER_SIZE*2/32) -1),2,2);
|
||||
DMACH2WrapConfig(0xFFFF,0,0xFFFF,0);
|
||||
|
||||
//
|
||||
//Since this is a static copy use one shot mode, so only one trigger is needed
|
||||
//Also using 32-bit mode
|
||||
//
|
||||
DMACH2ModeConfig(0x0,PERINT_ENABLE,ONESHOT_ENABLE,CONT_DISABLE,
|
||||
SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,
|
||||
THIRTYTWO_BIT,CHINT_END,CHINT_ENABLE);
|
||||
|
||||
StartDMACH1();
|
||||
StartDMACH2();
|
||||
|
||||
//
|
||||
//Configure GPIO pins for EMIF1
|
||||
//
|
||||
setup_emif1_pinmux_sdram_16bit(0);
|
||||
|
||||
//
|
||||
//Configure SDRAM control registers
|
||||
//
|
||||
// Need to be programmed based on SDRAM Data-Sheet.
|
||||
//T_RFC = 60ns = 0x6
|
||||
//T_RP = 18ns = 0x1
|
||||
//T_RCD = 18ns = 0x1
|
||||
//T_WR = 1CLK + 6 ns = 0x1
|
||||
//T_RAS = 42ns = 0x4
|
||||
//T_RC = 60ns = 0x6
|
||||
//T_RRD = 12ns = 0x1
|
||||
//
|
||||
Emif1Regs.SDRAM_TR.all = 0x31114610;
|
||||
|
||||
//
|
||||
//Txsr = 70ns = 0x7
|
||||
//
|
||||
Emif1Regs.SDR_EXT_TMNG.all = 0x7;
|
||||
|
||||
//
|
||||
//Tref = 64ms for 8192 ROW, RR = 64000*100(Tfrq)/8192 = 781.25 (0x30E)
|
||||
//
|
||||
Emif1Regs.SDRAM_RCR.all = 0x30E;
|
||||
|
||||
//
|
||||
//PAGESIZE=2 (1024 elements per ROW), IBANK = 2 (4 BANK), CL = 3, NM = 1 (16bit)
|
||||
//
|
||||
Emif1Regs.SDRAM_CR.all = 0x00015622;
|
||||
|
||||
//
|
||||
//Add some delay
|
||||
//
|
||||
for(i=0;i<123;i++) { }
|
||||
|
||||
//
|
||||
// Clear the Data from DMA Destination Address
|
||||
//
|
||||
DMA_DstDataClear();
|
||||
|
||||
//
|
||||
//WRITE TO EXT MEM (16-bit)
|
||||
//
|
||||
EALLOW;
|
||||
DmaRegs.CH1.CONTROL.bit.PERINTFRC = 1;
|
||||
while (DmaRegs.CH1.CONTROL.bit.TRANSFERSTS != 1){};
|
||||
while (DmaRegs.CH1.CONTROL.bit.TRANSFERSTS != 0){};
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// READ FROM EXT MEM (32-bit)
|
||||
//
|
||||
EALLOW;
|
||||
DmaRegs.CH2.CONTROL.bit.PERINTFRC = 1;
|
||||
while (DmaRegs.CH2.CONTROL.bit.TRANSFERSTS != 1){};
|
||||
while (DmaRegs.CH2.CONTROL.bit.TRANSFERSTS != 0){};
|
||||
EDIS;
|
||||
|
||||
//
|
||||
//Compare the Data
|
||||
//
|
||||
for (i = 0 ; i< MEM_BUFFER_SIZE ; i++)
|
||||
{
|
||||
if(g_ulSrcBuf0[i] != g_ulDstBuf1[i])
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if(ErrCount == 0x0)
|
||||
{
|
||||
TEST_STATUS = TEST_PASS;
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,477 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: emif1_ex4_32bit_sdram.c
|
||||
//
|
||||
// TITLE: EMIF1 module accessing 32bit SDRAM.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> EMIF1 SDRAM Module (emif1_32bit_sdram)</h1>
|
||||
//!
|
||||
//! This example configures EMIF1 in 32bit SDRAM mode.
|
||||
//! This example uses CS0 (SDRAM) as chip enable.
|
||||
//!
|
||||
//! \b Watch \b Variables: \n
|
||||
//! - \b TEST_STATUS - Equivalent to \b TEST_PASS if test finished correctly,
|
||||
//! else the value is set to \b TEST_FAIL
|
||||
//! - \b ErrCount - Error counter
|
||||
//!
|
||||
//
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define TEST_PASS 0xABCDABCD
|
||||
#define TEST_FAIL 0xDEADDEAD
|
||||
#define SDRAM_CS0_START_ADDR 0x80000000
|
||||
#define SDRAM_CS0_SIZE 0x300000
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 ErrCount = 0;
|
||||
Uint32 TEST_STATUS;
|
||||
int i;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
extern void setup_emif1_pinmux_sdram_32bit(Uint16);
|
||||
|
||||
//
|
||||
// sdram_data_walk - This function performs a walking 0 & 1 For SDRAM RD & WR
|
||||
//
|
||||
char
|
||||
sdram_data_walk(Uint32 start_addr, Uint32 mem_size)
|
||||
{
|
||||
Uint32 XM_p, XMEM_p;
|
||||
unsigned long sdram_rdl;
|
||||
unsigned long sdram_wdl;
|
||||
int i;
|
||||
int k;
|
||||
int m;
|
||||
|
||||
XM_p = start_addr;
|
||||
|
||||
for (i=0; i < mem_size; i=i+64)
|
||||
{
|
||||
for (m=0; m < 2; m++)
|
||||
{
|
||||
XMEM_p = XM_p;
|
||||
|
||||
//
|
||||
//Write loop
|
||||
//
|
||||
sdram_wdl = 0x0001;
|
||||
for (k=0; k < 32; k++)
|
||||
{
|
||||
if(m==0)
|
||||
{
|
||||
__addr32_write_uint32(XMEM_p, sdram_wdl);
|
||||
}
|
||||
else
|
||||
{
|
||||
__addr32_write_uint32(XMEM_p, ~sdram_wdl);
|
||||
}
|
||||
XMEM_p = XMEM_p+2;
|
||||
sdram_wdl = sdram_wdl<<1;
|
||||
}
|
||||
|
||||
//
|
||||
//Read loop
|
||||
//
|
||||
XMEM_p = XM_p;
|
||||
sdram_wdl = 0x0001;
|
||||
for (k=0; k < 32; k++)
|
||||
{
|
||||
sdram_rdl = __addr32_read_uint32(XMEM_p);
|
||||
if(m==1)
|
||||
{
|
||||
sdram_rdl = ~sdram_rdl;
|
||||
}
|
||||
if(sdram_rdl != sdram_wdl)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
|
||||
XMEM_p = XMEM_p+2;
|
||||
sdram_wdl=sdram_wdl<<1;
|
||||
}
|
||||
}
|
||||
XM_p = XMEM_p;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// sdram_addr_walk - This function performs a toggle on each address bit.
|
||||
// In this case memory assumed is 4Mb.
|
||||
// MA = BA[1:0]ROW[11:0]COL[7:0]
|
||||
//
|
||||
char
|
||||
sdram_addr_walk(Uint32 start_addr, Uint32 addr_size)
|
||||
{
|
||||
Uint32 XMEM_p;
|
||||
unsigned long sdram_rdl;
|
||||
unsigned long sdram_wdl;
|
||||
int i;
|
||||
unsigned long xshift;
|
||||
unsigned long xshift2;
|
||||
|
||||
//
|
||||
//Write loop
|
||||
//
|
||||
xshift = 0x00000001;
|
||||
sdram_wdl = 0x5678abcd;
|
||||
for (i=0; i < addr_size; i++)
|
||||
{
|
||||
xshift2 = ((xshift+1)<<1);
|
||||
XMEM_p = start_addr + xshift2;
|
||||
__addr32_write_uint32(XMEM_p, sdram_wdl);
|
||||
sdram_wdl = sdram_wdl+0x11111111;
|
||||
xshift = xshift<<1;
|
||||
}
|
||||
|
||||
//
|
||||
//Read loop
|
||||
//
|
||||
xshift = 0x00000001;
|
||||
sdram_wdl = 0x5678abcd;
|
||||
for (i=0; i < addr_size; i++)
|
||||
{
|
||||
xshift2 = ((xshift+1)<<1);
|
||||
XMEM_p= start_addr + xshift2;
|
||||
sdram_rdl = __addr32_read_uint32(XMEM_p);
|
||||
if( sdram_rdl != sdram_wdl)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
xshift = xshift<<1;
|
||||
sdram_wdl = sdram_wdl + 0x11111111;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// sdram_data_size - This function performs different data type
|
||||
// (HALFWORD/WORD) access.
|
||||
//
|
||||
char
|
||||
sdram_data_size(Uint32 start_addr, Uint32 mem_size)
|
||||
{
|
||||
unsigned short sdram_rds;
|
||||
unsigned long sdram_rdl;
|
||||
unsigned short sdram_wds;
|
||||
unsigned long sdram_wdl;
|
||||
int i;
|
||||
Uint32 XMEM_p;
|
||||
|
||||
//
|
||||
//Write data short
|
||||
//
|
||||
XMEM_p = start_addr;
|
||||
sdram_wds = 0x0605;
|
||||
for (i=0; i < 2; i++)
|
||||
{
|
||||
__addr32_write_uint16(XMEM_p, sdram_wds);
|
||||
XMEM_p++;
|
||||
sdram_wds += 0x0202;
|
||||
}
|
||||
|
||||
//
|
||||
//Write data long
|
||||
//
|
||||
sdram_wdl = 0x0C0B0A09;
|
||||
for (i=0; i < 2; i++)
|
||||
{
|
||||
__addr32_write_uint32(XMEM_p, sdram_wdl);
|
||||
XMEM_p = XMEM_p+2;
|
||||
sdram_wdl += 0x04040404;
|
||||
}
|
||||
|
||||
//
|
||||
//Read data short
|
||||
//
|
||||
XMEM_p = start_addr;
|
||||
sdram_wds=0x0605;
|
||||
for (i=0; i < 6; i++)
|
||||
{
|
||||
sdram_rds = __addr32_read_uint16(XMEM_p);
|
||||
if( sdram_rds != sdram_wds)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
XMEM_p++;
|
||||
sdram_wds += 0x0202;
|
||||
}
|
||||
|
||||
//
|
||||
//Read data long
|
||||
//
|
||||
XMEM_p = start_addr;
|
||||
sdram_wdl=0x08070605;
|
||||
for (i=0; i < 3; i++)
|
||||
{
|
||||
sdram_rdl = __addr32_read_uint32(XMEM_p);
|
||||
if( sdram_rdl != sdram_wdl)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
XMEM_p = XMEM_p+2;
|
||||
sdram_wdl += 0x04040404;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// sdram_read_write - This function performs simple read/write accesses
|
||||
// to memory.
|
||||
//
|
||||
char
|
||||
sdram_read_write(Uint32 start_addr, Uint32 mem_size)
|
||||
{
|
||||
unsigned long mem_rdl;
|
||||
unsigned long mem_wdl;
|
||||
Uint32 XMEM_p;
|
||||
Uint32 i;
|
||||
|
||||
//
|
||||
//Write data
|
||||
//
|
||||
XMEM_p = start_addr;
|
||||
|
||||
//
|
||||
//Fill memory
|
||||
//
|
||||
mem_wdl = 0x01234567;
|
||||
for (i=0; i < mem_size; i++)
|
||||
{
|
||||
__addr32_write_uint32(XMEM_p, mem_wdl);
|
||||
XMEM_p = XMEM_p+2;
|
||||
mem_wdl += 0x11111111;
|
||||
}
|
||||
|
||||
//
|
||||
//Verify memory
|
||||
//
|
||||
mem_wdl = 0x01234567;
|
||||
XMEM_p = start_addr;
|
||||
for (i=0; i < mem_size; i++)
|
||||
{
|
||||
mem_rdl = __addr32_read_uint32(XMEM_p);
|
||||
if( mem_rdl != mem_wdl)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
XMEM_p = XMEM_p+2;
|
||||
mem_wdl += 0x11111111;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
char ErrCount_local;
|
||||
TEST_STATUS = TEST_FAIL;
|
||||
|
||||
//
|
||||
// Initialize the device system and clocks
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
EALLOW;
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// GService Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
//Configure to run EMIF1 on half Rate (EMIF1CLK = CPU1SYSCLK/2)
|
||||
//
|
||||
EALLOW;
|
||||
ClkCfgRegs.PERCLKDIVSEL.bit.EMIF1CLKDIV = 0x1;
|
||||
EDIS;
|
||||
|
||||
EALLOW;
|
||||
//
|
||||
// Grab EMIF1 For CPU1
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1MSEL.all = 0x93A5CE71;
|
||||
if(Emif1ConfigRegs.EMIF1MSEL.all != 0x1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
//Disable Access Protection (CPU_FETCH/CPU_WR/DMA_WR)
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1ACCPROT0.all = 0x0;
|
||||
if(Emif1ConfigRegs.EMIF1ACCPROT0.all != 0x0)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Commit the configuration related to protection. Till this bit remains
|
||||
// set content of EMIF1ACCPROT0 register can't be changed.
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1COMMIT.all = 0x1;
|
||||
if(Emif1ConfigRegs.EMIF1COMMIT.all != 0x1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
//
|
||||
// Lock the configuration so that EMIF1COMMIT register can't be changed
|
||||
// any more.
|
||||
//
|
||||
Emif1ConfigRegs.EMIF1LOCK.all = 0x1;
|
||||
if(Emif1ConfigRegs.EMIF1LOCK.all != 1)
|
||||
{
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
EDIS;
|
||||
|
||||
//
|
||||
//Configure GPIO pins for EMIF1
|
||||
//
|
||||
setup_emif1_pinmux_sdram_32bit(0);
|
||||
|
||||
//
|
||||
//Configure SDRAM control registers
|
||||
//
|
||||
// Need to be programmed based on SDRAM Data-Sheet.
|
||||
//T_RFC = 60ns = 0x6
|
||||
//T_RP = 18ns = 0x1
|
||||
//T_RCD = 18ns = 0x1
|
||||
//T_WR = 1CLK + 6 ns = 0x1
|
||||
//T_RAS = 42ns = 0x4
|
||||
//T_RC = 60ns = 0x6
|
||||
//T_RRD = 12ns = 0x1
|
||||
//
|
||||
Emif1Regs.SDRAM_TR.all = 0x31114610;
|
||||
|
||||
//
|
||||
//Txsr = 70ns = 0x7
|
||||
//
|
||||
Emif1Regs.SDR_EXT_TMNG.all = 0x7;
|
||||
|
||||
//
|
||||
//Tref = 64ms for 4096 ROW, RR = 64000*100(Tfrq)/4096 = 1562.5 (0x61B)
|
||||
//
|
||||
Emif1Regs.SDRAM_RCR.all = 0x61B;
|
||||
|
||||
//
|
||||
//PAGESIZE=0 (256 elements per ROW), IBANK = 2 (4 BANK), CL = 3,
|
||||
//NM = 0 (32bit)
|
||||
//
|
||||
Emif1Regs.SDRAM_CR.all = 0x00000720;
|
||||
|
||||
//
|
||||
//Add some delay
|
||||
//
|
||||
for(i=0;i<123;i++) { }
|
||||
|
||||
//
|
||||
// Basic read/write check.
|
||||
//
|
||||
ErrCount_local = sdram_read_write(SDRAM_CS0_START_ADDR, SDRAM_CS0_SIZE);
|
||||
ErrCount = ErrCount + ErrCount_local;
|
||||
|
||||
//
|
||||
//run different addr walk checks
|
||||
//
|
||||
ErrCount_local = sdram_addr_walk(SDRAM_CS0_START_ADDR, 15);
|
||||
ErrCount = ErrCount + ErrCount_local;
|
||||
|
||||
//
|
||||
//run different data walk checks
|
||||
//
|
||||
ErrCount_local = sdram_data_walk(SDRAM_CS0_START_ADDR, SDRAM_CS0_SIZE);
|
||||
ErrCount = ErrCount + ErrCount_local;
|
||||
|
||||
//
|
||||
//run different data size checks
|
||||
//
|
||||
ErrCount_local = sdram_data_size(SDRAM_CS0_START_ADDR, 4);
|
||||
ErrCount = ErrCount + ErrCount_local;
|
||||
|
||||
if (ErrCount == 0x0)
|
||||
{
|
||||
TEST_STATUS = TEST_PASS;
|
||||
}
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,77 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: fpu_types.h
|
||||
//
|
||||
// TITLE: Prototypes and Definitions for the C28x FPU Library
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
#ifndef _FPU_TYPES_H_
|
||||
#define _FPU_TYPES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "float.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef FPU_TYPES
|
||||
#define FPU_TYPES
|
||||
|
||||
// Complex Float Data Type
|
||||
typedef struct {
|
||||
float dat[2];
|
||||
} complex_float;
|
||||
|
||||
#endif //FPU_TYPES
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif // - end of _FPU_TYPES_H_
|
||||
|
||||
//===========================================================================
|
||||
// End of file.
|
||||
//===========================================================================
|
||||
|
||||
@@ -0,0 +1,467 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: fpu_vector.h
|
||||
//
|
||||
// TITLE: Prototypes and Definitions for the C28x FPU Library
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
#ifndef _FPU_VECTOR_H_
|
||||
#define _FPU_VECTOR_H_
|
||||
|
||||
#include "fpu_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions and Prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef _TMS320C28XX_TMU0__
|
||||
#define abs_SP_CV abs_SP_CV_TMU0
|
||||
#define iabs_SP_CV iabs_SP_CV_TMU0
|
||||
#else
|
||||
#define abs_SP_CV abs_SP_CV
|
||||
#define iabs_SP_CV iabs_SP_CV
|
||||
#endif //_TMS320C28XX_TMU0__
|
||||
|
||||
// \brief Absolute Value of a Complex Vector.
|
||||
//
|
||||
// This module computes the absolute value of a complex vector. If N is even,
|
||||
// use abs_SP_CV_2() for better performance.
|
||||
// \f[y[i]&=& \sqrt(x_{re}[i]^{2} + x_{im}[i]^{2}) \f]
|
||||
// \param y pointer to the output vector
|
||||
// \param x pointer to the input vector
|
||||
// \param N length of the x and y vectors
|
||||
//
|
||||
extern void abs_SP_CV(volatile float *y, volatile const complex_float *x, const uint16_t N);
|
||||
|
||||
// \brief Absolute Value of an Even Length Complex Vector.
|
||||
//
|
||||
// This module computes the absolute value of an even length complex vector.
|
||||
// \f[ y[i]&=& \sqrt(x_{re}[i]^{2} + x_{im}[i]^{2})\f]
|
||||
// \param y pointer to the output vector
|
||||
// \param x pointer to the input vector
|
||||
// \param N length of the x and y vectors
|
||||
// \attention N must be even
|
||||
//
|
||||
extern void abs_SP_CV_2(volatile float *y, volatile const complex_float *x, const uint16_t N);
|
||||
|
||||
// \brief Absolute Value of a Complex Vector (TMU0).
|
||||
//
|
||||
// This module computes the absolute value of a complex vector. It uses
|
||||
// the TMU Type 0 accelerator to speed up the calculation of square roots.
|
||||
// \f[y[i]&=& \sqrt(x_{re}[i]^{2} + x_{im}[i]^{2}) \f]
|
||||
// \param y pointer to the output vector
|
||||
// \param x pointer to the input vector
|
||||
// \param N length of the x and y vectors
|
||||
// \attention
|
||||
// -# This function is optimized for N>=8. It is less cycle efficient
|
||||
// when N<8. For very small N (e.g., N=1, 2, maybe 3) the user might
|
||||
// consider using the TMU intrinsics in the compiler instead of this
|
||||
// function.
|
||||
//
|
||||
extern void abs_SP_CV_TMU0(volatile float *y, volatile const complex_float *x, const uint16_t N);
|
||||
|
||||
// \brief Addition (Element-Wise) of a Complex Scalar to a Complex Vector.
|
||||
//
|
||||
// This module adds a complex scalar element-wise to a complex vector.
|
||||
// \f[y_{re}[i]&=& x_{re}[i] + c_{re}\f]
|
||||
// \f[y_{im}[i]&=& x_{im}[i] + c_{im}\f]
|
||||
// \param y pointer to the complex output vector
|
||||
// \param x pointer to the complex input vector
|
||||
// \param c pointer to the complex input scalar
|
||||
// \param N length of the x and y vectors
|
||||
//
|
||||
extern void add_SP_CSxCV(volatile complex_float *y, volatile const complex_float *x, const complex_float c, const uint16_t N);
|
||||
|
||||
// \brief Addition of Two Complex Vectors.
|
||||
//
|
||||
// This module adds two complex vectors.
|
||||
// \f[y_{re}[i]&=& w_{re}[i] + x_{re}[i]\f]
|
||||
// \f[y_{im}[i]&=& w_{im}[i] + x_{im}[i]\f]
|
||||
// \param y pointer to the complex output vector
|
||||
// \param w pointer to the first complex input vector
|
||||
// \param x pointer to the second complex input vector
|
||||
// \param N length of the w, x and y vectors
|
||||
//
|
||||
extern void add_SP_CVxCV(volatile complex_float *y, volatile const complex_float *w, volatile const complex_float *x, const uint16_t N);
|
||||
|
||||
// \brief Inverse Absolute Value of a Complex Vector.
|
||||
//
|
||||
// This module computes the inverse absolute value of a complex vector.
|
||||
// \f[y[i]&=& \frac{1}{\sqrt(x_{re}[i]^{2} + x_{im}[i]^{2})}\f]
|
||||
// \param y pointer to the output vector
|
||||
// \param x pointer to the input vector
|
||||
// \param N length of the x and y vectors
|
||||
// \attention N must be at least 2
|
||||
//
|
||||
extern void iabs_SP_CV(volatile float *y, volatile const complex_float *x, const uint16_t N);
|
||||
|
||||
// \brief Inverse Absolute Value of an Even Length Complex Vector.
|
||||
//
|
||||
// This module calculates the inverse absolute value of an even
|
||||
// length complex vector.
|
||||
// \f[y[i]&=& \frac{1}{\sqrt(x_{re}[i]^{2} + x_{im}[i]^{2})}\f]
|
||||
// \param y pointer to the output vector
|
||||
// \param x pointer to the input vector
|
||||
// \param N length of the x and y vectors
|
||||
// \attention N must be even
|
||||
//
|
||||
extern void iabs_SP_CV_2(volatile float *y, volatile const complex_float *x, const uint16_t N);
|
||||
|
||||
// \brief Inverse Absolute Value of a Complex Vector (TMU0).
|
||||
//
|
||||
// This module computes the inverse absolute value of a complex vector.
|
||||
// It uses the TMU Type 0 accelerator to speed up the calculation
|
||||
// of square roots.
|
||||
// \f[y[i]&=& \frac{1}{\sqrt(x_{re}[i]^{2} + x_{im}[i]^{2})}\f]
|
||||
// \param y pointer to the output vector
|
||||
// \param x pointer to the input vector
|
||||
// \param N length of the x and y vectors
|
||||
// \attention
|
||||
// -# This function is optimized for N>=8. It is less cycle efficient
|
||||
// when N<8. For very small N (e.g., N=1, 2, maybe 3) the user might
|
||||
// consider using the TMU intrinsics in the compiler instead of this
|
||||
// function.
|
||||
//
|
||||
extern void iabs_SP_CV_TMU0(volatile float *y, volatile const complex_float *x, const uint16_t N);
|
||||
|
||||
// \brief Index of Maximum Value of an Even Length Real Array.
|
||||
//
|
||||
// \param x pointer to the input vector
|
||||
// \param N length of the x vector
|
||||
// \attention
|
||||
// -# N must be even
|
||||
// -# If more than one instance of the max value exists in x[], the
|
||||
// function will return the index of the first occurrence (lowest index
|
||||
// value)
|
||||
//
|
||||
extern uint16_t maxidx_SP_RV_2(volatile float *x, uint16_t N);
|
||||
|
||||
// \brief Mean of Real and Imaginary Parts of a Complex Vector.
|
||||
//
|
||||
// This module calculates the mean of real and imaginary parts of a
|
||||
// complex vector.
|
||||
// \f[y_{re} &=& \frac{\Sigma x_{re}}{N} \f]
|
||||
// \f[y_{im} &=& \frac{\Sigma x_{im}}{N} \f]
|
||||
// \param x pointer to the input vector
|
||||
// \param N length of the x vector
|
||||
// \attention N must be even and a minimum of 4
|
||||
//
|
||||
extern complex_float mean_SP_CV_2(volatile const complex_float *x, const uint16_t N);
|
||||
|
||||
// \brief Median of a Real Valued Array of Floats (Preserved Inputs).
|
||||
//
|
||||
// This module computes the median of a real valued array of
|
||||
// floats. The input array is preserved. If input array preservation is not required,
|
||||
// use median_SP_RV() for better performance. This function calls median_SP_RV() and
|
||||
// memcpy_fast().
|
||||
// \param x pointer to the real input vector
|
||||
// \param N length of the x vector
|
||||
// \attention
|
||||
// -# This function simply makes a local copy of the input array, and then
|
||||
// calls median_SP_CV() using the copy
|
||||
// -# The length of the copy of the input array is allocated at compile time
|
||||
// by the constant "K" defined in the code. If the passed parameter N
|
||||
// is greater than K, memory corruption will result. Be sure to recompile
|
||||
// the library with an appropriate value \f$K >= N\f$ before executing this code.
|
||||
// The library uses K = 256 as the default value.
|
||||
// \return median of the vector x
|
||||
// \attention The first stage of this function (memory copy) is not interruptible.
|
||||
// For interruptibility, use median_noreorder_SP_RV instead.
|
||||
// \attention This function does not support memory above 22-bits address.
|
||||
// For input data above 22 bits address, use median_noreorder_SP_RV_far instead.
|
||||
//
|
||||
extern float median_noreorder_SP_RV(const float *x, uint16_t N);
|
||||
|
||||
// \brief Median of a Real Valued Array of Floats (Preserved Inputs).
|
||||
//
|
||||
// This module computes the median of a real valued array of
|
||||
// floats. The input array is preserved. If input array preservation is not required,
|
||||
// use median_SP_RV() for better performance. This function calls median_SP_RV_far() and
|
||||
// memcpy_fast_far().
|
||||
// \param x pointer to the real input vector
|
||||
// \param N length of the x vector
|
||||
// \attention
|
||||
// -# This function simply makes a local copy of the input array, and then
|
||||
// calls median_SP_CV_far() using the copy
|
||||
// -# The length of the copy of the input array is allocated at compile time
|
||||
// by the constant "K" defined in the code. If the passed parameter N
|
||||
// is greater than K, memory corruption will result. Be sure to recompile
|
||||
// the library with an appropriate value \f$K >= N\f$ before executing this code.
|
||||
// The library uses K = 256 as the default value.
|
||||
// \return median of the vector x
|
||||
// \attention This function is intended for data above 22 bits address.
|
||||
// For input data at or below 22 bits address, use median_noreorder_SP_RV instead for possible better performance.
|
||||
//
|
||||
extern float median_noreorder_SP_RV_far(volatile const float *x, uint16_t N);
|
||||
|
||||
// \brief Median of a real array of floats.
|
||||
//
|
||||
// This module computes the median of a real array of floats.
|
||||
// The Input array is NOT preserved. If input array preservation
|
||||
// is required, use median_noreorder_SP_RV().
|
||||
// \param x pointer to the real input vector
|
||||
// \param N length of the x vector
|
||||
// \attention
|
||||
// -# This function is destructive to the input array x in that it
|
||||
// will be sorted during function execution. If this is not allowable,
|
||||
// use median_noreorder_SP_CV().
|
||||
// -# This function should be compiled with -o4, -mf5, and no -g compiler
|
||||
// options for best performance.
|
||||
// \return median of the vector x
|
||||
// \attention The function does not support memory above 22-bits address.
|
||||
// For input data above 22 bits address, use median_SP_RV_far instead.
|
||||
//
|
||||
extern float median_SP_RV(float *x, uint16_t N);
|
||||
|
||||
// \brief Median of a real array of floats.
|
||||
//
|
||||
// This module computes the median of a real array of floats.
|
||||
// The Input array is NOT preserved. If input array preservation
|
||||
// is required, use median_noreorder_SP_RV_far().
|
||||
// \param x pointer to the real input vector
|
||||
// \param N length of the x vector
|
||||
// \attention
|
||||
// -# This function is destructive to the input array x in that it
|
||||
// will be sorted during function execution. If this is not allowable,
|
||||
// use median_noreorder_SP_CV_far().
|
||||
// -# This function should be compiled with -o4, -mf5, and no -g compiler
|
||||
// options for best performance.
|
||||
// \return median of the vector x
|
||||
// \attention This function is intended for data above 22 bits address.
|
||||
// For input data at or below 22 bits address, use median_SP_RV instead for possible better performance.
|
||||
//
|
||||
extern float median_SP_RV_far(volatile float *x, uint16_t N);
|
||||
|
||||
// \brief Optimized Memory Copy.
|
||||
//
|
||||
// \param src pointer to the source buffer
|
||||
// \param dst pointer to the destination buffer
|
||||
// \param N size (16-bits) of the buffer to be copied
|
||||
// \attention The function checks for the case of N=0 and just returns if true
|
||||
// \attention This function is not interruptible. Use memcpy_fast_far instead for interruptibility.
|
||||
// \attention This function does not support memory above 22 bits address.
|
||||
// For input data above 22 bits address, use memcpy_fast_far instead.
|
||||
//
|
||||
extern void memcpy_fast(void *dst, const void *src, uint16_t N);
|
||||
|
||||
// \brief Optimized Memory Copy for far memory (above 22 bits).
|
||||
//
|
||||
// \param src pointer to the source buffer
|
||||
// \param dst pointer to the destination buffer
|
||||
// \param N size (16-bits) of the buffer to be copied
|
||||
// \attention The function checks for the case of N=0 and just returns if true
|
||||
// \attention This function is restricted to C28x devices with the FPU
|
||||
// \attention This function is intended for data above 22 bits address.
|
||||
// For input data at or below 22 bits address, use memcpy_fast instead for better performance.
|
||||
//
|
||||
extern void memcpy_fast_far(volatile void *dst, volatile const void *src, uint16_t N);
|
||||
|
||||
// \brief Optimized Memory Set.
|
||||
//
|
||||
// \param dst pointer to the destination buffer
|
||||
// \param value value to write to all the buffer locations
|
||||
// \param N size (16-bits) of the buffer to be written
|
||||
// \attention The function checks for the case of N=0 and just returns if true.
|
||||
// \attention This function is not interruptible
|
||||
//
|
||||
extern void memset_fast(volatile void *dst, int16_t value, uint16_t N);
|
||||
|
||||
// \brief Complex Multiply of Two Floating Point Numbers.
|
||||
//
|
||||
// This module multiplies two floating point complex values.
|
||||
// \f[y_{re} &=& w_{re}*x_{re} - w_{im}*x_{im}\f]
|
||||
// \f[y_{im} &=& w_{re}*x_{im} + w_{im}*x_{re}\f]
|
||||
// \param w First complex input
|
||||
// \param x Second complex input
|
||||
// \return complex product of the first and second complex input
|
||||
//
|
||||
extern complex_float mpy_SP_CSxCS(complex_float w, complex_float x);
|
||||
|
||||
// \brief Complex Multiply of Two Complex Vectors.
|
||||
//
|
||||
// This module performs complex multiplication on two input complex vectors.
|
||||
// \f[y_{re}[i] &=& w_{re}[i]*x_{re}[i] - w_{im}[i]*x_{im}[i] \f]
|
||||
// \f[y_{im}[i] &=& w_{re}[i]*x_{im}[i] + w_{im}[i]*x_{re}[i] \f]
|
||||
// \param y pointer to the complex product of the first and second complex vectors
|
||||
// \param w pointer to the first complex input vector
|
||||
// \param x pointer to the second complex input vector
|
||||
// \param N length of the w, x and y vectors
|
||||
//
|
||||
extern void mpy_SP_CVxCV(volatile complex_float *y, volatile const complex_float *w, volatile const complex_float *x, const uint16_t N);
|
||||
|
||||
// \brief Multiplication of a Complex Vector and the Complex Conjugate of another Vector.
|
||||
//
|
||||
// This module multiplies a complex vector (w) and the complex conjugate of another complex vector (x).
|
||||
// \f[x^{*}_{re}[i] &=& x_{re}[i]\f]
|
||||
// \f[x^{*}_{im}[i] &=& - x_{im}[i]\f]
|
||||
// \f[y_{re}[i] &=& w_{re}[i]*x_{re}[i] - w_{im}[i]*x^{*}_{im}[i]\f]
|
||||
// \f[y_{im}[i] &=& w_{re}[i]*x^{*}_{im}[i] + w_{im}[i]*x_{re}[i]\f]
|
||||
// \param y pointer to the complex product of the first and second complex vectors
|
||||
// \param w pointer to the first complex input vector
|
||||
// \param x pointer to the second complex input vector
|
||||
// \param N length of the w, x and y vectors
|
||||
//
|
||||
extern void mpy_SP_CVxCVC(volatile complex_float *y, volatile const complex_float *w, volatile const complex_float *x, const uint16_t N);
|
||||
|
||||
// \brief Multiplication of a Real scalar and a Real Vector.
|
||||
//
|
||||
// This module multiplies a real scalar and a real vector.
|
||||
// \f[y[i] &=& c*x[i] \f]
|
||||
// \param y pointer to the product of the scalar and a real vector
|
||||
// \param x pointer to the real input vector
|
||||
// \param c scalar multiplier
|
||||
// \param N length of the x and y vectors
|
||||
// \attention N must be even and a minimum of 4.
|
||||
//
|
||||
extern void mpy_SP_RSxRV_2(volatile float *y, volatile const float *x, const float c, const uint16_t N);
|
||||
|
||||
// \brief Multiplication of a Real Scalar, a Real Vector, and another Real Vector.
|
||||
//
|
||||
// This module multiplies a real scalar with a real vector and another real vector.
|
||||
// \f[y[i] &=& c*w[i]*x[i] \f]
|
||||
// \param y pointer to the product of the scalar and two real vectors
|
||||
// \param w pointer to the first real input vector
|
||||
// \param x pointer to the second real input vector
|
||||
// \param c scalar multiplier
|
||||
// \param N length of the w, x and y vectors
|
||||
// \attention N must be even and a minimum of 4.
|
||||
//
|
||||
extern void mpy_SP_RSxRVxRV_2(volatile float *y, volatile const float *w, volatile const float *x, const float c, const uint16_t N);
|
||||
|
||||
// \brief Multiplication of a Real Vector and a Complex Vector.
|
||||
//
|
||||
// This module multiplies a real vector and a complex vector.
|
||||
// \f[y_{re}[i] &=& x[i]*w_{re}[i] \f]
|
||||
// \f[y_{im}[i] &=& x[i]*w_{im}[i] \f]
|
||||
// \param y pointer to the product of the real and complex vectors
|
||||
// \param w pointer to the complex input vector
|
||||
// \param x pointer to the real input vector
|
||||
// \param N length of the w, x and y vectors
|
||||
// \attention N must be at least 2
|
||||
//
|
||||
extern void mpy_SP_RVxCV(volatile complex_float *y, volatile const complex_float *w, volatile const float *x, const uint16_t N);
|
||||
|
||||
// \brief Multiplication of a Real Vector and a Real Vector.
|
||||
//
|
||||
// This module multiplies two real vectors.
|
||||
// \f[y[i] &=& w[i]*x[i]\f]
|
||||
// \param y pointer to the product of two real vectors
|
||||
// \param w pointer to the first real input vector
|
||||
// \param x pointer to the second real input vector
|
||||
// \param N length of the w, x and y vectors
|
||||
// \attention N must be even and a minimum of 4.
|
||||
//
|
||||
extern void mpy_SP_RVxRV_2(volatile float *y, volatile const float *w, volatile const float *x, const uint16_t N);
|
||||
|
||||
// \brief Sort an Array of Floats.
|
||||
//
|
||||
// This module sorts an array of floats. This function is a partially optimized
|
||||
// version of qsort.c from the C28x cgtools lib qsort() v6.0.1.
|
||||
// \param x pointer to the input array
|
||||
// \param N size of the input array
|
||||
// \attention Performance is best with -o1, -mf3 compiler options (cgtools v6.0.1)
|
||||
// \attention This function does not support memory above 22 bits address.
|
||||
// For input data above 22 bits address, use qsort_SP_RV_far instead.
|
||||
//
|
||||
extern void qsort_SP_RV(void *x, uint16_t N);
|
||||
|
||||
// \brief Sort an Array of Floats.
|
||||
//
|
||||
// This module sorts an array of floats. This function is a partially optimized
|
||||
// version of qsort.c from the C28x cgtools lib qsort() v6.0.1.
|
||||
// \param x pointer to the input array
|
||||
// \param N size of the input array
|
||||
// \attention Performance is best with -o1, -mf3 compiler options (cgtools v6.0.1)
|
||||
// \attention This function is intended for data above 22 bits address.
|
||||
// For input data at or below 22 bits address, use qsort_SP_RV instead for possible better performance.
|
||||
//
|
||||
extern void qsort_SP_RV_far(volatile void *x, uint16_t N);
|
||||
|
||||
// \brief Rounding (Unbiased) of a Floating Point Scalar.
|
||||
//
|
||||
// numerical examples:
|
||||
// rnd_SP_RS(+4.4) = +4.0 \\
|
||||
// rnd_SP_RS(-4.4) = -4.0 \\
|
||||
// rnd_SP_RS(+4.5) = +5.0 \\
|
||||
// rnd_SP_RS(-4.5) = -5.0 \\
|
||||
// rnd_SP_RS(+4.6) = +5.0 \\
|
||||
// rnd_SP_RS(-4.6) = -5.0 \\
|
||||
// \param x input value
|
||||
// \return rounded
|
||||
//
|
||||
extern float rnd_SP_RS(float x);
|
||||
|
||||
// \brief Subtraction of a Complex Scalar from a Complex Vector.
|
||||
//
|
||||
// This module subtracts a complex scalar from a complex vector.
|
||||
// \f[y_{re}[i] &=& x_{re}[i] - c_{re} \f]
|
||||
// \f[y_{im}[i] &=& x_{im}[i] - c_{im} \f]
|
||||
// \param y pointer to the difference of a complex scalar from a complex vector
|
||||
// \param x pointer to the complex input vector
|
||||
// \param c pointer to the complex input scalar
|
||||
// \param N length of the x and y vectors
|
||||
// \attention N must be at least 2
|
||||
//
|
||||
extern void sub_SP_CSxCV(volatile complex_float *y,volatile const complex_float *x, const complex_float c, const uint16_t N);
|
||||
|
||||
// \brief Subtraction of a Complex Vector and another Complex Vector.
|
||||
//
|
||||
// This module subtracts a complex vector from another complex vector.
|
||||
// \f[y_{re}[i] &=& w_{re}[i] - x_{re}[i] \f]
|
||||
// \f[y_{im}[i] &=& w_{im}[i] - x_{im}[i] \f]
|
||||
// \param y pointer to the difference of two complex vectors
|
||||
// \param w pointer to the first complex input vector
|
||||
// \param x pointer to the second complex input vector
|
||||
// \param N length of the w, x and y vectors
|
||||
// \attention N must be at least 2
|
||||
//
|
||||
extern void sub_SP_CVxCV(volatile complex_float *y, volatile const complex_float *w, volatile const complex_float *x, const uint16_t N);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* extern "C" */
|
||||
|
||||
#endif // - end of _FPU_VECTOR_H_
|
||||
|
||||
//===========================================================================
|
||||
// End of file.
|
||||
//===========================================================================
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
; =============================================================================
|
||||
; This software is licensed for use with Texas Instruments C28x
|
||||
; family DSCs. This license was provided to you prior to installing
|
||||
; the software. You may review this license by consulting a copy of
|
||||
; the agreement in the doc directory of this library.
|
||||
; ------------------------------------------------------------------------
|
||||
; Copyright (C) 2014-2015 Texas Instruments, Incorporated.
|
||||
; All Rights Reserved.
|
||||
; =============================================================================
|
||||
;
|
||||
; FILE: memcpy_fast_far.asm
|
||||
;
|
||||
; AUTHOR: David M. Alter, Texas Instruments Inc.
|
||||
;
|
||||
; HISTORY:
|
||||
; 10/21/14 - original (D. Alter)
|
||||
;
|
||||
; DESCRIPTION: Optimized memory copy, src->dest.
|
||||
;
|
||||
; FUNCTION:
|
||||
; extern void memcpy_fast_far(volatile void* dst, volatile const void* src, Uint16 N);
|
||||
;
|
||||
; USAGE: memcpy_fast_far(dst, src, N);
|
||||
;
|
||||
; PARAMETERS: volatile void* dst = pointer to destination
|
||||
; volatile const void* src = pointer to source
|
||||
; N = number of 16-bit words to copy
|
||||
;
|
||||
; RETURNS: none
|
||||
;
|
||||
; BENCHMARK: The performance of this function differs depending on the
|
||||
; address alignment of the src and dst addresses (pointers).
|
||||
; - If both pointers have the same alignment (even or odd address),
|
||||
; then 32-bit copies are used for the bulk of the transfers. This
|
||||
; allows performance to approach 1 cycle/word (16-bit word) plus
|
||||
; overhead.
|
||||
; - If the two pointers have different alignments (one even aligned,
|
||||
; the other odd aligned) then 16-bit transfers must be used. This
|
||||
; provides performance approaching 2 cycles/word (16-bit word) plus
|
||||
; overhead.
|
||||
; The above benchmarks assume that the src and dst are located in
|
||||
; different internal RAM blocks (so there are no RAM stalls).
|
||||
;
|
||||
; NOTES:
|
||||
; 1) The function checks for the case of N=0 and just returns if true.
|
||||
; 2) This function is restricted to C28x devices with the FPU.
|
||||
; 3) This function is intended for data above 22 bits address.
|
||||
; For input data at or below 22 bits address, use memcpy_fast
|
||||
; instead for better performance.
|
||||
; 4) PREAD and PWRITE are used in the function, but this is OK with
|
||||
; above 22-bit address since the program bus is used for stack
|
||||
; access (below 22 bits). The data bus is used for the >22-bit
|
||||
; address access.
|
||||
;
|
||||
; =============================================================================
|
||||
; ###########################################################################
|
||||
;
|
||||
;// C2000Ware v5.04.00.00
|
||||
;//Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
;//
|
||||
;// Redistribution and use in source and binary forms, with or without
|
||||
;// modification, are permitted provided that the following conditions
|
||||
;// are met:
|
||||
;//
|
||||
;// Redistributions of source code must retain the above copyright
|
||||
;// notice, this list of conditions and the following disclaimer.
|
||||
;//
|
||||
;// Redistributions in binary form must reproduce the above copyright
|
||||
;// notice, this list of conditions and the following disclaimer in the
|
||||
;// documentation and/or other materials provided with the
|
||||
;// distribution.
|
||||
;//
|
||||
;// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
;// its contributors may be used to endorse or promote products derived
|
||||
;// from this software without specific prior written permission.
|
||||
;//
|
||||
;// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
;// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
;// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
;// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
;// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
;// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
;// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
;// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
;// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
;// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
;// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;// $
|
||||
; ###########################################################################
|
||||
|
||||
.global memcpy_fast_far
|
||||
.text
|
||||
|
||||
memcpy_fast_far:
|
||||
; Need to check 32-bit alignment of src and dst pointers for 32-bit transfers.
|
||||
; There are found cases:
|
||||
; Case 1: both pointers aligned
|
||||
; Case 2: neither pointer aligned
|
||||
; Case 3: src pointer aligned, dst pointer not aligned
|
||||
; Case 4: src pointer not aligned, dst pointer aligned
|
||||
|
||||
|
||||
; Test src pointer alignment
|
||||
TBIT AR5, #0 ;Test if src pointer is aligned
|
||||
SBF line1a, NTC ;Branch if aligned
|
||||
|
||||
; src pointer not aligned. Test dst pointer.
|
||||
TBIT AR4, #0 ;Test if dst pointer is aligned
|
||||
SBF line1b, NTC ;Branch if aligned
|
||||
|
||||
;--------------
|
||||
; Case 2 is true - neither pointer aligned
|
||||
; Copy the first 16-bit word to align both pointers
|
||||
ADDB AL, #-1 ;Decrement the copy number
|
||||
BF done3, NC ;Branch if N was zero
|
||||
MOV AH, *XAR5++ ;Read the src
|
||||
MOV *XAR4++, AH ;Store to dst
|
||||
BF line3a, UNC ;Proceed with 32-bit copies
|
||||
|
||||
;--------------
|
||||
line1b:
|
||||
; Case 4 is true - src pointer not aligned, dst pointer aligned.
|
||||
BF line2a, UNC ;Proceed with 16-bit copies
|
||||
|
||||
;--------------
|
||||
line1a:
|
||||
; src pointer aligned. Test dst pointer.
|
||||
TBIT AR4, #0 ;Test bit 0 of dst pointer
|
||||
SBF line1c, NTC ;Branch if aligned
|
||||
|
||||
;--------------
|
||||
; Case 3 is true - src pointer aligned, dst pointer not aligned.
|
||||
; Proceed with 16-bit copies.
|
||||
|
||||
;--------------------------------------
|
||||
line2a:
|
||||
; 16-bit copies.
|
||||
; These are used when the src and dst pointers have different alignments
|
||||
; (i.e., one is aligned, the other is not aligned).
|
||||
; Copy as many 8x16-bit word blocks as possible.
|
||||
; 8x16-bit length blocks are used so we can meet minimum size of RPTB.
|
||||
MOV PL, AL ;Save current copy number
|
||||
LSR AL, #3 ;Divide by 8
|
||||
|
||||
ADDB AL, #-1 ;Repeat "N-1" times
|
||||
BF line2b, NC ;Branch if N was zero
|
||||
|
||||
RPTB line2b, @AL
|
||||
MOV AH, *XAR5++ ;Read src #1
|
||||
MOV *XAR4++, AH ;Write dst #1
|
||||
MOV AH, *XAR5++ ;Read src #2
|
||||
MOV *XAR4++, AH ;Write dst #2
|
||||
MOV AH, *XAR5++ ;Read src #3
|
||||
MOV *XAR4++, AH ;Write dst #3
|
||||
MOV AH, *XAR5++ ;Read src #4
|
||||
MOV *XAR4++, AH ;Write dst #4
|
||||
MOV AH, *XAR5++ ;Read src #5
|
||||
MOV *XAR4++, AH ;Write dst #5
|
||||
MOV AH, *XAR5++ ;Read src #6
|
||||
MOV *XAR4++, AH ;Write dst #6
|
||||
MOV AH, *XAR5++ ;Read src #7
|
||||
MOV *XAR4++, AH ;Write dst #7
|
||||
MOV AH, *XAR5++ ;Read src #8
|
||||
MOV *XAR4++, AH ;Write dst #8
|
||||
|
||||
line2b:
|
||||
; Do the remaining elements as 16-bit copies. There could be up to 7 of them.
|
||||
MOV AL, PL ;Restore the saved copy number
|
||||
AND AL, #0007h ;Isolate 1st 3 bits of the copy number (0 - 15 copies)
|
||||
|
||||
MOVL XAR7, #0 ;Zero out XAR7
|
||||
MOV AR7, SP ;AR7 = SP
|
||||
ADD SP, AL ;Advance stack pointer beyond copy area
|
||||
|
||||
ADDB AL, #-1 ;Repeat "N-1" times
|
||||
BF done2, NC ;Branch if N was zero
|
||||
RPT @AL
|
||||
|| PWRITE *XAR7, *XAR5++ ;Copy src words to the stack
|
||||
RPT @AL
|
||||
|| PREAD *XAR4++, *XAR7 ;Copy stack words to the dst
|
||||
|
||||
SUB SP, AL ;Restore the stack pointer (part 1)
|
||||
SUB SP, #1 ;Restore the stack pointer (part 2)
|
||||
|
||||
;Finish up
|
||||
done2:
|
||||
LRETR ;return
|
||||
|
||||
;--------------
|
||||
line1c:
|
||||
; Case 1 is true - both pointers aligned.
|
||||
; Proceed with 32-bit copies.
|
||||
|
||||
;--------------------------------------
|
||||
line3a:
|
||||
; 32-bit copies.
|
||||
; Copy as many 8x32-bit word blocks as possible.
|
||||
; 8x32-bit (16x16-bit) length blocks are used so we can meet minimum size of RPTB.
|
||||
MOV PL, AL ;Save current copy number
|
||||
LSR AL, #4 ;Divide by 16
|
||||
|
||||
ADDB AL, #-1 ;Repeat "N-1" times
|
||||
BF line3b, NC ;Branch if N was zero
|
||||
|
||||
RPTB line3b, @AL
|
||||
MOVL ACC, *XAR5++ ;Read src #1
|
||||
MOVL *XAR4++, ACC ;Write dst #1
|
||||
MOVL ACC, *XAR5++ ;Read src #2
|
||||
MOVL *XAR4++, ACC ;Write dst #2
|
||||
MOVL ACC, *XAR5++ ;Read src #3
|
||||
MOVL *XAR4++, ACC ;Write dst #3
|
||||
MOVL ACC, *XAR5++ ;Read src #4
|
||||
MOVL *XAR4++, ACC ;Write dst #4
|
||||
MOVL ACC, *XAR5++ ;Read src #5
|
||||
MOVL *XAR4++, ACC ;Write dst #5
|
||||
MOVL ACC, *XAR5++ ;Read src #6
|
||||
MOVL *XAR4++, ACC ;Write dst #6
|
||||
MOVL ACC, *XAR5++ ;Read src #7
|
||||
MOVL *XAR4++, ACC ;Write dst #7
|
||||
MOVL ACC, *XAR5++ ;Read src #8
|
||||
MOVL *XAR4++, ACC ;Write dst #8
|
||||
|
||||
line3b:
|
||||
; Do the remaining elements as 16-bit copies. There could be up to 15 of them.
|
||||
MOV AL, PL ;Restore the saved copy number
|
||||
AND AL, #000Fh ;Isolate 1st 4 bits of the copy number (0 - 15 copies)
|
||||
|
||||
MOVL XAR7, #0 ;Zero out XAR7
|
||||
MOV AR7, SP ;AR7 = SP
|
||||
ADD SP, AL ;Advance stack pointer beyond copy area
|
||||
|
||||
ADDB AL, #-1 ;Repeat "N-1" times
|
||||
BF done3, NC ;Branch if N was zero
|
||||
RPT @AL
|
||||
|| PWRITE *XAR7, *XAR5++ ;Copy src words to the stack
|
||||
RPT @AL
|
||||
|| PREAD *XAR4++, *XAR7 ;Copy stack words to the dst
|
||||
|
||||
SUB SP, AL ;Restore the stack pointer (part 1)
|
||||
SUB SP, #1 ;Restore the stack pointer (part 2)
|
||||
|
||||
;Finish up
|
||||
done3:
|
||||
LRETR ;return
|
||||
|
||||
;end of function memcpy_fast_far()
|
||||
**********************************************************************
|
||||
|
||||
.end
|
||||
;end of file memcpy_fast_far.asm
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="empty_bitfield_project"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../empty_bitfield_main.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="empty_bitfield_driverlib_project"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_DUAL_HEADERS --gen_func_subsections --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_DUAL_HEADERS --define=_FLASH --gen_func_subsections --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<file action="copy" path="../../../../common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../empty_bitfield_driverlib_main.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: empty_bitfield_driverlib_main.c
|
||||
//
|
||||
// TITLE: Empty Example
|
||||
//
|
||||
// Empty Bit-Field & Driverlib Example
|
||||
//
|
||||
// This example is an empty project setup for Bit-Field and Driverlib
|
||||
// development.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,64 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: empty_bitfield_main.c
|
||||
//
|
||||
// TITLE: Empty Example
|
||||
//
|
||||
// Empty Bit-Field Example
|
||||
//
|
||||
// This example is an empty project setup for Bit-Field development.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="epwm_ex1_trip_zone"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_cputimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../epwm_ex1_trip_zone.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="epwm_ex2_updown_aq"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_cputimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../epwm_ex2_updown_aq.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="epwm_ex3_up_aq"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_cputimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../epwm_ex3_up_aq.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="epwm_ex4_deadband"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_cputimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../epwm_ex4_deadband.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,402 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: epwm_ex1_trip_zone.c
|
||||
//
|
||||
// TITLE: ePWM module using Trip-Zone submodule.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> EPWM Trip Zone Module (epwm_trip_zone)</h1>
|
||||
//!
|
||||
//! This example configures ePWM1 and ePWM2 as follows
|
||||
//! - ePWM1 has TZ1 as one shot trip source
|
||||
//! - ePWM2 has TZ1 as cycle by cycle trip source
|
||||
//!
|
||||
//! Initially tie TZ1 high. During the test, monitor ePWM1 or ePWM2
|
||||
//! outputs on a scope. Pull TZ1 low to see the effect.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - EPWM1A is on GPIO0
|
||||
//! - EPWM2A is on GPIO2
|
||||
//! - TZ1 is on GPIO12
|
||||
//!
|
||||
//! This example also makes use of the Input X-BAR. GPIO12 (the external
|
||||
//! trigger) is routed to the input X_BAR, from which it is routed to TZ1.
|
||||
//!
|
||||
//! The TZ-Event is defined such that EPWM1A will undergo a One-Shot Trip
|
||||
//! and EPWM2A will undergo a Cycle-By-Cycle Trip.
|
||||
//!
|
||||
// _____________ __________________
|
||||
// | | | |
|
||||
// GPIO12 -----| I/P X-BAR |-----TZ1-----| ePWM TZ Module |-----TZ-Event
|
||||
// |___________| |________________|
|
||||
//
|
||||
//
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define EXTTrig // Leave Uncommented for Testing with External Trigger.
|
||||
// Comment for Testing with ePWM Trigger.
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint32 EPwm1TZIntCount;
|
||||
Uint32 EPwm2TZIntCount;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void InitEPwm1Example(void);
|
||||
void InitEPwm2Example(void);
|
||||
void InitTzGpio(void);
|
||||
__interrupt void epwm1_tzint_isr(void);
|
||||
__interrupt void epwm2_tzint_isr(void);
|
||||
void InitEPwmGpio_TZ(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the <device>_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitGpio();
|
||||
|
||||
//
|
||||
// enable PWM1, and PWM2
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR2.bit.EPWM1=1;
|
||||
CpuSysRegs.PCLKCR2.bit.EPWM2=1;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// For this case just init GPIO pins for ePWM1, ePWM2, ePWM3
|
||||
//
|
||||
InitEPwmGpio_TZ();
|
||||
InitTzGpio();
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
//
|
||||
EALLOW; // This is needed to write to EALLOW protected registers
|
||||
PieVectTable.EPWM1_TZ_INT = &epwm1_tzint_isr;
|
||||
PieVectTable.EPWM2_TZ_INT = &epwm2_tzint_isr;
|
||||
EDIS; // This is needed to disable write to EALLOW protected registers
|
||||
|
||||
//
|
||||
// Step 4. Initialize the Device Peripherals:
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =0;
|
||||
EDIS;
|
||||
|
||||
InitEPwm1Example();
|
||||
InitEPwm2Example();
|
||||
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =1;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Step 5. User specific code, enable interrupts:
|
||||
//
|
||||
EPwm1TZIntCount = 0;
|
||||
EPwm2TZIntCount = 0;
|
||||
|
||||
//
|
||||
// Enable CPU INT2 which is connected to EPWM1-3 INT:
|
||||
//
|
||||
IER |= M_INT2;
|
||||
|
||||
//
|
||||
// Enable EPWM INTn in the PIE: Group 3 interrupt 1-3
|
||||
//
|
||||
PieCtrlRegs.PIEIER2.bit.INTx1 = 1;
|
||||
PieCtrlRegs.PIEIER2.bit.INTx2 = 1;
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Step 6. IDLE loop. Just sit and loop forever (optional):
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
asm (" NOP");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// epwm1_tzint_isr - EPWM1 TZ ISR
|
||||
//
|
||||
__interrupt void epwm1_tzint_isr(void)
|
||||
{
|
||||
EPwm1TZIntCount++;
|
||||
|
||||
//
|
||||
// To Re-enable the OST Interrupt, do the following:
|
||||
// EALLOW;
|
||||
// EPwm1Regs.TZCLR.bit.OST = 1;
|
||||
// EPwm1Regs.TZCLR.bit.INT = 1;
|
||||
// EDIS;
|
||||
//
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 2
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP2;
|
||||
}
|
||||
|
||||
//
|
||||
// epwm2_tzint_isr - EPWM2 TZ ISR
|
||||
//
|
||||
__interrupt void epwm2_tzint_isr(void)
|
||||
{
|
||||
GpioDataRegs.GPATOGGLE.bit.GPIO11 = 1;
|
||||
|
||||
EPwm2TZIntCount++;
|
||||
|
||||
//
|
||||
// Clear the flags - we will continue to take
|
||||
// this interrupt until the TZ pin goes high
|
||||
//
|
||||
EALLOW;
|
||||
EPwm2Regs.TZCLR.bit.CBC = 1;
|
||||
EPwm2Regs.TZCLR.bit.INT = 1;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 2
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP2;
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm1Example - Initialize EPWM1 configuration
|
||||
//
|
||||
void InitEPwm1Example()
|
||||
{
|
||||
//
|
||||
// Enable TZ1 as one shot trip sources
|
||||
//
|
||||
EALLOW;
|
||||
EPwm1Regs.TZSEL.bit.OSHT1 = 1;
|
||||
|
||||
//
|
||||
// Set TZA
|
||||
//
|
||||
EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_HI;
|
||||
|
||||
//
|
||||
// Enable TZ interrupt
|
||||
//
|
||||
EPwm1Regs.TZEINT.bit.OST = 1;
|
||||
EDIS;
|
||||
|
||||
EPwm1Regs.TBPRD = 12000; // Set timer period
|
||||
EPwm1Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
EPwm1Regs.TBCTR = 0x0000; // Clear counter
|
||||
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
|
||||
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
|
||||
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV4; // Clock ratio to SYSCLKOUT
|
||||
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV4;
|
||||
|
||||
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every ZERO
|
||||
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
|
||||
//
|
||||
// Setup compare
|
||||
//
|
||||
EPwm1Regs.CMPA.bit.CMPA = 6000;
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM1A on CAU
|
||||
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR; // Clear PWM1A on CAD
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm2Example - Initialize EPWM2 configuration
|
||||
//
|
||||
void InitEPwm2Example()
|
||||
{
|
||||
//
|
||||
// Enable TZ1 as one cycle-by-cycle trip sources
|
||||
//
|
||||
EALLOW;
|
||||
EPwm2Regs.TZSEL.bit.CBC1 = 1;
|
||||
|
||||
//
|
||||
// Set TZA
|
||||
//
|
||||
EPwm2Regs.TZCTL.bit.TZA = TZ_FORCE_HI;
|
||||
|
||||
//
|
||||
// Enable TZ interrupt
|
||||
//
|
||||
EPwm2Regs.TZEINT.bit.CBC = 1;
|
||||
EDIS;
|
||||
|
||||
EPwm2Regs.TBPRD = 6000; // Set timer period
|
||||
EPwm2Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
EPwm2Regs.TBCTR = 0x0000; // Clear counter
|
||||
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
|
||||
EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
|
||||
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV4; // Clock ratio to SYSCLKOUT
|
||||
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV4; // Slow just to observe on
|
||||
// the scope.
|
||||
|
||||
//
|
||||
// Setup compare
|
||||
//
|
||||
EPwm2Regs.CMPA.bit.CMPA = 3000;
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
EPwm2Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM2A on CAU
|
||||
EPwm2Regs.AQCTLA.bit.CAD = AQ_CLEAR; // Clear PWM2A on CAD
|
||||
}
|
||||
|
||||
//
|
||||
// InitTzGpio - Initialize TZ GPIOs
|
||||
//
|
||||
void InitTzGpio(void)
|
||||
{
|
||||
//
|
||||
// For External Trigger, GPIO12 as the trigger for TripZone
|
||||
//
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0; // Enable pull-up on GPIO12 (TZ1)
|
||||
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO12 = 3; // Asynch input GPIO12 (TZ1)
|
||||
EDIS;
|
||||
|
||||
EALLOW;
|
||||
InputXbarRegs.INPUT1SELECT = 12;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// For monitoring when the TZ Interrupt has been entered
|
||||
//
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO11 = 1; // Disable pull-up on GPIO0 (EPWM1A)
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 0; // Configure GPIO0 as EPWM1A
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO11 = 1;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwmGpio_TZ - Initialize EPWM1A and EPWM2A GPIOs
|
||||
//
|
||||
void InitEPwmGpio_TZ(void)
|
||||
{
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 1; // Disable pull-up on GPIO0 (EPWM1A)
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // Configure GPIO0 as EPWM1A
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO2 = 1; // Disable pull-up on GPIO2 (EPWM2A)
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1; // Configure GPIO2 as EPWM2A
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,606 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: epwm_ex2_updown_aq_cpu01.c
|
||||
//
|
||||
// TITLE: Action Qualifier Module - Using up/down count.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> EPWM Action Qualifier (epwm_updown_aq)</h1>
|
||||
//!
|
||||
//! This example configures ePWM1, ePWM2, ePWM3 to produce an
|
||||
//! waveform with independent modulation on EPWMxA and
|
||||
//! EPWMxB.
|
||||
//!
|
||||
//! The compare values CMPA and CMPB are modified within the ePWM's ISR.
|
||||
//!
|
||||
//! The TB counter is in up/down count mode for this example.
|
||||
//!
|
||||
//! View the EPWM1A/B(PA0_GPIO0 & PA1_GPIO1), EPWM2A/B(PA2_GPIO2 & PA3_GPIO3)
|
||||
//! and EPWM3A/B(PA4_GPIO4 & PA5_GPIO5) waveforms via an oscilloscope.
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define EPWM1_TIMER_TBPRD 2000 // Period register
|
||||
#define EPWM1_MAX_CMPA 1950
|
||||
#define EPWM1_MIN_CMPA 50
|
||||
#define EPWM1_MAX_CMPB 1950
|
||||
#define EPWM1_MIN_CMPB 50
|
||||
|
||||
#define EPWM2_TIMER_TBPRD 2000 // Period register
|
||||
#define EPWM2_MAX_CMPA 1950
|
||||
#define EPWM2_MIN_CMPA 50
|
||||
#define EPWM2_MAX_CMPB 1950
|
||||
#define EPWM2_MIN_CMPB 50
|
||||
|
||||
#define EPWM3_TIMER_TBPRD 2000 // Period register
|
||||
#define EPWM3_MAX_CMPA 950
|
||||
#define EPWM3_MIN_CMPA 50
|
||||
#define EPWM3_MAX_CMPB 1950
|
||||
#define EPWM3_MIN_CMPB 1050
|
||||
|
||||
#define EPWM_CMP_UP 1
|
||||
#define EPWM_CMP_DOWN 0
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
volatile struct EPWM_REGS *EPwmRegHandle;
|
||||
Uint16 EPwm_CMPA_Direction;
|
||||
Uint16 EPwm_CMPB_Direction;
|
||||
Uint16 EPwmTimerIntCount;
|
||||
Uint16 EPwmMaxCMPA;
|
||||
Uint16 EPwmMinCMPA;
|
||||
Uint16 EPwmMaxCMPB;
|
||||
Uint16 EPwmMinCMPB;
|
||||
}EPWM_INFO;
|
||||
|
||||
EPWM_INFO epwm1_info;
|
||||
EPWM_INFO epwm2_info;
|
||||
EPWM_INFO epwm3_info;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void InitEPwm1Example(void);
|
||||
void InitEPwm2Example(void);
|
||||
void InitEPwm3Example(void);
|
||||
__interrupt void epwm1_isr(void);
|
||||
__interrupt void epwm2_isr(void);
|
||||
__interrupt void epwm3_isr(void);
|
||||
void update_compare(EPWM_INFO*);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
// InitGpio();
|
||||
|
||||
//
|
||||
// enable PWM1, PWM2 and PWM3
|
||||
//
|
||||
CpuSysRegs.PCLKCR2.bit.EPWM1=1;
|
||||
CpuSysRegs.PCLKCR2.bit.EPWM2=1;
|
||||
CpuSysRegs.PCLKCR2.bit.EPWM3=1;
|
||||
|
||||
//
|
||||
// For this case just init GPIO pins for ePWM1, ePWM2, ePWM3
|
||||
// These functions are in the f2838x_epwm.c file
|
||||
//
|
||||
InitEPwm1Gpio();
|
||||
InitEPwm2Gpio();
|
||||
InitEPwm3Gpio();
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
//
|
||||
EALLOW; // This is needed to write to EALLOW protected registers
|
||||
PieVectTable.EPWM1_INT = &epwm1_isr;
|
||||
PieVectTable.EPWM2_INT = &epwm2_isr;
|
||||
PieVectTable.EPWM3_INT = &epwm3_isr;
|
||||
EDIS; // This is needed to disable write to EALLOW protected registers
|
||||
|
||||
//
|
||||
// For this example, only initialize the ePWM
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
|
||||
EDIS;
|
||||
|
||||
InitEPwm1Example();
|
||||
InitEPwm2Example();
|
||||
InitEPwm3Example();
|
||||
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Step 4. User specific code, enable interrupts:
|
||||
//
|
||||
|
||||
//
|
||||
// Enable CPU INT3 which is connected to EPWM1-3 INT:
|
||||
//
|
||||
IER |= M_INT3;
|
||||
|
||||
//
|
||||
// Enable EPWM INTn in the PIE: Group 3 interrupt 1-3
|
||||
//
|
||||
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;
|
||||
PieCtrlRegs.PIEIER3.bit.INTx2 = 1;
|
||||
PieCtrlRegs.PIEIER3.bit.INTx3 = 1;
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Step 5. IDLE loop. Just sit and loop forever (optional):
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
asm (" NOP");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// epwm1_isr - EPWM1 ISR
|
||||
//
|
||||
__interrupt void epwm1_isr(void)
|
||||
{
|
||||
//
|
||||
// Update the CMPA and CMPB values
|
||||
//
|
||||
update_compare(&epwm1_info);
|
||||
|
||||
//
|
||||
// Clear INT flag for this timer
|
||||
//
|
||||
EPwm1Regs.ETCLR.bit.INT = 1;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 3
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
|
||||
}
|
||||
|
||||
//
|
||||
// epwm2_isr - EPWM2 ISR
|
||||
//
|
||||
__interrupt void epwm2_isr(void)
|
||||
{
|
||||
//
|
||||
// Update the CMPA and CMPB values
|
||||
//
|
||||
update_compare(&epwm2_info);
|
||||
|
||||
//
|
||||
// Clear INT flag for this timer
|
||||
//
|
||||
EPwm2Regs.ETCLR.bit.INT = 1;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 3
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
|
||||
}
|
||||
|
||||
//
|
||||
// epwm3_isr - EPWM3 ISR
|
||||
//
|
||||
__interrupt void epwm3_isr(void)
|
||||
{
|
||||
//
|
||||
// Update the CMPA and CMPB values
|
||||
//
|
||||
update_compare(&epwm3_info);
|
||||
|
||||
//
|
||||
// Clear INT flag for this timer
|
||||
//
|
||||
EPwm3Regs.ETCLR.bit.INT = 1;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 3
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm1Example - Initialize EPWM1 configuration
|
||||
//
|
||||
void InitEPwm1Example()
|
||||
{
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
EPwm1Regs.TBPRD = EPWM1_TIMER_TBPRD; // Set timer period 801 TBCLKs
|
||||
EPwm1Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
EPwm1Regs.TBCTR = 0x0000; // Clear counter
|
||||
|
||||
//
|
||||
// Set Compare values
|
||||
//
|
||||
EPwm1Regs.CMPA.bit.CMPA = EPWM1_MIN_CMPA; // Set compare A value
|
||||
EPwm1Regs.CMPB.bit.CMPB = EPWM1_MAX_CMPB; // Set Compare B value
|
||||
|
||||
//
|
||||
// Setup counter mode
|
||||
//
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up and down
|
||||
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
|
||||
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
|
||||
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
//
|
||||
// Setup shadowing
|
||||
//
|
||||
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // Load on Zero
|
||||
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM1A on event A, up
|
||||
// count
|
||||
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR; // Clear PWM1A on event A,
|
||||
// down count
|
||||
|
||||
EPwm1Regs.AQCTLB.bit.CBU = AQ_SET; // Set PWM1B on event B, up
|
||||
// count
|
||||
EPwm1Regs.AQCTLB.bit.CBD = AQ_CLEAR; // Clear PWM1B on event B,
|
||||
// down count
|
||||
|
||||
//
|
||||
// Interrupt where we will change the Compare Values
|
||||
//
|
||||
EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
|
||||
EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable INT
|
||||
EPwm1Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
|
||||
|
||||
//
|
||||
// Information this example uses to keep track
|
||||
// of the direction the CMPA/CMPB values are
|
||||
// moving, the min and max allowed values and
|
||||
// a pointer to the correct ePWM registers
|
||||
//
|
||||
epwm1_info.EPwm_CMPA_Direction = EPWM_CMP_UP; // Start by increasing CMPA
|
||||
epwm1_info.EPwm_CMPB_Direction = EPWM_CMP_DOWN; // & decreasing CMPB
|
||||
epwm1_info.EPwmTimerIntCount = 0; // Zero the interrupt counter
|
||||
epwm1_info.EPwmRegHandle = &EPwm1Regs; // Set the pointer to the
|
||||
// ePWM module
|
||||
epwm1_info.EPwmMaxCMPA = EPWM1_MAX_CMPA; // Setup min/max CMPA/CMPB
|
||||
// values
|
||||
epwm1_info.EPwmMinCMPA = EPWM1_MIN_CMPA;
|
||||
epwm1_info.EPwmMaxCMPB = EPWM1_MAX_CMPB;
|
||||
epwm1_info.EPwmMinCMPB = EPWM1_MIN_CMPB;
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm2Example - Initialize EPWM2 configuration
|
||||
//
|
||||
void InitEPwm2Example()
|
||||
{
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
EPwm2Regs.TBPRD = EPWM2_TIMER_TBPRD; // Set timer period 801 TBCLKs
|
||||
EPwm2Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
EPwm2Regs.TBCTR = 0x0000; // Clear counter
|
||||
|
||||
//
|
||||
// Set Compare values
|
||||
//
|
||||
EPwm2Regs.CMPA.bit.CMPA = EPWM2_MIN_CMPA; // Set compare A value
|
||||
EPwm2Regs.CMPB.bit.CMPB = EPWM2_MIN_CMPB; // Set Compare B value
|
||||
|
||||
//
|
||||
// Setup counter mode
|
||||
//
|
||||
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up and down
|
||||
EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
|
||||
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
|
||||
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
//
|
||||
// Setup shadowing
|
||||
//
|
||||
EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // Load on Zero
|
||||
EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
EPwm2Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM2A on event A, up
|
||||
// count
|
||||
EPwm2Regs.AQCTLA.bit.CBD = AQ_CLEAR; // Clear PWM2A on event B, down
|
||||
// count
|
||||
|
||||
EPwm2Regs.AQCTLB.bit.ZRO = AQ_CLEAR; // Clear PWM2B on zero
|
||||
EPwm2Regs.AQCTLB.bit.PRD = AQ_SET; // Set PWM2B on period
|
||||
|
||||
//
|
||||
// Interrupt where we will change the Compare Values
|
||||
//
|
||||
EPwm2Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
|
||||
EPwm2Regs.ETSEL.bit.INTEN = 1; // Enable INT
|
||||
EPwm2Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
|
||||
|
||||
//
|
||||
// Information this example uses to keep track
|
||||
// of the direction the CMPA/CMPB values are
|
||||
// moving, the min and max allowed values and
|
||||
// a pointer to the correct ePWM registers
|
||||
//
|
||||
epwm2_info.EPwm_CMPA_Direction = EPWM_CMP_UP; // Start by increasing CMPA
|
||||
epwm2_info.EPwm_CMPB_Direction = EPWM_CMP_UP; // & increasing CMPB
|
||||
epwm2_info.EPwmTimerIntCount = 0; // Zero the interrupt counter
|
||||
epwm2_info.EPwmRegHandle = &EPwm2Regs; // Set the pointer to the
|
||||
// ePWM module
|
||||
epwm2_info.EPwmMaxCMPA = EPWM2_MAX_CMPA; // Setup min/max CMPA/CMPB
|
||||
// values
|
||||
epwm2_info.EPwmMinCMPA = EPWM2_MIN_CMPA;
|
||||
epwm2_info.EPwmMaxCMPB = EPWM2_MAX_CMPB;
|
||||
epwm2_info.EPwmMinCMPB = EPWM2_MIN_CMPB;
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm3Example - Initialize EPWM3 configuration
|
||||
//
|
||||
void InitEPwm3Example(void)
|
||||
{
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up/down and down
|
||||
EPwm3Regs.TBPRD = EPWM3_TIMER_TBPRD; // Set timer period
|
||||
EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
|
||||
EPwm3Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
EPwm3Regs.TBCTR = 0x0000; // Clear counter
|
||||
EPwm3Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
|
||||
EPwm3Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
//
|
||||
// Setup shadow register load on ZERO
|
||||
//
|
||||
EPwm3Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm3Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
EPwm3Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm3Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
|
||||
//
|
||||
// Set Compare values
|
||||
//
|
||||
EPwm3Regs.CMPA.bit.CMPA = EPWM3_MIN_CMPA; // Set compare A value
|
||||
EPwm3Regs.CMPB.bit.CMPB = EPWM3_MAX_CMPB; // Set Compare B value
|
||||
|
||||
//
|
||||
// Set Actions
|
||||
//
|
||||
EPwm3Regs.AQCTLA.bit.PRD = AQ_SET; // Set PWM3A on period
|
||||
EPwm3Regs.AQCTLA.bit.CBD = AQ_CLEAR; // Clear PWM3A on event B, down
|
||||
// count
|
||||
|
||||
EPwm3Regs.AQCTLB.bit.PRD = AQ_CLEAR; // Clear PWM3A on period
|
||||
EPwm3Regs.AQCTLB.bit.CAU = AQ_SET; // Set PWM3A on event A, up
|
||||
// count
|
||||
|
||||
//
|
||||
// Interrupt where we will change the Compare Values
|
||||
//
|
||||
EPwm3Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
|
||||
EPwm3Regs.ETSEL.bit.INTEN = 1; // Enable INT
|
||||
EPwm3Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
|
||||
|
||||
//
|
||||
// Information this example uses to keep track
|
||||
// of the direction the CMPA/CMPB values are
|
||||
// moving, the min and max allowed values and
|
||||
// a pointer to the correct ePWM registers
|
||||
//
|
||||
epwm3_info.EPwm_CMPA_Direction = EPWM_CMP_UP; // Start by increasing CMPA
|
||||
epwm3_info.EPwm_CMPB_Direction = EPWM_CMP_DOWN; // & decreasing CMPB
|
||||
epwm3_info.EPwmTimerIntCount = 0; // Zero the interrupt counter
|
||||
epwm3_info.EPwmRegHandle = &EPwm3Regs; // Set the pointer to the
|
||||
// ePWM module
|
||||
epwm3_info.EPwmMaxCMPA = EPWM3_MAX_CMPA; // Setup min/max CMPA/CMPB
|
||||
// values
|
||||
epwm3_info.EPwmMinCMPA = EPWM3_MIN_CMPA;
|
||||
epwm3_info.EPwmMaxCMPB = EPWM3_MAX_CMPB;
|
||||
epwm3_info.EPwmMinCMPB = EPWM3_MIN_CMPB;
|
||||
}
|
||||
|
||||
//
|
||||
// update_compare - Update the PWM compare values
|
||||
//
|
||||
void update_compare(EPWM_INFO *epwm_info)
|
||||
{
|
||||
//
|
||||
// Every 10'th interrupt, change the CMPA/CMPB values
|
||||
//
|
||||
if(epwm_info->EPwmTimerIntCount == 10)
|
||||
{
|
||||
epwm_info->EPwmTimerIntCount = 0;
|
||||
|
||||
//
|
||||
// If we were increasing CMPA, check to see if
|
||||
// we reached the max value. If not, increase CMPA
|
||||
// else, change directions and decrease CMPA
|
||||
//
|
||||
if(epwm_info->EPwm_CMPA_Direction == EPWM_CMP_UP)
|
||||
{
|
||||
if(epwm_info->EPwmRegHandle->CMPA.bit.CMPA <
|
||||
epwm_info->EPwmMaxCMPA)
|
||||
{
|
||||
epwm_info->EPwmRegHandle->CMPA.bit.CMPA++;
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm_info->EPwm_CMPA_Direction = EPWM_CMP_DOWN;
|
||||
epwm_info->EPwmRegHandle->CMPA.bit.CMPA--;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we were decreasing CMPA, check to see if
|
||||
// we reached the min value. If not, decrease CMPA
|
||||
// else, change directions and increase CMPA
|
||||
//
|
||||
else
|
||||
{
|
||||
if(epwm_info->EPwmRegHandle->CMPA.bit.CMPA ==
|
||||
epwm_info->EPwmMinCMPA)
|
||||
{
|
||||
epwm_info->EPwm_CMPA_Direction = EPWM_CMP_UP;
|
||||
epwm_info->EPwmRegHandle->CMPA.bit.CMPA++;
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm_info->EPwmRegHandle->CMPA.bit.CMPA--;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we were increasing CMPB, check to see if
|
||||
// we reached the max value. If not, increase CMPB
|
||||
// else, change directions and decrease CMPB
|
||||
//
|
||||
if(epwm_info->EPwm_CMPB_Direction == EPWM_CMP_UP)
|
||||
{
|
||||
if(epwm_info->EPwmRegHandle->CMPB.bit.CMPB < epwm_info->EPwmMaxCMPB)
|
||||
{
|
||||
epwm_info->EPwmRegHandle->CMPB.bit.CMPB++;
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm_info->EPwm_CMPB_Direction = EPWM_CMP_DOWN;
|
||||
epwm_info->EPwmRegHandle->CMPB.bit.CMPB--;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we were decreasing CMPB, check to see if
|
||||
// we reached the min value. If not, decrease CMPB
|
||||
// else, change directions and increase CMPB
|
||||
//
|
||||
else
|
||||
{
|
||||
if(epwm_info->EPwmRegHandle->CMPB.bit.CMPB == epwm_info->EPwmMinCMPB)
|
||||
{
|
||||
epwm_info->EPwm_CMPB_Direction = EPWM_CMP_UP;
|
||||
epwm_info->EPwmRegHandle->CMPB.bit.CMPB++;
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm_info->EPwmRegHandle->CMPB.bit.CMPB--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm_info->EPwmTimerIntCount++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,591 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: epwm_ex3_up_aq_cpu01.c
|
||||
//
|
||||
// TITLE: Action Qualifier Module - Using up count.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> EPWM Action Qualifier (epwm_up_aq)</h1>
|
||||
//!
|
||||
//! This example configures ePWM1, ePWM2, ePWM3 to produce an
|
||||
//! waveform with independent modulation on EPWMxA and
|
||||
//! EPWMxB.
|
||||
//!
|
||||
//! The compare values CMPA and CMPB are modified within the ePWM's ISR.
|
||||
//!
|
||||
//! The TB counter is in up count mode for this example.
|
||||
//!
|
||||
//! View the EPWM1A/B(PA0_GPIO0 & PA1_GPIO1), EPWM2A/B(PA2_GPIO2 & PA3_GPIO3)
|
||||
//! and EPWM3A/B(PA4_GPIO4 & PA5_GPIO5) waveforms via an oscilloscope.
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define EPWM1_TIMER_TBPRD 2000 // Period register
|
||||
#define EPWM1_MAX_CMPA 1950
|
||||
#define EPWM1_MIN_CMPA 50
|
||||
#define EPWM1_MAX_CMPB 1950
|
||||
#define EPWM1_MIN_CMPB 50
|
||||
|
||||
#define EPWM2_TIMER_TBPRD 2000 // Period register
|
||||
#define EPWM2_MAX_CMPA 1950
|
||||
#define EPWM2_MIN_CMPA 50
|
||||
#define EPWM2_MAX_CMPB 1950
|
||||
#define EPWM2_MIN_CMPB 50
|
||||
|
||||
#define EPWM3_TIMER_TBPRD 2000 // Period register
|
||||
#define EPWM3_MAX_CMPA 950
|
||||
#define EPWM3_MIN_CMPA 50
|
||||
#define EPWM3_MAX_CMPB 1950
|
||||
#define EPWM3_MIN_CMPB 1050
|
||||
|
||||
#define EPWM_CMP_UP 1
|
||||
#define EPWM_CMP_DOWN 0
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
typedef struct
|
||||
{
|
||||
volatile struct EPWM_REGS *EPwmRegHandle;
|
||||
Uint16 EPwm_CMPA_Direction;
|
||||
Uint16 EPwm_CMPB_Direction;
|
||||
Uint16 EPwmTimerIntCount;
|
||||
Uint16 EPwmMaxCMPA;
|
||||
Uint16 EPwmMinCMPA;
|
||||
Uint16 EPwmMaxCMPB;
|
||||
Uint16 EPwmMinCMPB;
|
||||
}EPWM_INFO;
|
||||
|
||||
EPWM_INFO epwm1_info;
|
||||
EPWM_INFO epwm2_info;
|
||||
EPWM_INFO epwm3_info;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void InitEPwm1Example(void);
|
||||
void InitEPwm2Example(void);
|
||||
void InitEPwm3Example(void);
|
||||
__interrupt void epwm1_isr(void);
|
||||
__interrupt void epwm2_isr(void);
|
||||
__interrupt void epwm3_isr(void);
|
||||
void update_compare(EPWM_INFO*);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
// InitGpio();
|
||||
|
||||
//
|
||||
// Enable PWM1, PWM2 and PWM3
|
||||
//
|
||||
CpuSysRegs.PCLKCR2.bit.EPWM1=1;
|
||||
CpuSysRegs.PCLKCR2.bit.EPWM2=1;
|
||||
CpuSysRegs.PCLKCR2.bit.EPWM3=1;
|
||||
|
||||
//
|
||||
// For this case just init GPIO pins for ePWM1, ePWM2, ePWM3
|
||||
// These functions are in the f2838x_epwm.c file
|
||||
//
|
||||
InitEPwm1Gpio();
|
||||
InitEPwm2Gpio();
|
||||
InitEPwm3Gpio();
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
//
|
||||
EALLOW; // This is needed to write to EALLOW protected registers
|
||||
PieVectTable.EPWM1_INT = &epwm1_isr;
|
||||
PieVectTable.EPWM2_INT = &epwm2_isr;
|
||||
PieVectTable.EPWM3_INT = &epwm3_isr;
|
||||
EDIS; // This is needed to disable write to EALLOW protected registers
|
||||
|
||||
//
|
||||
// For this example, only initialize the ePWM
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
|
||||
EDIS;
|
||||
|
||||
InitEPwm1Example();
|
||||
InitEPwm2Example();
|
||||
InitEPwm3Example();
|
||||
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Step 4. User specific code, enable interrupts:
|
||||
//
|
||||
// Enable CPU INT3 which is connected to EPWM1-3 INT:
|
||||
//
|
||||
IER |= M_INT3;
|
||||
|
||||
//
|
||||
// Enable EPWM INTn in the PIE: Group 3 interrupt 1-3
|
||||
//
|
||||
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;
|
||||
PieCtrlRegs.PIEIER3.bit.INTx2 = 1;
|
||||
PieCtrlRegs.PIEIER3.bit.INTx3 = 1;
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Step 5. IDLE loop. Just sit and loop forever (optional):
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
asm (" NOP");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// epwm1_isr - EPWM1 ISR to update compare values
|
||||
//
|
||||
__interrupt void epwm1_isr(void)
|
||||
{
|
||||
//
|
||||
// Update the CMPA and CMPB values
|
||||
//
|
||||
update_compare(&epwm1_info);
|
||||
|
||||
//
|
||||
// Clear INT flag for this timer
|
||||
//
|
||||
EPwm1Regs.ETCLR.bit.INT = 1;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 3
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
|
||||
}
|
||||
|
||||
//
|
||||
// epwm2_isr - EPWM2 ISR to update compare values
|
||||
//
|
||||
__interrupt void epwm2_isr(void)
|
||||
{
|
||||
//
|
||||
// Update the CMPA and CMPB values
|
||||
//
|
||||
update_compare(&epwm2_info);
|
||||
|
||||
//
|
||||
// Clear INT flag for this timer
|
||||
//
|
||||
EPwm2Regs.ETCLR.bit.INT = 1;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 3
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
|
||||
}
|
||||
|
||||
//
|
||||
// epwm3_isr - EPWM3 ISR to update compare values
|
||||
//
|
||||
__interrupt void epwm3_isr(void)
|
||||
{
|
||||
//
|
||||
// Update the CMPA and CMPB values
|
||||
//
|
||||
update_compare(&epwm3_info);
|
||||
|
||||
//
|
||||
// Clear INT flag for this timer
|
||||
//
|
||||
EPwm3Regs.ETCLR.bit.INT = 1;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 3
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm1Example - Initialize EPWM1 values
|
||||
//
|
||||
void InitEPwm1Example()
|
||||
{
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
|
||||
EPwm1Regs.TBPRD = EPWM1_TIMER_TBPRD; // Set timer period
|
||||
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
|
||||
EPwm1Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
EPwm1Regs.TBCTR = 0x0000; // Clear counter
|
||||
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2; // Clock ratio to SYSCLKOUT
|
||||
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV2;
|
||||
|
||||
//
|
||||
// Setup shadow register load on ZERO
|
||||
//
|
||||
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
|
||||
//
|
||||
// Set Compare values
|
||||
//
|
||||
EPwm1Regs.CMPA.bit.CMPA = EPWM1_MIN_CMPA; // Set compare A value
|
||||
EPwm1Regs.CMPB.bit.CMPB = EPWM1_MIN_CMPB; // Set Compare B value
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET; // Set PWM1A on Zero
|
||||
EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Clear PWM1A on event A,
|
||||
// up count
|
||||
|
||||
EPwm1Regs.AQCTLB.bit.ZRO = AQ_SET; // Set PWM1B on Zero
|
||||
EPwm1Regs.AQCTLB.bit.CBU = AQ_CLEAR; // Clear PWM1B on event B,
|
||||
// up count
|
||||
|
||||
//
|
||||
// Interrupt where we will change the Compare Values
|
||||
//
|
||||
EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
|
||||
EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable INT
|
||||
EPwm1Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
|
||||
|
||||
//
|
||||
// Information this example uses to keep track
|
||||
// of the direction the CMPA/CMPB values are
|
||||
// moving, the min and max allowed values and
|
||||
// a pointer to the correct ePWM registers
|
||||
//
|
||||
epwm1_info.EPwm_CMPA_Direction = EPWM_CMP_UP; // Start by increasing
|
||||
// CMPA & CMPB
|
||||
epwm1_info.EPwm_CMPB_Direction = EPWM_CMP_UP;
|
||||
epwm1_info.EPwmTimerIntCount = 0; // Zero the interrupt counter
|
||||
epwm1_info.EPwmRegHandle = &EPwm1Regs; // Set the pointer to the
|
||||
// ePWM module
|
||||
epwm1_info.EPwmMaxCMPA = EPWM1_MAX_CMPA; // Setup min/max
|
||||
// CMPA/CMPB values
|
||||
epwm1_info.EPwmMinCMPA = EPWM1_MIN_CMPA;
|
||||
epwm1_info.EPwmMaxCMPB = EPWM1_MAX_CMPB;
|
||||
epwm1_info.EPwmMinCMPB = EPWM1_MIN_CMPB;
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm2Example - Initialize EPWM2 values
|
||||
//
|
||||
void InitEPwm2Example()
|
||||
{
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
|
||||
EPwm2Regs.TBPRD = EPWM2_TIMER_TBPRD; // Set timer period
|
||||
EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
|
||||
EPwm2Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
EPwm2Regs.TBCTR = 0x0000; // Clear counter
|
||||
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2; // Clock ratio to SYSCLKOUT
|
||||
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV2;
|
||||
|
||||
//
|
||||
// Setup shadow register load on ZERO
|
||||
//
|
||||
EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
|
||||
//
|
||||
// Set Compare values
|
||||
//
|
||||
EPwm2Regs.CMPA.bit.CMPA = EPWM2_MIN_CMPA; // Set compare A value
|
||||
EPwm2Regs.CMPB.bit.CMPB = EPWM2_MAX_CMPB; // Set Compare B value
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
EPwm2Regs.AQCTLA.bit.PRD = AQ_CLEAR; // Clear PWM2A on Period
|
||||
EPwm2Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM2A on event A,
|
||||
// up count
|
||||
|
||||
EPwm2Regs.AQCTLB.bit.PRD = AQ_CLEAR; // Clear PWM2B on Period
|
||||
EPwm2Regs.AQCTLB.bit.CBU = AQ_SET; // Set PWM2B on event B,
|
||||
// up count
|
||||
|
||||
//
|
||||
// Interrupt where we will change the Compare Values
|
||||
//
|
||||
EPwm2Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
|
||||
EPwm2Regs.ETSEL.bit.INTEN = 1; // Enable INT
|
||||
EPwm2Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
|
||||
|
||||
//
|
||||
// Information this example uses to keep track
|
||||
// of the direction the CMPA/CMPB values are
|
||||
// moving, the min and max allowed values and
|
||||
// a pointer to the correct ePWM registers
|
||||
//
|
||||
epwm2_info.EPwm_CMPA_Direction = EPWM_CMP_UP; // Start by increasing CMPA
|
||||
epwm2_info.EPwm_CMPB_Direction = EPWM_CMP_DOWN; // and decreasing CMPB
|
||||
epwm2_info.EPwmTimerIntCount = 0; // Zero the interrupt
|
||||
// counter
|
||||
epwm2_info.EPwmRegHandle = &EPwm2Regs; // Set the pointer to the
|
||||
// ePWM module
|
||||
epwm2_info.EPwmMaxCMPA = EPWM2_MAX_CMPA; // Setup min/max
|
||||
// CMPA/CMPB values
|
||||
epwm2_info.EPwmMinCMPA = EPWM2_MIN_CMPA;
|
||||
epwm2_info.EPwmMaxCMPB = EPWM2_MAX_CMPB;
|
||||
epwm2_info.EPwmMinCMPB = EPWM2_MIN_CMPB;
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm3Example - Initialize EPWM3 values
|
||||
//
|
||||
void InitEPwm3Example(void)
|
||||
{
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
|
||||
EPwm3Regs.TBPRD = EPWM3_TIMER_TBPRD; // Set timer period
|
||||
EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
|
||||
EPwm3Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
EPwm3Regs.TBCTR = 0x0000; // Clear counter
|
||||
EPwm3Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
|
||||
EPwm3Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
//
|
||||
// Setup shadow register load on ZERO
|
||||
//
|
||||
EPwm3Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm3Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
EPwm3Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm3Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
|
||||
//
|
||||
// Set Compare values
|
||||
//
|
||||
EPwm3Regs.CMPA.bit.CMPA = EPWM3_MIN_CMPA; // Set compare A value
|
||||
EPwm3Regs.CMPB.bit.CMPB = EPWM3_MAX_CMPB; // Set Compare B value
|
||||
|
||||
//
|
||||
// Set Actions
|
||||
//
|
||||
EPwm3Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM3A on event B, up count
|
||||
EPwm3Regs.AQCTLA.bit.CBU = AQ_CLEAR; // Clear PWM3A on event B,
|
||||
// up count
|
||||
EPwm3Regs.AQCTLB.bit.ZRO = AQ_TOGGLE; // Toggle EPWM3B on Zero
|
||||
|
||||
//
|
||||
// Interrupt where we will change the Compare Values
|
||||
//
|
||||
EPwm3Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
|
||||
EPwm3Regs.ETSEL.bit.INTEN = 1; // Enable INT
|
||||
EPwm3Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
|
||||
|
||||
//
|
||||
// Start by increasing the compare A and decreasing compare B
|
||||
//
|
||||
epwm3_info.EPwm_CMPA_Direction = EPWM_CMP_UP;
|
||||
epwm3_info.EPwm_CMPB_Direction = EPWM_CMP_DOWN;
|
||||
|
||||
//
|
||||
// Start the count at 0
|
||||
//
|
||||
epwm3_info.EPwmTimerIntCount = 0;
|
||||
epwm3_info.EPwmRegHandle = &EPwm3Regs;
|
||||
epwm3_info.EPwmMaxCMPA = EPWM3_MAX_CMPA;
|
||||
epwm3_info.EPwmMinCMPA = EPWM3_MIN_CMPA;
|
||||
epwm3_info.EPwmMaxCMPB = EPWM3_MAX_CMPB;
|
||||
epwm3_info.EPwmMinCMPB = EPWM3_MIN_CMPB;
|
||||
}
|
||||
|
||||
//
|
||||
// update_compare - Update the compare values for the specified EPWM
|
||||
//
|
||||
void update_compare(EPWM_INFO *epwm_info)
|
||||
{
|
||||
//
|
||||
// Every 10'th interrupt, change the CMPA/CMPB values
|
||||
//
|
||||
if(epwm_info->EPwmTimerIntCount == 10)
|
||||
{
|
||||
epwm_info->EPwmTimerIntCount = 0;
|
||||
|
||||
//
|
||||
// If we were increasing CMPA, check to see if
|
||||
// we reached the max value. If not, increase CMPA
|
||||
// else, change directions and decrease CMPA
|
||||
//
|
||||
if(epwm_info->EPwm_CMPA_Direction == EPWM_CMP_UP)
|
||||
{
|
||||
if(epwm_info->EPwmRegHandle->CMPA.bit.CMPA < epwm_info->EPwmMaxCMPA)
|
||||
{
|
||||
epwm_info->EPwmRegHandle->CMPA.bit.CMPA++;
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm_info->EPwm_CMPA_Direction = EPWM_CMP_DOWN;
|
||||
epwm_info->EPwmRegHandle->CMPA.bit.CMPA--;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we were decreasing CMPA, check to see if
|
||||
// we reached the min value. If not, decrease CMPA
|
||||
// else, change directions and increase CMPA
|
||||
//
|
||||
else
|
||||
{
|
||||
if(epwm_info->EPwmRegHandle->CMPA.bit.CMPA == epwm_info->EPwmMinCMPA)
|
||||
{
|
||||
epwm_info->EPwm_CMPA_Direction = EPWM_CMP_UP;
|
||||
epwm_info->EPwmRegHandle->CMPA.bit.CMPA++;
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm_info->EPwmRegHandle->CMPA.bit.CMPA--;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we were increasing CMPB, check to see if
|
||||
// we reached the max value. If not, increase CMPB
|
||||
// else, change directions and decrease CMPB
|
||||
//
|
||||
if(epwm_info->EPwm_CMPB_Direction == EPWM_CMP_UP)
|
||||
{
|
||||
if(epwm_info->EPwmRegHandle->CMPB.bit.CMPB < epwm_info->EPwmMaxCMPB)
|
||||
{
|
||||
epwm_info->EPwmRegHandle->CMPB.bit.CMPB++;
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm_info->EPwm_CMPB_Direction = EPWM_CMP_DOWN;
|
||||
epwm_info->EPwmRegHandle->CMPB.bit.CMPB--;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we were decreasing CMPB, check to see if
|
||||
// we reached the min value. If not, decrease CMPB
|
||||
// else, change directions and increase CMPB
|
||||
//
|
||||
else
|
||||
{
|
||||
if(epwm_info->EPwmRegHandle->CMPB.bit.CMPB ==
|
||||
epwm_info->EPwmMinCMPB)
|
||||
{
|
||||
epwm_info->EPwm_CMPB_Direction = EPWM_CMP_UP;
|
||||
epwm_info->EPwmRegHandle->CMPB.bit.CMPB++;
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm_info->EPwmRegHandle->CMPB.bit.CMPB--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
epwm_info->EPwmTimerIntCount++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,533 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: epwm_ex4_deadband_c28.c
|
||||
//
|
||||
// TITLE: Check PWM Dead-Band
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> EPWM dead band control (epwm_deadband)</h1>
|
||||
//!
|
||||
//! During the test, monitor ePWM1, ePWM2, and/or ePWM3 outputs
|
||||
//! on a scope.
|
||||
//!
|
||||
//! - ePWM1A is on GPIO0
|
||||
//! - ePWM1B is on GPIO1
|
||||
//! - ePWM2A is on GPIO2
|
||||
//! - ePWM2B is on GPIO3
|
||||
//! - ePWM3A is on GPIO4
|
||||
//! - ePWM3B is on GPIO5
|
||||
//!
|
||||
//! This example configures ePWM1, ePWM2 and ePWM3 for:
|
||||
//! - Count up/down
|
||||
//! - Deadband
|
||||
//!
|
||||
//! 3 Examples are included:
|
||||
//! - ePWM1: Active low PWMs
|
||||
//! - ePWM2: Active low complementary PWMs
|
||||
//! - ePWM3: Active high complementary PWMs
|
||||
//!
|
||||
//! Each ePWM is configured to interrupt on the 3rd zero event.
|
||||
//! When this happens the deadband is modified such that
|
||||
//! 0 <= DB <= DB_MAX. That is, the deadband will move up and
|
||||
//! down between 0 and the maximum value.
|
||||
//!
|
||||
//! View the EPWM1A/B, EPWM2A/B and EPWM3A/B waveforms
|
||||
//! via an oscilloscope
|
||||
//
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define EPWM1_MAX_DB 0x03FF
|
||||
#define EPWM2_MAX_DB 0x03FF
|
||||
#define EPWM3_MAX_DB 0x03FF
|
||||
#define EPWM1_MIN_DB 0
|
||||
#define EPWM2_MIN_DB 0
|
||||
#define EPWM3_MIN_DB 0
|
||||
#define DB_UP 1
|
||||
#define DB_DOWN 0
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint32 EPwm1TimerIntCount;
|
||||
Uint32 EPwm2TimerIntCount;
|
||||
Uint32 EPwm3TimerIntCount;
|
||||
Uint16 EPwm1_DB_Direction;
|
||||
Uint16 EPwm2_DB_Direction;
|
||||
Uint16 EPwm3_DB_Direction;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void InitEPwm1Example(void);
|
||||
void InitEPwm2Example(void);
|
||||
void InitEPwm3Example(void);
|
||||
__interrupt void epwm1_isr(void);
|
||||
__interrupt void epwm2_isr(void);
|
||||
__interrupt void epwm3_isr(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to its default state.
|
||||
//
|
||||
// InitGpio();
|
||||
|
||||
//
|
||||
// enable PWM1, PWM2 and PWM3
|
||||
//
|
||||
CpuSysRegs.PCLKCR2.bit.EPWM1=1;
|
||||
CpuSysRegs.PCLKCR2.bit.EPWM2=1;
|
||||
CpuSysRegs.PCLKCR2.bit.EPWM3=1;
|
||||
|
||||
//
|
||||
// For this case just init GPIO pins for ePWM1, ePWM2, ePWM3
|
||||
// These functions are in the f2838x_epwm.c file
|
||||
//
|
||||
InitEPwm1Gpio();
|
||||
InitEPwm2Gpio();
|
||||
InitEPwm3Gpio();
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
//
|
||||
EALLOW; // This is needed to write to EALLOW protected registers
|
||||
PieVectTable.EPWM1_INT = &epwm1_isr;
|
||||
PieVectTable.EPWM2_INT = &epwm2_isr;
|
||||
PieVectTable.EPWM3_INT = &epwm3_isr;
|
||||
EDIS; // This is needed to disable write to EALLOW protected registers
|
||||
|
||||
//
|
||||
// Step 4. Initialize the Device Peripherals:
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =0;
|
||||
EDIS;
|
||||
|
||||
InitEPwm1Example();
|
||||
InitEPwm2Example();
|
||||
InitEPwm3Example();
|
||||
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC =1;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Step 5. User specific code, enable interrupts:
|
||||
// Initialize counters:
|
||||
//
|
||||
EPwm1TimerIntCount = 0;
|
||||
EPwm2TimerIntCount = 0;
|
||||
EPwm3TimerIntCount = 0;
|
||||
|
||||
//
|
||||
// Enable CPU INT3 which is connected to EPWM1-3 INT:
|
||||
//
|
||||
IER |= M_INT3;
|
||||
|
||||
//
|
||||
// Enable EPWM INTn in the PIE: Group 3 interrupt 1-3
|
||||
//
|
||||
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;
|
||||
PieCtrlRegs.PIEIER3.bit.INTx2 = 1;
|
||||
PieCtrlRegs.PIEIER3.bit.INTx3 = 1;
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Step 6. IDLE loop. Just sit and loop forever (optional):
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
asm (" NOP");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// epwm1_isr - EPWM1 ISR
|
||||
//
|
||||
__interrupt void epwm1_isr(void)
|
||||
{
|
||||
if(EPwm1_DB_Direction == DB_UP)
|
||||
{
|
||||
if(EPwm1Regs.DBFED.bit.DBFED < EPWM1_MAX_DB)
|
||||
{
|
||||
EPwm1Regs.DBFED.bit.DBFED++;
|
||||
EPwm1Regs.DBRED.bit.DBRED++;
|
||||
}
|
||||
else
|
||||
{
|
||||
EPwm1_DB_Direction = DB_DOWN;
|
||||
EPwm1Regs.DBFED.bit.DBFED--;
|
||||
EPwm1Regs.DBRED.bit.DBRED--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(EPwm1Regs.DBFED.bit.DBFED == EPWM1_MIN_DB)
|
||||
{
|
||||
EPwm1_DB_Direction = DB_UP;
|
||||
EPwm1Regs.DBFED.bit.DBFED++;
|
||||
EPwm1Regs.DBRED.bit.DBRED++;
|
||||
}
|
||||
else
|
||||
{
|
||||
EPwm1Regs.DBFED.bit.DBFED--;
|
||||
EPwm1Regs.DBRED.bit.DBRED--;
|
||||
}
|
||||
}
|
||||
EPwm1TimerIntCount++;
|
||||
|
||||
//
|
||||
// Clear INT flag for this timer
|
||||
//
|
||||
EPwm1Regs.ETCLR.bit.INT = 1;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 3
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
|
||||
}
|
||||
|
||||
//
|
||||
// epwm2_isr - EPWM2 ISR
|
||||
//
|
||||
__interrupt void epwm2_isr(void)
|
||||
{
|
||||
if(EPwm2_DB_Direction == DB_UP)
|
||||
{
|
||||
if(EPwm2Regs.DBFED.bit.DBFED < EPWM2_MAX_DB)
|
||||
{
|
||||
EPwm2Regs.DBFED.bit.DBFED++;
|
||||
EPwm2Regs.DBRED.bit.DBRED++;
|
||||
}
|
||||
else
|
||||
{
|
||||
EPwm2_DB_Direction = DB_DOWN;
|
||||
EPwm2Regs.DBFED.bit.DBFED--;
|
||||
EPwm2Regs.DBRED.bit.DBRED--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(EPwm2Regs.DBFED.bit.DBFED == EPWM2_MIN_DB)
|
||||
{
|
||||
EPwm2_DB_Direction = DB_UP;
|
||||
EPwm2Regs.DBFED.bit.DBFED++;
|
||||
EPwm2Regs.DBRED.bit.DBRED++;
|
||||
}
|
||||
else
|
||||
{
|
||||
EPwm2Regs.DBFED.bit.DBFED--;
|
||||
EPwm2Regs.DBRED.bit.DBRED--;
|
||||
}
|
||||
}
|
||||
|
||||
EPwm2TimerIntCount++;
|
||||
|
||||
//
|
||||
// Clear INT flag for this timer
|
||||
//
|
||||
EPwm2Regs.ETCLR.bit.INT = 1;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 3
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
|
||||
}
|
||||
|
||||
//
|
||||
// epwm3_isr - EPWM3 ISR
|
||||
//
|
||||
__interrupt void epwm3_isr(void)
|
||||
{
|
||||
if(EPwm3_DB_Direction == DB_UP)
|
||||
{
|
||||
if(EPwm3Regs.DBFED.bit.DBFED < EPWM3_MAX_DB)
|
||||
{
|
||||
EPwm3Regs.DBFED.bit.DBFED++;
|
||||
EPwm3Regs.DBRED.bit.DBRED++;
|
||||
}
|
||||
else
|
||||
{
|
||||
EPwm3_DB_Direction = DB_DOWN;
|
||||
EPwm3Regs.DBFED.bit.DBFED--;
|
||||
EPwm3Regs.DBRED.bit.DBRED--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(EPwm3Regs.DBFED.bit.DBFED == EPWM3_MIN_DB)
|
||||
{
|
||||
EPwm3_DB_Direction = DB_UP;
|
||||
EPwm3Regs.DBFED.bit.DBFED++;
|
||||
EPwm3Regs.DBRED.bit.DBRED++;
|
||||
}
|
||||
else
|
||||
{
|
||||
EPwm3Regs.DBFED.bit.DBFED--;
|
||||
EPwm3Regs.DBRED.bit.DBRED--;
|
||||
}
|
||||
}
|
||||
|
||||
EPwm3TimerIntCount++;
|
||||
|
||||
//
|
||||
// Clear INT flag for this timer
|
||||
//
|
||||
EPwm3Regs.ETCLR.bit.INT = 1;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 3
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm1Example - Initialize EPWM1 configuration
|
||||
//
|
||||
void InitEPwm1Example()
|
||||
{
|
||||
EPwm1Regs.TBPRD = 6000; // Set timer period
|
||||
EPwm1Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
EPwm1Regs.TBCTR = 0x0000; // Clear counter
|
||||
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
|
||||
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
|
||||
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV4; // Clock ratio to SYSCLKOUT
|
||||
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV4;
|
||||
|
||||
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every ZERO
|
||||
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
|
||||
//
|
||||
// Setup compare
|
||||
//
|
||||
EPwm1Regs.CMPA.bit.CMPA = 3000;
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM1A on Zero
|
||||
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;
|
||||
|
||||
EPwm1Regs.AQCTLB.bit.CAU = AQ_CLEAR; // Set PWM1A on Zero
|
||||
EPwm1Regs.AQCTLB.bit.CAD = AQ_SET;
|
||||
|
||||
//
|
||||
// Active Low PWMs - Setup Deadband
|
||||
//
|
||||
EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
|
||||
EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_LO;
|
||||
EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL;
|
||||
EPwm1Regs.DBRED.bit.DBRED = EPWM1_MIN_DB;
|
||||
EPwm1Regs.DBFED.bit.DBFED = EPWM1_MIN_DB;
|
||||
EPwm1_DB_Direction = DB_UP;
|
||||
|
||||
//
|
||||
// Interrupt where we will change the Deadband
|
||||
//
|
||||
EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
|
||||
EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable INT
|
||||
EPwm1Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm2Example - Initialize EPWM2 configuration
|
||||
//
|
||||
void InitEPwm2Example()
|
||||
{
|
||||
EPwm2Regs.TBPRD = 6000; // Set timer period
|
||||
EPwm2Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
EPwm2Regs.TBCTR = 0x0000; // Clear counter
|
||||
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
|
||||
EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
|
||||
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV4; // Clock ratio to SYSCLKOUT
|
||||
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV4; // Slow just to observe on
|
||||
// the scope
|
||||
|
||||
//
|
||||
// Setup compare
|
||||
//
|
||||
EPwm2Regs.CMPA.bit.CMPA = 3000;
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
EPwm2Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM2A on Zero
|
||||
EPwm2Regs.AQCTLA.bit.CAD = AQ_CLEAR;
|
||||
|
||||
EPwm2Regs.AQCTLB.bit.CAU = AQ_CLEAR; // Set PWM2A on Zero
|
||||
EPwm2Regs.AQCTLB.bit.CAD = AQ_SET;
|
||||
|
||||
//
|
||||
// Active Low complementary PWMs - setup the deadband
|
||||
//
|
||||
EPwm2Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
|
||||
EPwm2Regs.DBCTL.bit.POLSEL = DB_ACTV_LOC;
|
||||
EPwm2Regs.DBCTL.bit.IN_MODE = DBA_ALL;
|
||||
EPwm2Regs.DBRED.bit.DBRED = EPWM2_MIN_DB;
|
||||
EPwm2Regs.DBFED.bit.DBFED = EPWM2_MIN_DB;
|
||||
EPwm2_DB_Direction = DB_UP;
|
||||
|
||||
//
|
||||
// Interrupt where we will modify the deadband
|
||||
//
|
||||
EPwm2Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
|
||||
EPwm2Regs.ETSEL.bit.INTEN = 1; // Enable INT
|
||||
EPwm2Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm3Example - Initialize EPWM3 configuration
|
||||
//
|
||||
void InitEPwm3Example()
|
||||
{
|
||||
EPwm3Regs.TBPRD = 6000; // Set timer period
|
||||
EPwm3Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
EPwm3Regs.TBCTR = 0x0000; // Clear counter
|
||||
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
|
||||
EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
|
||||
EPwm3Regs.TBCTL.bit.HSPCLKDIV = TB_DIV4; // Clock ratio to SYSCLKOUT
|
||||
EPwm3Regs.TBCTL.bit.CLKDIV = TB_DIV4; // Slow so we can observe on
|
||||
// the scope
|
||||
|
||||
//
|
||||
// Setup compare
|
||||
//
|
||||
EPwm3Regs.CMPA.bit.CMPA = 3000;
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
EPwm3Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM3A on Zero
|
||||
EPwm3Regs.AQCTLA.bit.CAD = AQ_CLEAR;
|
||||
|
||||
EPwm3Regs.AQCTLB.bit.CAU = AQ_CLEAR; // Set PWM3A on Zero
|
||||
EPwm3Regs.AQCTLB.bit.CAD = AQ_SET;
|
||||
|
||||
//
|
||||
// Active high complementary PWMs - Setup the deadband
|
||||
//
|
||||
EPwm3Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
|
||||
EPwm3Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;
|
||||
EPwm3Regs.DBCTL.bit.IN_MODE = DBA_ALL;
|
||||
EPwm3Regs.DBRED.bit.DBRED = EPWM3_MIN_DB;
|
||||
EPwm3Regs.DBFED.bit.DBFED = EPWM3_MIN_DB;
|
||||
EPwm3_DB_Direction = DB_UP;
|
||||
|
||||
//
|
||||
// Interrupt where we will change the deadband
|
||||
//
|
||||
EPwm3Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
|
||||
EPwm3Regs.ETSEL.bit.INTEN = 1; // Enable INT
|
||||
EPwm3Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,29 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="gpio_ex1_setup"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../gpio_ex1_setup.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,515 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: gpio_ex1_setup.c
|
||||
//
|
||||
// TITLE: Device GPIO Setup
|
||||
//! <h1> Device GPIO Setup </h1>
|
||||
//! \addtogroup bitfield_example_list
|
||||
//!
|
||||
//! Configures the F2838X GPIO into two different configurations
|
||||
//! This code is verbose to illustrate how the GPIO could be setup.
|
||||
//! In a real application, lines of code can be combined for improved
|
||||
//! code size and efficiency.
|
||||
//! This example only sets-up the GPIO.
|
||||
//! Nothing is actually done with the pins after setup.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
// Select the example to compile in. Only one example should be set as 1
|
||||
// the rest should be set as 0.
|
||||
//
|
||||
#define EXAMPLE1 1 // Basic pinout configuration example
|
||||
#define EXAMPLE2 0 // Communication pinout example
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void setup1GPIO(void);
|
||||
void setup2GPIO(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
//Step 1. Initialize System Control:
|
||||
//PLL, WatchDog,enabe Peripheral Clocks
|
||||
//This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
//Step 2. Initialize GPIO
|
||||
//
|
||||
InitGpio();
|
||||
|
||||
//
|
||||
//Step 3. Clear all __interrupts and initialize PIE vector table:
|
||||
//Disable CPU __interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
//Initialize the PIE control registers to their default state.
|
||||
//The default state is all PIE interrupts disabled and flags
|
||||
//are cleared.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
//Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
//Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
//Service Routines (ISR).
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
//Step 4. User specific code:
|
||||
//
|
||||
#if EXAMPLE1
|
||||
|
||||
//
|
||||
//This example is a basic pinout
|
||||
//
|
||||
setup1GPIO();
|
||||
|
||||
#endif
|
||||
|
||||
#if EXAMPLE2
|
||||
|
||||
//
|
||||
// This example is a communications pinout
|
||||
//
|
||||
setup2GPIO();
|
||||
|
||||
#endif
|
||||
|
||||
while(1)
|
||||
{
|
||||
ESTOP0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// setup1GPIO - Is an example that demonstrates the basic pinout
|
||||
//
|
||||
void setup1GPIO(void)
|
||||
{
|
||||
//
|
||||
// Example 1: Basic Pinout.
|
||||
// This basic pinout includes:
|
||||
// PWM1-3, ECAP1, ECAP2, TZ1-TZ4, SPI-A, EQEP1, SCI-A, CAN-A, I2C
|
||||
// and a number of I/O pins
|
||||
// These can be combined into single statements for improved
|
||||
// code efficiency.
|
||||
//
|
||||
|
||||
//
|
||||
// Enable PWM1-3 on GPIO0-GPIO5
|
||||
//
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; // Enable pullup on GPIO0
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0; // Enable pullup on GPIO1
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO2 = 0; // Enable pullup on GPIO2
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO3 = 0; // Enable pullup on GPIO3
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO4 = 0; // Enable pullup on GPIO4
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO5 = 0; // Enable pullup on GPIO5
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // GPIO0 = PWM1A
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // GPIO1 = PWM1B
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1; // GPIO2 = PWM2A
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 1; // GPIO3 = PWM2B
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 1; // GPIO4 = PWM3A
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 1; // GPIO5 = PWM3B
|
||||
|
||||
//
|
||||
// Enable an GPIO output on GPIO6, set it high
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; // Enable pullup on GPIO6
|
||||
GpioDataRegs.GPASET.bit.GPIO6 = 1; // Load output latch
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0; // GPIO6 = GPIO6
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO6 = 1; // GPIO6 = output
|
||||
|
||||
//
|
||||
// Enable eCAP1 on GPIO7
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO7 = 0; // Enable pullup on GPIO7
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO7 = 0; // Synch to SYSCLKOUT
|
||||
InputXbarRegs.INPUT7SELECT = 7; // INPUT7 = GPIO7
|
||||
ECap1Regs.ECCTL0.bit.INPUTSEL = 7; // Select eCAP1 TO INPUT7
|
||||
|
||||
//
|
||||
// Enable GPIO outputs on GPIO8 - GPIO11, set it high
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO8 = 0; // Enable pullup on GPIO8
|
||||
GpioDataRegs.GPASET.bit.GPIO8 = 1; // Load output latch
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 0; // GPIO8 = GPIO8
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO8 = 1; // GPIO8 = output
|
||||
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO9 = 0; // Enable pullup on GPIO9
|
||||
GpioDataRegs.GPASET.bit.GPIO9 = 1; // Load output latch
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 0; // GPIO9 = GPIO9
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO9 = 1; // GPIO9 = output
|
||||
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO10 = 0; // Enable pullup on GPIO10
|
||||
GpioDataRegs.GPASET.bit.GPIO10 = 1; // Load output latch
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 0; // GPIO10 = GPIO10
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO10 = 1; // GPIO10 = output
|
||||
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO11 = 0; // Enable pullup on GPIO11
|
||||
GpioDataRegs.GPASET.bit.GPIO11 = 1; // Load output latch
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 0; // GPIO11 = GPIO11
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO11 = 1; // GPIO11 = output
|
||||
|
||||
//
|
||||
// Enable Trip Zone inputs on GPIO12 - GPIO14
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0; // Enable pullup on GPIO12
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO13 = 0; // Enable pullup on GPIO13
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO14 = 0; // Enable pullup on GPIO14
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO12 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO13 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO14 = 3; // asynch input
|
||||
InputXbarRegs.INPUT1SELECT = 12; // GPIO12 = TZ1
|
||||
InputXbarRegs.INPUT2SELECT = 13; // GPIO13 = TZ2
|
||||
InputXbarRegs.INPUT3SELECT = 14; // GPIO14 = TZ3
|
||||
|
||||
//
|
||||
// Enable SPI-A on GPIO16 - GPIO19
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO16 = 0; // Enable pullup on GPIO16
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO17 = 0; // Enable pullup on GPIO17
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO18 = 0; // Enable pullup on GPIO18
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO19 = 0; // Enable pullup on GPIO19
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO16 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO17 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO18 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO19 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 1; // GPIO16 = SPISIMOA
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 1; // GPIO17 = SPIS0MIA
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 1; // GPIO18 = SPICLKA
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 1; // GPIO19 = SPISTEA
|
||||
|
||||
//
|
||||
// Enable EQEP1 on GPIO's 20,21,22,23
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO20 = 0; // Enable pullup on GPIO20
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO21 = 0; // Enable pullup on GPIO21
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO22 = 0; // Enable pullup on GPIO22
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO23 = 0; // Enable pullup on GPIO23
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO20 = 0; // Synch to SYSCLKOUT
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO21 = 0; // Synch to SYSCLKOUT
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO22 = 0; // Synch to SYSCLKOUT
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO23 = 0; // Synch to SYSCLKOUT
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 1; // GPIO20 = EQEP1A
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 1; // GPIO21 = EQEP1B
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 1; // GPIO22 = EQEP1S
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 2; // GPIO23 = EQEP1I
|
||||
|
||||
//
|
||||
// Enable eCAP1 on GPIO24
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0; // Enable pullup on GPIO24
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0; // Synch to SYSCLKOUT
|
||||
InputXbarRegs.INPUT8SELECT = 24; // INPUT8 = GPIO24
|
||||
ECap1Regs.ECCTL0.bit.INPUTSEL=8; // Select eCAP1 TO INPUT8
|
||||
|
||||
//
|
||||
// Set input qualification period for GPIO25 & GPIO26
|
||||
//
|
||||
GpioCtrlRegs.GPACTRL.bit.QUALPRD3=1; // Qual period = SYSCLKOUT/2
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO25=2; // 6 samples
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO26=2; // 6 samples
|
||||
|
||||
//
|
||||
// Make GPIO25 the input source for XINT1
|
||||
//
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO25 = 0; // GPIO25 = GPIO25
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO25 = 0; // GPIO25 = input
|
||||
GPIO_SetupXINT1Gpio(25); // XINT1 connected to GPIO25
|
||||
|
||||
//
|
||||
// Make GPIO26 the input source for XINT2
|
||||
//
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 0; // GPIO26 = GPIO26
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO26 = 0; // GPIO26 = input
|
||||
GPIO_SetupXINT2Gpio(26); // XINT2 connected to GPIO26
|
||||
|
||||
//
|
||||
// Make GPIO27 wakeup from STANDBY Low Power Modes
|
||||
//
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO27 = 0; // GPIO27 = GPIO27
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO27 = 0; // GPIO27 = input
|
||||
CpuSysRegs.GPIOLPMSEL0.bit.GPIO27=1; // GPIO27 will wake the device
|
||||
CpuSysRegs.LPMCR.bit.QUALSTDBY = 2; // Qualify GPIO27 by 2 OSCCLK
|
||||
// cycles before waking the device
|
||||
// from STANDBY
|
||||
|
||||
//
|
||||
// Enable SCI-A on GPIO28 - GPIO29
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; // Enable pullup on GPIO28
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3; // Asynch input
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1; // GPIO28 = SCIRXDA
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0; // Enable pullup on GPIO29
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; // GPIO29 = SCITXDA
|
||||
|
||||
//
|
||||
// Enable CAN-A on GPIO30 - GPIO31
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO30 = 0; // Enable pullup on GPIO30
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 1; // GPIO30 = CANRXA
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO31 = 0; // Enable pullup on GPIO31
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO31 = 3; // Asynch input
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 1; // GPIO31 = CANTXA
|
||||
|
||||
//
|
||||
// Enable I2C-A on GPIO32 - GPIO33
|
||||
//
|
||||
GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0; // Enable pullup on GPIO32
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1; // GPIO32 = SDAA
|
||||
GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3; // Asynch input
|
||||
GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0; // Enable pullup on GPIO33
|
||||
GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3; // Asynch input
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1; // GPIO33 = SCLA
|
||||
|
||||
//
|
||||
// Make GPIO34 an input
|
||||
//
|
||||
GpioCtrlRegs.GPBPUD.bit.GPIO34 = 0; // Enable pullup on GPIO34
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // GPIO34 = GPIO34
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 0; // GPIO34 = input
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// setup2GPIO - Is an example that demonstrates the communications pinout
|
||||
//
|
||||
void setup2GPIO(void)
|
||||
{
|
||||
//
|
||||
// Example 2:
|
||||
// Communications Pinout.
|
||||
// This basic communications pinout includes:
|
||||
// PWM1-3, CAP2, SPI-B, CAN-A, SCI-A and I2C
|
||||
// and a number of I/O pins
|
||||
//
|
||||
|
||||
//
|
||||
// Enable PWM1-3 on GPIO0-GPIO5
|
||||
//
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; // Enable pullup on GPIO0
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0; // Enable pullup on GPIO1
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO2 = 0; // Enable pullup on GPIO2
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO3 = 0; // Enable pullup on GPIO3
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO4 = 0; // Enable pullup on GPIO4
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO5 = 0; // Enable pullup on GPIO5
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // GPIO0 = PWM1A
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // GPIO1 = PWM1B
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1; // GPIO2 = PWM2A
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 1; // GPIO3 = PWM2B
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 1; // GPIO4 = PWM3A
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 1; // GPIO5 = PWM3B
|
||||
|
||||
//
|
||||
// Enable an GPIO output on GPIO6
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; // Enable pullup on GPIO6
|
||||
GpioDataRegs.GPASET.bit.GPIO6 = 1; // Load output latch
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0; // GPIO6 = GPIO6
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO6 = 1; // GPIO6 = output
|
||||
|
||||
//
|
||||
// Enable eCAP1 on GPIO7
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO7 = 0; // Enable pullup on GPIO7
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO7 = 0; // Synch to SYSCLKOUT
|
||||
InputXbarRegs.INPUT7SELECT = 7; // INPUT7 = GPIO7
|
||||
ECap1Regs.ECCTL0.bit.INPUTSEL=7; // Select eCAP1 TO INPUT7
|
||||
|
||||
//
|
||||
// Enable GPIO outputs on GPIO8 - GPIO11, set it high
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO8 = 0; // Enable pullup on GPIO8
|
||||
GpioDataRegs.GPASET.bit.GPIO8 = 1; // Load output latch
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 0; // GPIO8 = GPIO8
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO8 = 1; // GPIO8 = output
|
||||
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO9 = 0; // Enable pullup on GPIO9
|
||||
GpioDataRegs.GPASET.bit.GPIO9 = 1; // Load output latch
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 0; // GPIO9 = GPIO9
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO9 = 1; // GPIO9 = output
|
||||
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO10 = 0; // Enable pullup on GPIO10
|
||||
GpioDataRegs.GPASET.bit.GPIO10 = 1; // Load output latch
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 0; // GPIO10 = GPIO10
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO10 = 1; // GPIO10 = output
|
||||
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO11 = 0; // Enable pullup on GPIO11
|
||||
GpioDataRegs.GPASET.bit.GPIO11 = 1; // Load output latch
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 0; // GPIO11 = GPIO11
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO11 = 1; // GPIO11 = output
|
||||
|
||||
//
|
||||
// Enable SPI-B on GPIO22 - GPIO25
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO22 = 0; // Enable pull-up on GPIO22 (SPICLKB)
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO23 = 0; // Enable pull-up on GPIO23 (SPISTEB)
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0; // Enable pull-up on GPIO24 (SPISIMOB)
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO25 = 0; // Enable pull-up on GPIO25 (SPISOMIB)
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO22 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO23 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO25 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 1; // GPIO22 = SPICLKB
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 1; // GPIO23 = SPISTEB
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1; // GPIO24 = SPISIMOB
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO25 = 1; // GPIO25 = SPISOMIB
|
||||
|
||||
//
|
||||
// Enable SPI-A on GPIO16 - GPIO19
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO16 = 0; // Enable pull-up on GPIO16 (SPISIMOA)
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO17 = 0; // Enable pull-up on GPIO17 (SPISOMIA)
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO18 = 0; // Enable pull-up on GPIO18 (SPICLKA)
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO19 = 0; // Enable pull-up on GPIO19 (SPISTEA)
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO16 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO17 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO18 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO19 = 3; // asynch input
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 1; // GPIO16 = SPISIMOA
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 1; // GPIO17 = SPISOMIA
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 1; // GPIO18 = SPICLKA
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 1; // GPIO19 = SPISTEA
|
||||
|
||||
//
|
||||
// Enable eCAP2 on GPIO24
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0; // Enable pullup on GPIO24
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0; // Synch to SYSCLKOUT
|
||||
InputXbarRegs.INPUT8SELECT = 24; // INPUT8 = GPIO24
|
||||
ECap2Regs.ECCTL0.bit.INPUTSEL=8; // Select eCAP2 TO INPUT8
|
||||
|
||||
//
|
||||
// Set input qualifcation period for GPIO25 & GPIO26
|
||||
//
|
||||
GpioCtrlRegs.GPACTRL.bit.QUALPRD3=1; // Qual period = SYSCLKOUT/2
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO25=2; // 6 samples
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO26=2; // 6 samples
|
||||
|
||||
//
|
||||
// Make GPIO25 the input source for XINT1
|
||||
//
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO25 = 0; // GPIO25 = GPIO25
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO25 = 0; // GPIO25 = input
|
||||
GPIO_SetupXINT1Gpio(25); // XINT1 connected to GPIO25
|
||||
|
||||
//
|
||||
// Make GPIO26 the input source for XINT2
|
||||
//
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 0; // GPIO26 = GPIO26
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO26 = 0; // GPIO26 = input
|
||||
GPIO_SetupXINT2Gpio(26); // XINT2 connected to GPIO26
|
||||
|
||||
//
|
||||
// Make GPIO27 wakeup from HALT/STANDBY Low Power Modes
|
||||
//
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO27 = 0; // GPIO27 = GPIO27
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO27 = 0; // GPIO27 = input
|
||||
CpuSysRegs.GPIOLPMSEL0.bit.GPIO27=1; // GPIO27 will wake the device
|
||||
CpuSysRegs.LPMCR.bit.QUALSTDBY = 2; // Qualify GPIO27 by 2 OSCCLK
|
||||
// cycles before waking the device
|
||||
// from STANDBY
|
||||
|
||||
//
|
||||
// Enable SCI-A on GPIO28 - GPIO29
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; // Enable pullup on GPIO28
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3; // Asynch input
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1; // GPIO28 = SCIRXDA
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0; // Enable pullup on GPIO29
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; // GPIO29 = SCITXDA
|
||||
|
||||
//
|
||||
// Enable CAN-A on GPIO30 - GPIO31
|
||||
//
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO30 = 0; // Enable pullup on GPIO30
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 1; // GPIO30 = CANTXA
|
||||
GpioCtrlRegs.GPAPUD.bit.GPIO31 = 0; // Enable pullup on GPIO31
|
||||
GpioCtrlRegs.GPAQSEL2.bit.GPIO31 = 3; // Asynch input
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 1; // GPIO31 = CANRXA
|
||||
|
||||
//
|
||||
// Enable I2C-A on GPIO32 - GPIO33
|
||||
//
|
||||
GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0; // Enable pullup on GPIO32
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1; // GPIO32 = SDAA
|
||||
GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3; // Asynch input
|
||||
GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0; // Enable pullup on GPIO33
|
||||
GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3; // Asynch input
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1; // GPIO33 = SCLA
|
||||
|
||||
//
|
||||
// Make GPIO34 an input
|
||||
//
|
||||
GpioCtrlRegs.GPBPUD.bit.GPIO34 = 0; // Enable pullup on GPIO34
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // GPIO34 = GPIO34
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 0; // GPIO34 = input
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,14 @@
|
||||
//AddWatchWindowVars_Lab4.js
|
||||
expRemoveAll
|
||||
expAdd ("InputPeriodInc");
|
||||
expAdd ("EPwm1Regs.DBRED");
|
||||
expAdd ("EPwm1Regs.DBREDHR.bit.DBREDHR");
|
||||
expAdd ("EPwm1Regs.DBFED");
|
||||
expAdd ("EPwm1Regs.DBFEDHR.bit.DBFEDHR");
|
||||
expAdd ("EPwm2Regs.DBRED");
|
||||
expAdd ("EPwm2Regs.DBREDHR.bit.DBREDHR");
|
||||
expAdd ("EPwm2Regs.DBFED");
|
||||
expAdd ("EPwm2Regs.DBFEDHR.bit.DBFEDHR");
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="hrpwm_ex1_slider"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063 --gen_func_subsections=on" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../hrpwm_ex1_slider.c" targetDirectory="" />
|
||||
<file action="copy" path="../f2838x_hrpwm_ex1_slider.gel" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="hrpwm_ex2_duty_sfo_v8"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -I${C2000WARE_SFO_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063 --gen_func_subsections=on" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -I${C2000WARE_SFO_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2838x/include" scope="project" />
|
||||
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2838x/lib/SFO_v8_fpu_lib_build_c28.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../hrpwm_ex2_duty_sfo_v8.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="hrpwm_ex3_prdupdown_sfo_v8"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -I${C2000WARE_SFO_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063 --gen_func_subsections=on" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -I${C2000WARE_SFO_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2838x/include" scope="project" />
|
||||
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2838x/lib/SFO_v8_fpu_lib_build_c28.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../hrpwm_ex3_prdupdown_sfo_v8.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="hrpwm_ex4_deadband_sfo_v8"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -I${C2000WARE_SFO_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063 --gen_func_subsections=on" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -I${C2000WARE_SFO_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_SFO_INCLUDE" path="../../../../../../libraries/calibration/hrpwm/f2838x/include" scope="project" />
|
||||
<file action="link" path="../../../../../../libraries/calibration/hrpwm/f2838x/lib/SFO_v8_fpu_lib_build_c28.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../hrpwm_ex4_deadband_sfo_v8.c" targetDirectory="" />
|
||||
<file action="copy" path="../AddWatchWindowVars_HRPWM.js" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,50 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// This .gel file can be used to help demonstrate the example project.
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
|
||||
menuitem "HRPWM FineDutySlider"
|
||||
slider FineDutySlider(1, 255, 1, 1, finedutyvalue)
|
||||
{
|
||||
|
||||
DutyFine = finedutyvalue;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,597 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: hrpwm_ex1_slider.c
|
||||
//
|
||||
// TITLE: f2838x Device HRPWM MEP Slider example
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> HRPWM Slider Test (hrpwm_slider)</h1>
|
||||
//!
|
||||
//! This example modifies the MEP control registers to show edge displacement
|
||||
//! due to HRPWM control blocks of the respective EPwm module channel A and B
|
||||
//! will have fine edge movement due to HRPWM logic. Load the
|
||||
//! f2838x_hrpwm_slider.gel file. Select HRPWM FineDutySlider from the GEL menu.
|
||||
//! A FineDuty slider graphics will show up in CCS. Load the program and run.
|
||||
//! Use the Slider to and observe the EPwm edge displacement for each slider
|
||||
//! step change. This explains the MEP control on the EPwmxA channels.
|
||||
//!
|
||||
//! Monitor ePWM1-ePWM8 A/B pins on an oscilloscope.
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define PWM_CH 9 // # of PWM channels
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 DutyFine,update;
|
||||
volatile struct EPWM_REGS *ePWM[PWM_CH] =
|
||||
{&EPwm1Regs, &EPwm1Regs, &EPwm2Regs, &EPwm3Regs, &EPwm4Regs,
|
||||
&EPwm5Regs, &EPwm6Regs, &EPwm7Regs, &EPwm8Regs};
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void HRPWM1_Config(int);
|
||||
void HRPWM2_Config(int);
|
||||
void HRPWM3_Config(int);
|
||||
void HRPWM4_Config(int);
|
||||
void HRPWM5_Config(int);
|
||||
void HRPWM6_Config(int);
|
||||
void HRPWM7_Config(int);
|
||||
void HRPWM8_Config(int);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize System Control for Control and Analog Subsystems
|
||||
// Enable Peripheral Clocks
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Configure pins for EPWM modules 1-8.
|
||||
//
|
||||
InitEPwm1Gpio();
|
||||
InitEPwm2Gpio();
|
||||
InitEPwm3Gpio();
|
||||
InitEPwm4Gpio();
|
||||
InitEPwm5Gpio();
|
||||
InitEPwm6Gpio();
|
||||
InitEPwm7Gpio();
|
||||
InitEPwm8Gpio();
|
||||
|
||||
DINT; // Disable CPU interrupts
|
||||
|
||||
//
|
||||
// Initialize PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Enable interrupts required for this example
|
||||
//
|
||||
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
|
||||
IER = 0x400; // Enable CPU INT
|
||||
|
||||
//
|
||||
// User specific code, enable interrupts:
|
||||
//
|
||||
update = 1; // variable to enable run-time duty updates
|
||||
DutyFine = 0; // duty value to be updated from slider
|
||||
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// EPwm and HRPWM register initialization
|
||||
//
|
||||
HRPWM1_Config(30); // EPwm1 target, Period = 30
|
||||
HRPWM2_Config(20); // EPwm2 target, Period = 20
|
||||
HRPWM3_Config(20); // EPwm3 target, Period = 20
|
||||
HRPWM4_Config(20); // EPwm4 target, Period = 20
|
||||
HRPWM5_Config(20); // EPwm5 target, Period = 20
|
||||
HRPWM6_Config(20); // EPwm6 target, Period = 20
|
||||
HRPWM7_Config(20); // EPwm7 target, Period = 20
|
||||
HRPWM8_Config(20); // EPwm8 target, Period = 20
|
||||
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
EDIS;
|
||||
|
||||
while(update == 1)
|
||||
{
|
||||
//
|
||||
// Example, write to the HRPWM extension of CMPA / CMPB
|
||||
//
|
||||
EPwm1Regs.CMPA.bit.CMPAHR = DutyFine << 8;
|
||||
EPwm1Regs.CMPB.bit.CMPBHR = DutyFine << 8;
|
||||
|
||||
EPwm2Regs.CMPA.bit.CMPAHR = DutyFine << 8;
|
||||
EPwm2Regs.CMPB.bit.CMPBHR = DutyFine << 8;
|
||||
|
||||
//
|
||||
// Example, 32-bit write to CMPA:CMPAHR
|
||||
//
|
||||
EPwm3Regs.CMPA.all = ((Uint32)EPwm3Regs.CMPA.bit.CMPA << 16) +
|
||||
(DutyFine << 8);
|
||||
EPwm3Regs.CMPB.bit.CMPBHR = DutyFine << 8;
|
||||
|
||||
EPwm4Regs.CMPA.bit.CMPAHR = (DutyFine << 8);
|
||||
EPwm4Regs.CMPB.bit.CMPBHR = (DutyFine << 8);
|
||||
|
||||
//
|
||||
// Example, write to the HRPWM extension of CMPA / CMPB
|
||||
//
|
||||
EPwm5Regs.CMPA.bit.CMPAHR = DutyFine << 8;
|
||||
EPwm5Regs.CMPB.bit.CMPBHR = DutyFine << 8;
|
||||
|
||||
EPwm6Regs.CMPA.bit.CMPAHR = DutyFine << 8;
|
||||
EPwm6Regs.CMPB.bit.CMPBHR = DutyFine << 8;
|
||||
|
||||
//
|
||||
// Example, write to the HRPWM extension of CMPA / CMPB
|
||||
//
|
||||
EPwm7Regs.CMPA.bit.CMPAHR = DutyFine << 8;
|
||||
EPwm7Regs.CMPB.bit.CMPBHR = DutyFine << 8;
|
||||
|
||||
EPwm8Regs.CMPA.bit.CMPAHR = DutyFine << 8;
|
||||
EPwm8Regs.CMPB.bit.CMPBHR = DutyFine << 8;
|
||||
}
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// IDLE loop. Just sit and loop forever (optional)
|
||||
//
|
||||
for(;;);
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM1_Config - Configure HRPWM1 settings
|
||||
//
|
||||
void HRPWM1_Config(period)
|
||||
{
|
||||
//
|
||||
// ePWM1 register configuration with HRPWM
|
||||
// ePWM toggle high/low with MEP control on 1A AND 1B
|
||||
//
|
||||
EPwm1Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; // set Immediate load
|
||||
EPwm1Regs.TBPRD = period - 1; // PWM frequency = 1 / period
|
||||
EPwm1Regs.CMPB.bit.CMPB = period / 2; // set duty 50% initial
|
||||
EPwm1Regs.CMPB.all |= (1 << 8); // initialize HRPWM extension
|
||||
EPwm1Regs.CMPA.bit.CMPA = period / 2; // set duty 50% initially
|
||||
EPwm1Regs.CMPA.bit.CMPAHR = (1 << 8);
|
||||
EPwm1Regs.TBPHS.all = 0;
|
||||
EPwm1Regs.TBCTR = 0;
|
||||
|
||||
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
|
||||
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;
|
||||
EPwm1Regs.EPWMSYNCINSEL.all = SYNC_IN_SRC_DISABLE_ALL;
|
||||
EPwm1Regs.EPWMSYNCOUTEN.all = SYNC_OUT_SRC_DISABLE_ALL;
|
||||
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET;
|
||||
EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR;
|
||||
EPwm1Regs.AQCTLB.bit.ZRO = AQ_SET;
|
||||
EPwm1Regs.AQCTLB.bit.CBU = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
EPwm1Regs.HRCNFG.all = 0x0;
|
||||
EPwm1Regs.HRCNFG.bit.EDGMODE = HR_FEP;
|
||||
EPwm1Regs.HRCNFG.bit.CTLMODE = HR_CMP;
|
||||
EPwm1Regs.HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
|
||||
|
||||
EPwm1Regs.HRCNFG.bit.EDGMODEB = HR_FEP;
|
||||
EPwm1Regs.HRCNFG.bit.CTLMODEB = HR_CMP;
|
||||
EPwm1Regs.HRCNFG.bit.HRLOADB = HR_CTR_ZERO;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM2_Config - Configure HRPWM2 settings
|
||||
//
|
||||
void HRPWM2_Config(period)
|
||||
{
|
||||
//
|
||||
// ePWM2 register configuration with HRPWM
|
||||
// ePWM toggle high/low with MEP control on 2A AND 2B
|
||||
//
|
||||
EPwm2Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; // set Immediate load
|
||||
EPwm2Regs.TBPRD = period - 1; // PWM frequency = 1 / period
|
||||
EPwm2Regs.CMPB.bit.CMPB = period / 2; // set duty 50% initial
|
||||
EPwm2Regs.CMPB.all |= (1 << 8); // initialize HRPWM extension
|
||||
EPwm2Regs.CMPA.bit.CMPA = period / 2; // set duty 50% initially
|
||||
EPwm2Regs.CMPA.bit.CMPAHR = (1 << 8);
|
||||
EPwm2Regs.TBPHS.all = 0;
|
||||
EPwm2Regs.TBCTR = 0;
|
||||
|
||||
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
|
||||
EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE;
|
||||
EPwm2Regs.EPWMSYNCINSEL.all = SYNC_IN_SRC_DISABLE_ALL;
|
||||
EPwm2Regs.EPWMSYNCOUTEN.all = SYNC_OUT_SRC_DISABLE_ALL;
|
||||
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
EPwm2Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm2Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
EPwm2Regs.AQCTLA.bit.ZRO = AQ_SET;
|
||||
EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR;
|
||||
EPwm2Regs.AQCTLB.bit.ZRO = AQ_SET;
|
||||
EPwm2Regs.AQCTLB.bit.CBU = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
EPwm2Regs.HRCNFG.all = 0x0;
|
||||
EPwm2Regs.HRCNFG.bit.EDGMODE = HR_FEP;
|
||||
EPwm2Regs.HRCNFG.bit.CTLMODE = HR_CMP;
|
||||
EPwm2Regs.HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
|
||||
|
||||
EPwm2Regs.HRCNFG.bit.EDGMODEB = HR_FEP;
|
||||
EPwm2Regs.HRCNFG.bit.CTLMODEB = HR_CMP;
|
||||
EPwm2Regs.HRCNFG.bit.HRLOADB = HR_CTR_ZERO;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM3_Config - Configure HRPWM3 settings
|
||||
//
|
||||
void HRPWM3_Config(period)
|
||||
{
|
||||
//
|
||||
// ePWM3 register configuration with HRPWM
|
||||
// ePWM3A / 3B toggle high/low with MEP control on falling edge
|
||||
//
|
||||
EPwm3Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; // set Immediate load
|
||||
EPwm3Regs.TBPRD = period - 1; // PWM frequency = 1 / period
|
||||
EPwm3Regs.CMPB.bit.CMPB = period / 2; // set duty 50% initial
|
||||
EPwm3Regs.CMPB.all |= (1 << 8); // initialize HRPWM extension
|
||||
EPwm3Regs.CMPA.bit.CMPA = period / 2; // set duty 50% initially
|
||||
EPwm3Regs.CMPA.bit.CMPAHR = (1 << 8);
|
||||
EPwm3Regs.TBPHS.all = 0;
|
||||
EPwm3Regs.TBCTR = 0;
|
||||
|
||||
EPwm3Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
|
||||
EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE;
|
||||
EPwm3Regs.EPWMSYNCINSEL.all = SYNC_IN_SRC_DISABLE_ALL;
|
||||
EPwm3Regs.EPWMSYNCOUTEN.all = SYNC_OUT_SRC_DISABLE_ALL;
|
||||
EPwm3Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
EPwm3Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
EPwm3Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm3Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
EPwm3Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm3Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
EPwm3Regs.AQCTLA.bit.ZRO = AQ_SET;
|
||||
EPwm3Regs.AQCTLA.bit.CAU = AQ_CLEAR;
|
||||
EPwm3Regs.AQCTLB.bit.ZRO = AQ_SET;
|
||||
EPwm3Regs.AQCTLB.bit.CBU = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
EPwm3Regs.HRCNFG.all = 0x0;
|
||||
EPwm3Regs.HRCNFG.bit.EDGMODE = HR_FEP;
|
||||
EPwm3Regs.HRCNFG.bit.CTLMODE = HR_CMP;
|
||||
EPwm3Regs.HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
|
||||
|
||||
EPwm3Regs.HRCNFG.bit.EDGMODEB = HR_FEP;
|
||||
EPwm3Regs.HRCNFG.bit.CTLMODEB = HR_CMP;
|
||||
EPwm3Regs.HRCNFG.bit.HRLOADB = HR_CTR_ZERO;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM4_Config - Configure HRPWM4 settings
|
||||
//
|
||||
void HRPWM4_Config(period)
|
||||
{
|
||||
//
|
||||
// ePWM4 register configuration with HRPWM
|
||||
// ePWM4A / 4B toggle high/low with MEP control on falling edge
|
||||
//
|
||||
EPwm4Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; // set Immediate load
|
||||
EPwm4Regs.TBPRD = period - 1; // PWM frequency = 1 / period
|
||||
EPwm4Regs.CMPB.bit.CMPB = period / 2; // set duty 50% initial
|
||||
EPwm4Regs.CMPB.all |= (1 << 8); // initialize HRPWM extension
|
||||
EPwm4Regs.CMPA.bit.CMPA = period / 2; // set duty 50% initially
|
||||
EPwm4Regs.CMPA.bit.CMPAHR = (1 << 8);
|
||||
EPwm4Regs.TBPHS.all = 0;
|
||||
EPwm4Regs.TBCTR = 0;
|
||||
|
||||
EPwm4Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
|
||||
EPwm4Regs.TBCTL.bit.PHSEN = TB_DISABLE;
|
||||
EPwm4Regs.EPWMSYNCINSEL.all = SYNC_IN_SRC_DISABLE_ALL;
|
||||
EPwm4Regs.EPWMSYNCOUTEN.all = SYNC_OUT_SRC_DISABLE_ALL;
|
||||
EPwm4Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
EPwm4Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
EPwm4Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm4Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
EPwm4Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm4Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
EPwm4Regs.AQCTLA.bit.ZRO = AQ_SET;
|
||||
EPwm4Regs.AQCTLA.bit.CAU = AQ_CLEAR;
|
||||
EPwm4Regs.AQCTLB.bit.ZRO = AQ_SET;
|
||||
EPwm4Regs.AQCTLB.bit.CBU = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
EPwm4Regs.HRCNFG.all = 0x0;
|
||||
EPwm4Regs.HRCNFG.bit.EDGMODE = HR_FEP;
|
||||
EPwm4Regs.HRCNFG.bit.CTLMODE = HR_CMP;
|
||||
EPwm4Regs.HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
|
||||
|
||||
EPwm4Regs.HRCNFG.bit.EDGMODEB = HR_FEP;
|
||||
EPwm4Regs.HRCNFG.bit.CTLMODEB = HR_CMP;
|
||||
EPwm4Regs.HRCNFG.bit.HRLOADB = HR_CTR_ZERO;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM5_Config - Configure HRPWM5 settings
|
||||
//
|
||||
void HRPWM5_Config(period)
|
||||
{
|
||||
//
|
||||
// ePWM5 register configuration with HRPWM
|
||||
// ePWM5A / 5B toggle high/low with MEP control on falling edge
|
||||
//
|
||||
EPwm5Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; // set Immediate load
|
||||
EPwm5Regs.TBPRD = period - 1; // PWM frequency = 1 / period
|
||||
EPwm5Regs.CMPB.bit.CMPB = period / 2; // set duty 50% initial
|
||||
EPwm5Regs.CMPB.all |= (1 << 8); // initialize HRPWM extension
|
||||
EPwm5Regs.CMPA.bit.CMPA = period / 2; // set duty 50% initially
|
||||
EPwm5Regs.CMPA.bit.CMPAHR = (1 << 8);
|
||||
EPwm5Regs.TBPHS.all = 0;
|
||||
EPwm5Regs.TBCTR = 0;
|
||||
|
||||
EPwm5Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
|
||||
EPwm5Regs.TBCTL.bit.PHSEN = TB_DISABLE;
|
||||
EPwm5Regs.EPWMSYNCINSEL.all = SYNC_IN_SRC_DISABLE_ALL;
|
||||
EPwm5Regs.EPWMSYNCOUTEN.all = SYNC_OUT_SRC_DISABLE_ALL;
|
||||
EPwm5Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
EPwm5Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
EPwm5Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm5Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
EPwm5Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm5Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
EPwm5Regs.AQCTLA.bit.ZRO = AQ_SET;
|
||||
EPwm5Regs.AQCTLA.bit.CAU = AQ_CLEAR;
|
||||
EPwm5Regs.AQCTLB.bit.ZRO = AQ_SET;
|
||||
EPwm5Regs.AQCTLB.bit.CBU = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
EPwm5Regs.HRCNFG.all = 0x0;
|
||||
EPwm5Regs.HRCNFG.bit.EDGMODE = HR_FEP;
|
||||
EPwm5Regs.HRCNFG.bit.CTLMODE = HR_CMP;
|
||||
EPwm5Regs.HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
|
||||
|
||||
EPwm5Regs.HRCNFG.bit.EDGMODEB = HR_FEP;
|
||||
EPwm5Regs.HRCNFG.bit.CTLMODEB = HR_CMP;
|
||||
EPwm5Regs.HRCNFG.bit.HRLOADB = HR_CTR_ZERO;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM6_Config - Configure HRPWM6 settings
|
||||
//
|
||||
void HRPWM6_Config(period)
|
||||
{
|
||||
//
|
||||
// ePWM6 register configuration with HRPWM
|
||||
// ePWM6A / 6B toggle high/low with MEP control on falling edge
|
||||
//
|
||||
EPwm6Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; // set Immediate load
|
||||
EPwm6Regs.TBPRD = period - 1; // PWM frequency = 1 / period
|
||||
EPwm6Regs.CMPB.bit.CMPB = period / 2; // set duty 50% initial
|
||||
EPwm6Regs.CMPB.all |= (1 << 8); // initialize HRPWM extension
|
||||
EPwm6Regs.CMPA.bit.CMPA = period / 2; // set duty 50% initially
|
||||
EPwm6Regs.CMPA.bit.CMPAHR = (1 << 8);
|
||||
EPwm6Regs.TBPHS.all = 0;
|
||||
EPwm6Regs.TBCTR = 0;
|
||||
|
||||
EPwm6Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
|
||||
EPwm6Regs.TBCTL.bit.PHSEN = TB_DISABLE;
|
||||
EPwm6Regs.EPWMSYNCINSEL.all = SYNC_IN_SRC_DISABLE_ALL;
|
||||
EPwm6Regs.EPWMSYNCOUTEN.all = SYNC_OUT_SRC_DISABLE_ALL;
|
||||
EPwm6Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
EPwm6Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
EPwm6Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm6Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
EPwm6Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm6Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
EPwm6Regs.AQCTLA.bit.ZRO = AQ_SET;
|
||||
EPwm6Regs.AQCTLA.bit.CAU = AQ_CLEAR;
|
||||
EPwm6Regs.AQCTLB.bit.ZRO = AQ_SET;
|
||||
EPwm6Regs.AQCTLB.bit.CBU = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
EPwm6Regs.HRCNFG.all = 0x0;
|
||||
EPwm6Regs.HRCNFG.bit.EDGMODE = HR_FEP;
|
||||
EPwm6Regs.HRCNFG.bit.CTLMODE = HR_CMP;
|
||||
EPwm6Regs.HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
|
||||
|
||||
EPwm6Regs.HRCNFG.bit.EDGMODEB = HR_FEP;
|
||||
EPwm6Regs.HRCNFG.bit.CTLMODEB = HR_CMP;
|
||||
EPwm6Regs.HRCNFG.bit.HRLOADB = HR_CTR_ZERO;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM7_Config - Configure HRPWM7 settings
|
||||
//
|
||||
void HRPWM7_Config(period)
|
||||
{
|
||||
//
|
||||
// ePWM7 register configuration with HRPWM
|
||||
// ePWM7A 7B toggle high/low with MEP control on falling edge
|
||||
//
|
||||
EPwm7Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; // set Immediate load
|
||||
EPwm7Regs.TBPRD = period - 1; // PWM frequency = 1 / period
|
||||
EPwm7Regs.CMPB.bit.CMPB = period / 2; // set duty 50% initial
|
||||
EPwm7Regs.CMPB.all |= (1 << 8); // initialize HRPWM extension
|
||||
EPwm7Regs.CMPA.bit.CMPA = period / 2; // set duty 50% initially
|
||||
EPwm7Regs.CMPA.bit.CMPAHR = (1 << 8);
|
||||
EPwm7Regs.TBPHS.all = 0;
|
||||
EPwm7Regs.TBCTR = 0;
|
||||
|
||||
EPwm7Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
|
||||
EPwm7Regs.TBCTL.bit.PHSEN = TB_DISABLE;
|
||||
EPwm7Regs.EPWMSYNCINSEL.all = SYNC_IN_SRC_DISABLE_ALL;
|
||||
EPwm7Regs.EPWMSYNCOUTEN.all = SYNC_OUT_SRC_DISABLE_ALL;
|
||||
EPwm7Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
EPwm7Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
EPwm7Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm7Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
EPwm7Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm7Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
EPwm7Regs.AQCTLA.bit.ZRO = AQ_SET;
|
||||
EPwm7Regs.AQCTLA.bit.CAU = AQ_CLEAR;
|
||||
EPwm7Regs.AQCTLB.bit.ZRO = AQ_SET;
|
||||
EPwm7Regs.AQCTLB.bit.CBU = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
EPwm7Regs.HRCNFG.all = 0x0;
|
||||
EPwm7Regs.HRCNFG.bit.EDGMODE = HR_FEP;
|
||||
EPwm7Regs.HRCNFG.bit.CTLMODE = HR_CMP;
|
||||
EPwm7Regs.HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
|
||||
|
||||
EPwm7Regs.HRCNFG.bit.EDGMODEB = HR_FEP;
|
||||
EPwm7Regs.HRCNFG.bit.CTLMODEB = HR_CMP;
|
||||
EPwm7Regs.HRCNFG.bit.HRLOADB = HR_CTR_ZERO;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM8_Config - Configure HRPWM8 settings
|
||||
//
|
||||
void HRPWM8_Config(period)
|
||||
{
|
||||
//
|
||||
// ePWM8 register configuration with HRPWM
|
||||
// ePWM8A 8B toggle high/low with MEP control on falling edge
|
||||
//
|
||||
EPwm8Regs.TBCTL.bit.PRDLD = TB_IMMEDIATE; // set Immediate load
|
||||
EPwm8Regs.TBPRD = period - 1; // PWM frequency = 1 / period
|
||||
EPwm8Regs.CMPB.bit.CMPB = period / 2; // set duty 50% initial
|
||||
EPwm8Regs.CMPB.all |= (1 << 8); // initialize HRPWM extension
|
||||
EPwm8Regs.CMPA.bit.CMPA = period / 2; // set duty 50% initially
|
||||
EPwm8Regs.CMPA.bit.CMPAHR = (1 << 8);
|
||||
EPwm8Regs.TBPHS.all = 0;
|
||||
EPwm8Regs.TBCTR = 0;
|
||||
|
||||
EPwm8Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
|
||||
EPwm8Regs.TBCTL.bit.PHSEN = TB_DISABLE;
|
||||
EPwm8Regs.EPWMSYNCINSEL.all = SYNC_IN_SRC_DISABLE_ALL;
|
||||
EPwm8Regs.EPWMSYNCOUTEN.all = SYNC_OUT_SRC_DISABLE_ALL;
|
||||
EPwm8Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
EPwm8Regs.TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
EPwm8Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
EPwm8Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
EPwm8Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
EPwm8Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
EPwm8Regs.AQCTLA.bit.ZRO = AQ_SET;
|
||||
EPwm8Regs.AQCTLA.bit.CAU = AQ_CLEAR;
|
||||
EPwm8Regs.AQCTLB.bit.ZRO = AQ_SET;
|
||||
EPwm8Regs.AQCTLB.bit.CBU = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
EPwm8Regs.HRCNFG.all = 0x0;
|
||||
EPwm8Regs.HRCNFG.bit.EDGMODE = HR_FEP;
|
||||
EPwm8Regs.HRCNFG.bit.CTLMODE = HR_CMP;
|
||||
EPwm8Regs.HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
|
||||
|
||||
EPwm8Regs.HRCNFG.bit.EDGMODEB = HR_FEP;
|
||||
EPwm8Regs.HRCNFG.bit.CTLMODEB = HR_CMP;
|
||||
EPwm8Regs.HRCNFG.bit.HRLOADB = HR_CTR_ZERO;
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,442 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: hrpwm_ex2_duty_sfo_v8.c
|
||||
//
|
||||
// TITLE: f2838x Device HRPWM SFO V8 High-Resolution Period
|
||||
// (Up-Down Count) example
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> HRPWM Duty SFO (hrpwm_duty_sfo_v8)</h1>
|
||||
//! This program requires the f2838x header files, which include
|
||||
//! the following files required for this example:
|
||||
//! sfo_v8.h and SFO_v8_fpu_lib_build_c28_eabi.lib
|
||||
//!
|
||||
//! Monitor ePWM1-ePWM8 A/B pins on an oscilloscope.
|
||||
//! DESCRIPTION:
|
||||
//!
|
||||
//! This example modifies the MEP control registers to show edge displacement
|
||||
//! for high-resolution period with ePWM in Up-Down count mode
|
||||
//! due to the HRPWM control extension of the respective ePWM module.
|
||||
//!
|
||||
//! This example calls the following TI's MEP Scale Factor Optimizer (SFO)
|
||||
//! software library V8 functions:
|
||||
//!
|
||||
//! \b int \b SFO(); \n
|
||||
//! - updates MEP_ScaleFactor dynamically when HRPWM is in use
|
||||
//! - updates HRMSTEP register (exists only in EPwm1Regs register space)
|
||||
//! with MEP_ScaleFactor value
|
||||
//! - returns 2 if error: MEP_ScaleFactor is greater than maximum value of 255
|
||||
//! (Auto-conversion may not function properly under this condition)
|
||||
//! - returns 1 when complete for the specified channel
|
||||
//! - returns 0 if not complete for the specified channel
|
||||
//!
|
||||
//! This example is intended to explain the HRPWM capabilities. The code can be
|
||||
//! optimized for code efficiency. Refer to TI's Digital power application
|
||||
//! examples and TI Digital Power Supply software libraries for details.
|
||||
//!
|
||||
//! All ePWM1 -8 all channels will have fine edge movement due to the
|
||||
//! HRPWM logic
|
||||
//! =======================================================================
|
||||
//! NOTE: For more information on using the SFO software library, see the
|
||||
//! f2838x High-Resolution Pulse Width Modulator (HRPWM) Reference Guide
|
||||
//! =======================================================================
|
||||
//!
|
||||
//! To load and run this example:
|
||||
//! -# **!!IMPORTANT!!**
|
||||
//! -# Run this example at maximum SYSCLKOUT
|
||||
//! -# Activate Real time mode
|
||||
//! -# Run the code
|
||||
//! -# Watch ePWM A / B channel waveforms on a Oscilloscope
|
||||
//! -# In the watch window:
|
||||
//! Set the variable UpdateFine = 1 to observe the ePWMxA & ePWMxB output
|
||||
//! with HRPWM capabilities (default)
|
||||
//! Observe the period/frequency of the waveform changes in fine MEP steps
|
||||
//! -# In the watch window:
|
||||
//! Change the variable UpdateFine to 0, to observe the
|
||||
//! ePWMxA & ePWMxB output without HRPWM capabilities
|
||||
//! Observe the period/frequency of the waveform changes in coarse
|
||||
//! SYSCLKOUT cycle steps.
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "sfo_v8.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define PWM_CH 9 // # of PWM channels + 1
|
||||
#define STATUS_SUCCESS 1
|
||||
#define STATUS_FAIL 0
|
||||
|
||||
#define AUTOCONVERT 0 // 1 = Turn auto-conversion ON
|
||||
// 0 = Turn auto-conversion OFF
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 UpdateFine;
|
||||
Uint16 DutyFine;
|
||||
Uint16 status;
|
||||
Uint16 CMPA_reg_val;
|
||||
Uint16 CMPAHR_reg_val;
|
||||
Uint16 CMPB_reg_val;
|
||||
Uint16 CMPBHR_reg_val;
|
||||
|
||||
int MEP_ScaleFactor; // Global variable used by the SFO library
|
||||
// Result can be used for all HRPWM channels
|
||||
// This variable is also copied to HRMSTEP
|
||||
// register by SFO() function.
|
||||
|
||||
//
|
||||
// Array of pointers to EPwm register structures:
|
||||
// *ePWM[0] is defined as dummy value not used in the example
|
||||
//
|
||||
volatile struct EPWM_REGS *ePWM[PWM_CH] = {0, &EPwm1Regs, &EPwm2Regs,
|
||||
&EPwm3Regs, &EPwm4Regs, &EPwm5Regs,
|
||||
&EPwm6Regs, &EPwm7Regs, &EPwm8Regs};
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void HRPWM_Config(int);
|
||||
void error(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
int i;
|
||||
Uint32 temp, temp1;
|
||||
|
||||
//
|
||||
// Initialize System Control for Control and Analog Subsystems
|
||||
// Enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
EALLOW;
|
||||
InitSysCtrl();
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitEPwm1Gpio();
|
||||
InitEPwm2Gpio();
|
||||
InitEPwm3Gpio();
|
||||
InitEPwm4Gpio();
|
||||
InitEPwm5Gpio();
|
||||
InitEPwm6Gpio();
|
||||
InitEPwm7Gpio();
|
||||
InitEPwm8Gpio();
|
||||
|
||||
DINT; // Disable CPU interrupts
|
||||
|
||||
//
|
||||
// Initialize PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
EALLOW;
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// For this example, only initialize the ePWM
|
||||
// User specific code, enable interrupts:
|
||||
//
|
||||
UpdateFine = 1;
|
||||
DutyFine = 0;
|
||||
status = SFO_INCOMPLETE;
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Calling SFO() updates the HRMSTEP register with calibrated
|
||||
// MEP_ScaleFactor. HRMSTEP must be populated with a scale factor
|
||||
// value prior to enabling high resolution period control.
|
||||
//
|
||||
while(status == SFO_INCOMPLETE)
|
||||
{
|
||||
status = SFO();
|
||||
if(status == SFO_ERROR)
|
||||
{
|
||||
error(); // SFO function returns 2 if an error occurs & # of MEP
|
||||
} // steps/coarse step exceeds maximum of 255.
|
||||
}
|
||||
|
||||
//
|
||||
// ePWM and HRPWM register initialization
|
||||
//
|
||||
HRPWM_Config(10); // ePWMx target
|
||||
EALLOW;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Sweep DutyFine as a Q15 number from 0.2 - 0.999
|
||||
//
|
||||
for(DutyFine = 0x199A; DutyFine < 0x7FDF; DutyFine++)
|
||||
{
|
||||
if(UpdateFine)
|
||||
{
|
||||
|
||||
/* All below calculations apply for CMPB as well.
|
||||
// CMPA_reg_val , CMPAHR_reg_val is calculated as a Q0.
|
||||
// Since DutyFine is a Q15 number, and the period is Q0
|
||||
// the product is Q15. So to store as a Q0, we shift right
|
||||
// 15 bits.
|
||||
|
||||
CMPA_reg_val = ((long)DutyFine * (EPwm1Regs.TBPRD + 1)) >> 15;
|
||||
|
||||
// This next step is to obtain the remainder which was
|
||||
// truncated during our 15 bit shift above.
|
||||
// compute the whole value, and then subtract CMPA_reg_val
|
||||
// shifted LEFT 15 bits:
|
||||
temp = ((long)DutyFine * (EPwm1Regs.TBPRD + 1)) ;
|
||||
temp = temp - ((long)CMPA_reg_val << 15);
|
||||
|
||||
** If auto-conversion is disabled, the following step can be
|
||||
// skipped. If autoconversion is enabled, the SFO function will
|
||||
// write the MEP_ScaleFactor to the HRMSTEP register and the
|
||||
// hardware will automatically scale the remainder in the CMPAHR
|
||||
// register by the MEP_ScaleFactor.
|
||||
// Because the remainder calculated above (temp) is in Q15
|
||||
// format, it must be shifted left by 1 to convert to Q16 format
|
||||
// for the hardware to properly convert.
|
||||
CMPAHR_reg_val = temp << 1;
|
||||
|
||||
** If auto-conversion is enabled, the following step is
|
||||
performed automatically in hardware and can be skipped
|
||||
// This obtains the MEP count in digits, from
|
||||
// 0,1, .... MEP_Scalefactor.
|
||||
// 0x0080 (0.5 in Q8) is converted to 0.5 in Q15 by shifting
|
||||
// left 7. This is added to fractional duty * MEP_SF product in
|
||||
// order to round the decimal portion of the product up to the
|
||||
// next integer if the decimal portion is >= 0.5.
|
||||
//
|
||||
// Once again since this is Q15 convert to Q0 by shifting:
|
||||
//
|
||||
CMPAHR_reg_val = (temp * MEP_ScaleFactor + (0x0080 << 7)) >> 15;
|
||||
|
||||
** If auto-conversion is enabled, the following step is
|
||||
performed automatically in hardware and can be skipped
|
||||
// Now the lower 8 bits contain the MEP count.
|
||||
// Since the MEP count needs to be in the upper 8 bits of
|
||||
// the 16 bit CMPAHR register, shift left by 8.
|
||||
CMPAHR_reg_val = CMPAHR_reg_val << 8;
|
||||
|
||||
// Write the values to the registers as one 32-bit or two
|
||||
// 16-bits
|
||||
EPwm1Regs.CMPA.bit.CMPA = CMPA_reg_val;
|
||||
EPwm1Regs.CMPA.bit.CMPAHR = CMPAHR_reg_val;
|
||||
*/
|
||||
|
||||
//
|
||||
// All the above operations may be condensed into the following
|
||||
// form:
|
||||
//
|
||||
for(i = 1;i < PWM_CH;i++)
|
||||
{
|
||||
CMPA_reg_val = ((long)DutyFine * ((*ePWM[i]).TBPRD + 1)) >> 15;
|
||||
CMPB_reg_val = ((long)DutyFine * ((*ePWM[i]).TBPRD + 1)) >> 15;
|
||||
temp = ((long)DutyFine * ((*ePWM[i]).TBPRD + 1)) ;
|
||||
temp1 = ((long)DutyFine * ((*ePWM[i]).TBPRD + 1)) ;
|
||||
temp = temp - ((long)CMPA_reg_val << 15);
|
||||
temp1 = temp1 - ((long)CMPB_reg_val << 15);
|
||||
|
||||
#if(AUTOCONVERT)
|
||||
CMPAHR_reg_val = temp << 1; // convert to Q16
|
||||
CMPBHR_reg_val = temp << 1; // convert to Q16
|
||||
#else
|
||||
CMPAHR_reg_val = ((temp * MEP_ScaleFactor) +
|
||||
(0x0080 << 7)) >> 15;
|
||||
CMPAHR_reg_val = CMPAHR_reg_val << 8;
|
||||
CMPBHR_reg_val = ((temp1 * MEP_ScaleFactor) +
|
||||
(0x0080 << 7)) >> 15;
|
||||
CMPBHR_reg_val = CMPBHR_reg_val << 8;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Example for a 32 bit write to CMPA:CMPAHR
|
||||
//
|
||||
(*ePWM[i]).CMPA.all = ((long)CMPA_reg_val) << 16 |
|
||||
CMPAHR_reg_val; // loses lower 8-bits
|
||||
//
|
||||
// Example for a 32 bit write to CMPB:CMPBHR
|
||||
//
|
||||
(*ePWM[i]).CMPB.all = ((long)CMPB_reg_val) << 16 |
|
||||
CMPBHR_reg_val; // loses lower 8-bits
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// CMPA_reg_val is calculated as a Q0.
|
||||
// Since DutyFine is a Q15 number, and the period is Q0
|
||||
// the product is Q15. So to store as a Q0, we shift right
|
||||
// 15 bits.
|
||||
//
|
||||
for(i = 1;i < PWM_CH;i++)
|
||||
{
|
||||
(*ePWM[i]).CMPA.bit.CMPA = (((long)DutyFine *
|
||||
((*ePWM[i]).TBPRD + 1)) >> 15);
|
||||
(*ePWM[i]).CMPB.bit.CMPB = (((long)DutyFine *
|
||||
((*ePWM[i]).TBPRD + 1)) >> 15);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Call the scale factor optimizer lib function SFO()
|
||||
// periodically to track for any change due to temp/voltage.
|
||||
// This function generates MEP_ScaleFactor by running the
|
||||
// MEP calibration module in the HRPWM logic. This scale
|
||||
// factor can be used for all HRPWM channels. The SFO()
|
||||
// function also updates the HRMSTEP register with the
|
||||
// scale factor value.
|
||||
//
|
||||
status = SFO(); // in background, MEP calibration module
|
||||
// continuously updates MEP_ScaleFactor
|
||||
|
||||
if(status == SFO_ERROR)
|
||||
{
|
||||
error(); // SFO function returns 2 if an error occurs & #
|
||||
// of MEP steps/coarse step
|
||||
} // exceeds maximum of 255.
|
||||
} // end DutyFine for loop
|
||||
} // end infinite for loop
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM_Config - Configures all ePWM channels and sets up HRPWM
|
||||
// on ePWMxA / ePWMxB channels
|
||||
//
|
||||
void HRPWM_Config(period)
|
||||
{
|
||||
Uint16 j;
|
||||
|
||||
//
|
||||
// ePWM channel register configuration with HRPWM
|
||||
// ePWMxA / ePWMxB toggle low/high with MEP control on Rising edge
|
||||
//
|
||||
for (j = 1;j < PWM_CH;j++)
|
||||
{
|
||||
(*ePWM[j]).TBCTL.bit.PRDLD = TB_SHADOW; // set Shadow load
|
||||
(*ePWM[j]).TBPRD = period-1; // PWM frequency = 1 / period
|
||||
(*ePWM[j]).CMPA.bit.CMPA = period / 2; // set duty 50% initially
|
||||
(*ePWM[j]).CMPA.bit.CMPAHR = (1 << 8); // initialize HRPWM extension
|
||||
(*ePWM[j]).CMPB.bit.CMPB = period / 2; // set duty 50% initially
|
||||
(*ePWM[j]).CMPB.all |= (1 << 8); // initialize HRPWM extension
|
||||
(*ePWM[j]).TBPHS.all = 0;
|
||||
(*ePWM[j]).TBCTR = 0;
|
||||
|
||||
(*ePWM[j]).TBCTL.bit.CTRMODE = TB_COUNT_UP;
|
||||
(*ePWM[j]).TBCTL.bit.PHSEN = TB_DISABLE;
|
||||
(*ePWM[j]).EPWMSYNCINSEL.all = SYNC_IN_SRC_DISABLE_ALL;
|
||||
(*ePWM[j]).EPWMSYNCOUTEN.all = SYNC_OUT_SRC_DISABLE_ALL;
|
||||
(*ePWM[j]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
(*ePWM[j]).TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
(*ePWM[j]).TBCTL.bit.FREE_SOFT = 11;
|
||||
|
||||
(*ePWM[j]).CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
|
||||
(*ePWM[j]).CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
(*ePWM[j]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
(*ePWM[j]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
|
||||
(*ePWM[j]).AQCTLA.bit.ZRO = AQ_SET; // PWM toggle high/low
|
||||
(*ePWM[j]).AQCTLA.bit.CAU = AQ_CLEAR;
|
||||
(*ePWM[j]).AQCTLB.bit.ZRO = AQ_SET;
|
||||
(*ePWM[j]).AQCTLB.bit.CBU = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
(*ePWM[j]).HRCNFG.all = 0x0;
|
||||
(*ePWM[j]).HRCNFG.bit.EDGMODE = HR_FEP; // MEP control on falling edge
|
||||
(*ePWM[j]).HRCNFG.bit.CTLMODE = HR_CMP;
|
||||
(*ePWM[j]).HRCNFG.bit.HRLOAD = HR_CTR_ZERO;
|
||||
(*ePWM[j]).HRCNFG.bit.EDGMODEB = HR_FEP; // MEP control on falling edge
|
||||
(*ePWM[j]).HRCNFG.bit.CTLMODEB = HR_CMP;
|
||||
(*ePWM[j]).HRCNFG.bit.HRLOADB = HR_CTR_ZERO;
|
||||
#if(AUTOCONVERT)
|
||||
(*ePWM[j]).HRCNFG.bit.AUTOCONV = 1; // Enable auto-conversion
|
||||
// logic
|
||||
#endif
|
||||
(*ePWM[j]).HRPCTL.bit.HRPE = 0; // Turn off high-resolution period
|
||||
// control.
|
||||
EDIS;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// error - Halt debugger when called
|
||||
//
|
||||
void error (void)
|
||||
{
|
||||
ESTOP0; // Stop here and handle error
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,369 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: hrpwm_ex3_prdupdown_sfo_v8.c
|
||||
//
|
||||
// TITLE: f2838x Device HRPWM SFO V8 High-Resolution Period (Up-Down Count)
|
||||
// example
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> HRPWM SFO Test (hrpwm_prdupdown_sfo_v8)</h1>
|
||||
//!
|
||||
//! This program requires the f2838x header files, which include
|
||||
//! the following files required for this example:
|
||||
//! sfo_v8.h and SFO_v8_fpu_lib_build_c28_eabi.lib
|
||||
//!
|
||||
//! Monitor ePWM1-ePWM8 A/B pins on an oscilloscope.
|
||||
//! DESCRIPTION:
|
||||
//!
|
||||
//! This example modifies the MEP control registers to show edge displacement
|
||||
//! for high-resolution period with ePWM in Up-Down count mode
|
||||
//! due to the HRPWM control extension of the respective ePWM module.
|
||||
//!
|
||||
//! This example calls the following TI's MEP Scale Factor Optimizer (SFO)
|
||||
//! software library V8 functions:
|
||||
//!
|
||||
//! \b int \b SFO(); \n
|
||||
//! - updates MEP_ScaleFactor dynamically when HRPWM is in use
|
||||
//! - updates HRMSTEP register (exists only in EPwm1Regs register space)
|
||||
//! with MEP_ScaleFactor value
|
||||
//! - returns 2 if error: MEP_ScaleFactor is greater than maximum value of 255
|
||||
//! (Auto-conversion may not function properly under this condition)
|
||||
//! - returns 1 when complete for the specified channel
|
||||
//! - returns 0 if not complete for the specified channel
|
||||
//!
|
||||
//! This example is intended to explain the HRPWM capabilities. The code can be
|
||||
//! optimized for code efficiency. Refer to TI's Digital power application
|
||||
//! examples and TI Digital Power Supply software libraries for details.
|
||||
//!
|
||||
//! All ePWM1-8 A/B channels will have fine
|
||||
//! edge movement due to the HRPWM logic
|
||||
//!
|
||||
//! =======================================================================
|
||||
//! NOTE: For more information on using the SFO software library, see the
|
||||
//! f2838x High-Resolution Pulse Width Modulator (HRPWM) Reference Guide
|
||||
//! =======================================================================
|
||||
//!
|
||||
//! To load and run this example:
|
||||
//! -# **!!IMPORTANT!!**
|
||||
//! -# Run this example at maximum SYSCLKOUT
|
||||
//! -# Activate Real time mode
|
||||
//! -# Run the code
|
||||
//! -# Watch ePWM A / B channel waveforms on an Oscilloscope
|
||||
//! -# In the watch window:
|
||||
//! Set the variable UpdateFine = 1 to observe the ePWMxA & ePWMxB output
|
||||
//! with HRPWM capabilities (default)
|
||||
//! Observe the period/frequency of the waveform changes in fine MEP steps
|
||||
//! -# In the watch window:
|
||||
//! Change the variable UpdateFine to 0, to observe the
|
||||
//! ePWMxA & ePWMxB output without HRPWM capabilities
|
||||
//! Observe the period/frequency of the waveform changes in coarse SYSCLKOUT
|
||||
//! cycle steps.
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "sfo_v8.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define PWM_CH 9 // # of PWM channels + 1
|
||||
#define STATUS_SUCCESS 1
|
||||
#define STATUS_FAIL 0
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 UpdateFine, PeriodFine, status;
|
||||
|
||||
int MEP_ScaleFactor; // Global variable used by the SFO library
|
||||
// Result can be used for all HRPWM channels
|
||||
// This variable is also copied to HRMSTEP
|
||||
// register by SFO(0) function.
|
||||
|
||||
//
|
||||
// Array of pointers to EPwm register structures:
|
||||
// *ePWM[0] is defined as dummy value not used in the example
|
||||
//
|
||||
volatile struct EPWM_REGS *ePWM[PWM_CH] = {0, &EPwm1Regs, &EPwm2Regs,
|
||||
&EPwm3Regs, &EPwm4Regs, &EPwm5Regs,
|
||||
&EPwm6Regs, &EPwm7Regs, &EPwm8Regs};
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void HRPWM_Config(int);
|
||||
void error(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
EALLOW; // This is needed to write to EALLOW protected registers
|
||||
|
||||
//
|
||||
// Initialize System Control for Control and Analog Subsystems
|
||||
// Enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// EPWM1A and EPWM1B through all PWMS
|
||||
//
|
||||
InitEPwmGpio();
|
||||
|
||||
DINT; // Disable CPU interrupts
|
||||
|
||||
//
|
||||
// Initialize PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
//
|
||||
|
||||
//
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
EALLOW;
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Initialize system variables, enable HRPWM
|
||||
//
|
||||
UpdateFine = 1;
|
||||
PeriodFine = 0;
|
||||
status = SFO_INCOMPLETE;
|
||||
|
||||
//
|
||||
// Enable global Interrupts and higher priority real-time debug events:
|
||||
//
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
|
||||
//
|
||||
// Calling SFO() updates the HRMSTEP register with calibrated
|
||||
// MEP_ScaleFactor. HRMSTEP must be populated with a scale factor
|
||||
// value prior to enabling high resolution period control.
|
||||
//
|
||||
while(status == SFO_INCOMPLETE) // Call until complete
|
||||
{
|
||||
status = SFO();
|
||||
if(status == SFO_ERROR)
|
||||
{
|
||||
error(); // SFO function returns 2 if an error occurs & # of MEP
|
||||
} // steps/coarse step exceeds maximum of 255.
|
||||
}
|
||||
|
||||
//
|
||||
// ePWM and HRPWM register initialization
|
||||
//
|
||||
HRPWM_Config(20); // ePWMx target
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Sweep PeriodFine as a Q16 number from 0.2 - 0.999
|
||||
//
|
||||
for(PeriodFine = 0x3333; PeriodFine < 0xFFBF; PeriodFine++)
|
||||
{
|
||||
if(UpdateFine)
|
||||
{
|
||||
//
|
||||
// Because auto-conversion is enabled, the desired
|
||||
// fractional period must be written directly to the
|
||||
// TBPRDHR (or TBPRDHRM) register in Q16 format
|
||||
// (lower 8-bits are ignored)
|
||||
//
|
||||
// EPwm1Regs.TBPRDHR = PeriodFine;
|
||||
//
|
||||
// The hardware will automatically scale
|
||||
// the fractional period by the MEP_ScaleFactor
|
||||
// in the HRMSTEP register (which is updated
|
||||
// by the SFO calibration software).
|
||||
//
|
||||
// Hardware conversion:
|
||||
// MEP delay movement = ((TBPRDHR(15:0) >> 8) * HRMSTEP(7:0) +
|
||||
// 0x80) >> 8
|
||||
//
|
||||
for(i = 1;i < PWM_CH; i++)
|
||||
{
|
||||
(*ePWM[i]).TBPRDHR = PeriodFine; //In Q16 format
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// No high-resolution movement on TBPRDHR.
|
||||
//
|
||||
for(i = 1;i < PWM_CH; i++)
|
||||
{
|
||||
(*ePWM[i]).TBPRDHR = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Call the scale factor optimizer lib function SFO(0)
|
||||
// periodically to track for any change due to temp/voltage.
|
||||
// This function generates MEP_ScaleFactor by running the
|
||||
// MEP calibration module in the HRPWM logic. This scale
|
||||
// factor can be used for all HRPWM channels. HRMSTEP
|
||||
// register is automatically updated by the SFO function.
|
||||
//
|
||||
status = SFO(); // in background, MEP calibration module
|
||||
// continuously updates MEP_ScaleFactor
|
||||
|
||||
if(status == SFO_ERROR)
|
||||
{
|
||||
error(); // SFO function returns 2 if an error occurs & # of
|
||||
} // MEP steps/coarse step exceeds maximum of 255.
|
||||
} // end PeriodFine for loop
|
||||
} // end infinite for loop
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM_Config - Configures all ePWM channels and sets up HRPWM
|
||||
// on ePWMxA channels & ePWMxB channels
|
||||
//
|
||||
void HRPWM_Config(period)
|
||||
{
|
||||
Uint16 j;
|
||||
|
||||
//
|
||||
// ePWM channel register configuration with HRPWM
|
||||
// ePWMxA toggle low/high with MEP control on Rising edge
|
||||
//
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0; // Disable TBCLK within the EPWM
|
||||
EDIS;
|
||||
|
||||
for(j = 1;j < PWM_CH;j++)
|
||||
{
|
||||
(*ePWM[j]).TBCTL.bit.PRDLD = TB_SHADOW; // set Shadow load
|
||||
(*ePWM[j]).TBPRD = period; // PWM frequency = 1/(2*TBPRD)
|
||||
(*ePWM[j]).CMPA.bit.CMPA = period / 2; // set duty 50% initially
|
||||
(*ePWM[j]).CMPA.bit.CMPAHR = (1 << 8); // initialize HRPWM extension
|
||||
(*ePWM[j]).CMPB.bit.CMPB = period / 2; // set duty 50% initially
|
||||
(*ePWM[j]).CMPB.all |= 1;
|
||||
(*ePWM[j]).TBPHS.all = 0;
|
||||
(*ePWM[j]).TBCTR = 0;
|
||||
|
||||
(*ePWM[j]).TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Select up-down
|
||||
// count mode
|
||||
(*ePWM[j]).EPWMSYNCINSEL.all = SYNC_IN_SRC_DISABLE_ALL;
|
||||
(*ePWM[j]).EPWMSYNCOUTEN.all = SYNC_OUT_SRC_DISABLE_ALL;
|
||||
(*ePWM[j]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
(*ePWM[j]).TBCTL.bit.CLKDIV = TB_DIV1; // TBCLK = SYSCLKOUT
|
||||
(*ePWM[j]).TBCTL.bit.FREE_SOFT = 11;
|
||||
|
||||
(*ePWM[j]).CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // LOAD CMPA on CTR = 0
|
||||
(*ePWM[j]).CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
|
||||
(*ePWM[j]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
(*ePWM[j]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
(*ePWM[j]).AQCTLA.bit.CAU = AQ_SET; // PWM toggle high/low
|
||||
(*ePWM[j]).AQCTLA.bit.CAD = AQ_CLEAR;
|
||||
(*ePWM[j]).AQCTLB.bit.CBU = AQ_SET; // PWM toggle high/low
|
||||
(*ePWM[j]).AQCTLB.bit.CBD = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
(*ePWM[j]).HRCNFG.all = 0x0;
|
||||
(*ePWM[j]).HRCNFG.bit.EDGMODE = HR_BEP; // MEP control on
|
||||
// both edges.
|
||||
(*ePWM[j]).HRCNFG.bit.CTLMODE = HR_CMP; // CMPAHR and TBPRDHR
|
||||
// HR control.
|
||||
(*ePWM[j]).HRCNFG.bit.HRLOAD = HR_CTR_ZERO_PRD; // load on CTR = 0
|
||||
// and CTR = TBPRD
|
||||
(*ePWM[j]).HRCNFG.bit.EDGMODEB = HR_BEP; // MEP control on
|
||||
// both edges
|
||||
(*ePWM[j]).HRCNFG.bit.CTLMODEB = HR_CMP; // CMPBHR and TBPRDHR
|
||||
// HR control
|
||||
(*ePWM[j]).HRCNFG.bit.HRLOADB = HR_CTR_ZERO_PRD; // load on CTR = 0
|
||||
// and CTR = TBPRD
|
||||
(*ePWM[j]).HRCNFG.bit.AUTOCONV = 1; // Enable autoconversion for
|
||||
// HR period
|
||||
|
||||
(*ePWM[j]).HRPCTL.bit.TBPHSHRLOADE = 1; // Enable TBPHSHR sync
|
||||
// (required for updwn
|
||||
// count HR control)
|
||||
(*ePWM[j]).HRPCTL.bit.HRPE = 1; // Turn on high-resolution
|
||||
// period control.
|
||||
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1; // Enable TBCLK within
|
||||
// the EPWM
|
||||
(*ePWM[j]).TBCTL.bit.SWFSYNC = 1; // Synchronize high
|
||||
// resolution phase to
|
||||
// start HR period
|
||||
EDIS;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// error - Halt debugger when error occurs
|
||||
//
|
||||
void error (void)
|
||||
{
|
||||
ESTOP0; // Stop here and handle error
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,624 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: hrpwm_ex4_deadband_sfo_v8.c
|
||||
//
|
||||
// TITLE: f2838x Device HRPWM SFO V8 High-Resolution Dead-Band
|
||||
// (up-down count) example
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> HRPWM Dead-Band Example (hrpwm_deadband_sfo_v8)</h1>
|
||||
//! This program requires the f2838x header files, including the
|
||||
//! following files required for this example:
|
||||
//! sfo_v8.h and SFO_v8_fpu_lib_build_c28_eabi.lib
|
||||
//!
|
||||
//! Monitor ePWM1 & ePWM2 A/B pins on an oscilloscope
|
||||
//!
|
||||
//! DESCRIPTION:
|
||||
//!
|
||||
//! This example sweeps the ePWM frequency while maintaining a duty cycle of
|
||||
//! ~50% in ePWM up-down count mode. In addition, this example demonstrates
|
||||
//! ePWM high-resolution dead-band (HRDB) capabilities utilizing the HRPWM
|
||||
//! extension of the respective ePWM module.
|
||||
//!
|
||||
//! This example calls the following TI's micro-edge positioner (MEP) Scale
|
||||
//! Factor Optimizer (SFO) software library V8 functions:
|
||||
//!
|
||||
//! \b int \b SFO(); \n
|
||||
//! updates MEP_ScaleFactor dynamically when HRPWM is in use
|
||||
//! updates HRMSTEP register (exists only in EPwm1Regs register space)
|
||||
//! which updates MEP_ScaleFactor value
|
||||
//! - returns 0 if not complete for the specified channel
|
||||
//! - returns 1 when complete for the specified channel
|
||||
//! - returns 2 if error: MEP_ScaleFactor is greater than maximum value of 255
|
||||
//! (Auto-conversion may not function properly under this condition)
|
||||
//!
|
||||
//! This example is intended to demonstrate the HRPWM capability to control
|
||||
//! the dead-band falling edge delay (FED) and rising edge delay (RED).
|
||||
//!
|
||||
//! ePWM1 and ePWM2 A/B channels will have fine edge movement due to HRPWM
|
||||
//! control.
|
||||
//!
|
||||
//!=======================================================================
|
||||
//! NOTE: For more information on using the SFO software library, see the
|
||||
//! f2838x High-Resolution Pulse Width Modulator (HRPWM) Chapter in the
|
||||
//! Technical Reference Manual.
|
||||
//!=======================================================================
|
||||
//!
|
||||
//! To load and run this example:
|
||||
//! -# **!!IMPORTANT!!**
|
||||
//! -# Run this example at maximum SYSCLKOUT
|
||||
//! -# Activate Real time mode
|
||||
//! -# Run the "AddWatchWindowVars_HRPWM.js" script from the scripting console
|
||||
//! (View -> Scripting Console) to populate watch window by using the
|
||||
//! command:
|
||||
//! loadJSFile <path_to_JS_file>/AddWatchWindowVars_HRPWM.js
|
||||
//! -# Run the code
|
||||
//! -# Watch ePWM A / B channel waveforms on an oscilloscope
|
||||
//! -# In the watch window:
|
||||
//! Change the variable InputPeriodInc to increase or decrease the frequency
|
||||
//! sweep rate. Setting InputPeriodInc = 0 will stop the sweep while
|
||||
//! allowing other variables to be manipulated and updated in real time.
|
||||
//! -# In the watch window:
|
||||
//! Change values for registers EPwm1Regs.DBRED/EPwm2Regs.DBRED to see
|
||||
//! changes in rising edge dead-bands for ePWM1 and ePWM2 respectively.
|
||||
//! Alternatively, changing values for registers
|
||||
//! EPwm1Regs.DBFED/EPwm2Regs.DBFED will change falling edge dead-bands for
|
||||
//! ePWM1 and ePWM2. Changing these values will alter the duty cycle
|
||||
//! percentage for their respective ePWM modules.
|
||||
//! **!!NOTE!!** - DBRED/DBFED values should never be set below 4.
|
||||
//! Do not set these values to 0, 1, 2 or 3.
|
||||
//! -# In the watch window:
|
||||
//! Change values for registers
|
||||
//! EPwm1Regs.DBREDHR.bit.DBREDHR/EPwm2Regs.DBREDHR.bit.DBREDHR to increase
|
||||
//! or decrease number of resolvable high-resolution steps at the
|
||||
//! dead-band rising edge. Alternatively, change values for
|
||||
//! EPwm1Regs.DBFEDHR.bit.DBFEDHR/EPwm2Regs.DBFEDHR.bit.DBFEDHR to change
|
||||
//! the number of resolvable steps at the dead-band falling edge for ePWM1
|
||||
//! and ePWM2 respectively.
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "sfo_v8.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define PWM_CH 2 // # of PWM channels used in example
|
||||
#define HR_ENABLED 1 // 1 = HR behavior
|
||||
// 0 = non-HR behavior
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 UpdateFine, status;
|
||||
Uint16 temp_REM2 = 0, temp_PHS2, PhaseFine2;
|
||||
|
||||
Uint32 CountUpdatefine = 0, CountUpdateMax = 0;
|
||||
Uint16 Period = 0, PeriodFine = 0, PeriodOdd = 0;
|
||||
Uint16 PeriodIncrement = 0, PeriodFineIncrement = 0;
|
||||
Uint32 InputPeriodInc = 0;
|
||||
Uint32 PeriodFine_temp = 0;
|
||||
Uint16 PWM1 = 1;
|
||||
Uint16 PWM2 = 2;
|
||||
Uint16 PeriodMax = 600, PeriodMin = 360;
|
||||
|
||||
//
|
||||
// Array of pointers to EPwm register structures:
|
||||
// *ePWM[0] is defined as dummy value not used in the example
|
||||
//
|
||||
volatile struct EPWM_REGS *ePWM[PWM_CH + 1] = {0, &EPwm1Regs, &EPwm2Regs};
|
||||
|
||||
int MEP_ScaleFactor;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void HRPWM1_Config(int);
|
||||
void HRPWM2_Config(int);
|
||||
void FreqCtl_func(void);
|
||||
interrupt void PRDEQfix_ISR(void);
|
||||
void error(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize System Control for Control and Analog Subsystems.
|
||||
// Enable Peripheral Clocks.
|
||||
// This example function is found in the f2838x_SysCtrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_PieCtrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_PieVect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Set address of ISR in PIE vector table
|
||||
//
|
||||
EALLOW;
|
||||
PieVectTable.EPWM1_INT = &PRDEQfix_ISR;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Calling SFO() updates the HRMSTEP register with calibrated
|
||||
// MEP_ScaleFactor. HRMSTEP must be populated with a scale factor value
|
||||
// prior to enabling high resolution period control.
|
||||
//
|
||||
status = SFO_INCOMPLETE;
|
||||
while(status == SFO_INCOMPLETE)
|
||||
{
|
||||
//
|
||||
// Call until complete
|
||||
//
|
||||
status = SFO();
|
||||
if(status == SFO_ERROR)
|
||||
{
|
||||
error();
|
||||
}
|
||||
}
|
||||
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Init HRPWM1/HRPWM2
|
||||
//
|
||||
InitEPwm1Gpio();
|
||||
InitEPwm2Gpio();
|
||||
HRPWM1_Config(360); // EPwm1 target, Period = 360
|
||||
HRPWM2_Config(360); // EPwm2 target, Period = 360
|
||||
|
||||
EALLOW;
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1; // Resync PWM timebase clock
|
||||
(*ePWM[PWM1]).GLDCTL2.bit.OSHTLD = 1; // This should also write to
|
||||
// GLDCTL2 of PWM2
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Configure ePWM1 to generate interrupts on period match
|
||||
//
|
||||
(*ePWM[PWM1]).ETSEL.bit.INTSEL = 1; // Interrupt on counter zero match
|
||||
(*ePWM[PWM1]).ETSEL.bit.INTEN = 1; // Enable peripheral interrupt
|
||||
(*ePWM[PWM1]).ETPS.bit.INTPRD = 1; // Generate interrupt on every event
|
||||
PieCtrlRegs.PIEIER3.bit.INTx1 = 1; // Enable ePWM1 interrupt in PIE
|
||||
|
||||
IER |= 0x0004; // Enable core INT #3
|
||||
EINT; // Clear global interrupt mask
|
||||
|
||||
UpdateFine = 0; // Disable continuous updates
|
||||
Period = 360;
|
||||
PeriodFine = 0x0;
|
||||
CountUpdateMax = 0x0FFFF;
|
||||
CountUpdatefine = CountUpdateMax;
|
||||
|
||||
//
|
||||
// Watch window variable to modify the rate of the frequency sweep
|
||||
//
|
||||
InputPeriodInc = 6553;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
while(UpdateFine == 0)
|
||||
{
|
||||
if(CountUpdatefine >= CountUpdateMax)
|
||||
{
|
||||
if(Period < PeriodMax)
|
||||
{
|
||||
//
|
||||
// Perform sweep
|
||||
//
|
||||
PeriodIncrement = InputPeriodInc >> 16;
|
||||
PeriodFineIncrement = (Uint16)InputPeriodInc;
|
||||
Period = Period + PeriodIncrement;
|
||||
PeriodFine_temp = (Uint32)PeriodFine +
|
||||
(Uint32)PeriodFineIncrement;
|
||||
if(PeriodFine_temp >= 0x10000)
|
||||
{
|
||||
PeriodFine_temp = PeriodFine_temp - 0x10000;
|
||||
Period = Period + 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Period is odd - CMP is divide by 2 for 50% duty
|
||||
//
|
||||
if(Period % 2 == 1)
|
||||
{
|
||||
PeriodOdd = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
PeriodOdd = 0;
|
||||
}
|
||||
|
||||
PeriodFine = (Uint16) PeriodFine_temp;
|
||||
|
||||
//
|
||||
// Update PWM values for non-zero increment
|
||||
//
|
||||
if(InputPeriodInc != 0)
|
||||
{
|
||||
FreqCtl_func();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Period = PeriodMin;
|
||||
PeriodFine = 0;
|
||||
if(InputPeriodInc != 0)
|
||||
{
|
||||
FreqCtl_func();
|
||||
}
|
||||
}
|
||||
CountUpdatefine = 0;
|
||||
}
|
||||
CountUpdatefine++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM1_Config - ePWM1 register configuration with HRPWM
|
||||
// ePWM1A toggle low/high with MEP control on Rising edge
|
||||
//
|
||||
void HRPWM1_Config(PeriodConfig)
|
||||
{
|
||||
(*ePWM[PWM1]).TBCTL.bit.PRDLD = TB_SHADOW; // Set shadow load
|
||||
|
||||
//
|
||||
// PWM frequency = 1 / PeriodConfig
|
||||
//
|
||||
(*ePWM[PWM1]).TBPRD = PeriodConfig;
|
||||
|
||||
//
|
||||
// Set duty 50% initially and initialize HRPWM extension
|
||||
//
|
||||
(*ePWM[PWM1]).CMPA.bit.CMPA = PeriodConfig / 2;
|
||||
(*ePWM[PWM1]).CMPA.bit.CMPAHR = (1 << 8);
|
||||
(*ePWM[PWM1]).CMPB.bit.CMPB = PeriodConfig / 2;
|
||||
(*ePWM[PWM1]).CMPB.bit.CMPBHR = (1 << 8);
|
||||
(*ePWM[PWM1]).TBPHS.all = 0;
|
||||
(*ePWM[PWM1]).TBCTR = 0;
|
||||
|
||||
(*ePWM[PWM1]).TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
|
||||
(*ePWM[PWM1]).TBCTL.bit.PHSEN = TB_DISABLE; // ePWM1 is the Master
|
||||
(*ePWM[PWM1]).EPWMSYNCINSEL.all = SYNC_IN_SRC_DISABLE_ALL;
|
||||
(*ePWM[PWM1]).EPWMSYNCOUTEN.all = 2; // syncout on ctr = zero
|
||||
(*ePWM[PWM1]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
(*ePWM[PWM1]).TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
//
|
||||
// LOAD CMPA on CTR = ZERO_PRD
|
||||
//
|
||||
(*ePWM[PWM1]).CMPCTL.bit.LOADAMODE = CC_CTR_ZERO_PRD;
|
||||
(*ePWM[PWM1]).CMPCTL.bit.LOADBMODE = CC_CTR_ZERO_PRD;
|
||||
|
||||
(*ePWM[PWM1]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
(*ePWM[PWM1]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
(*ePWM[PWM1]).AQCTLA.bit.CAU = AQ_SET;
|
||||
(*ePWM[PWM1]).AQCTLA.bit.CAD = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
#if HR_ENABLED
|
||||
(*ePWM[PWM1]).HRCNFG.all = 0x1353;
|
||||
|
||||
//
|
||||
// Turn on high-resolution period control
|
||||
//
|
||||
(*ePWM[PWM1]).HRPCTL.bit.HRPE = 1;
|
||||
|
||||
//
|
||||
// Synchronize high resolution phase to start HR period
|
||||
//
|
||||
(*ePWM[PWM1]).TBCTL.bit.SWFSYNC = 1;
|
||||
#endif
|
||||
|
||||
(*ePWM[PWM1]).GLDCFG.bit.CMPA_CMPAHR = 1;
|
||||
(*ePWM[PWM1]).GLDCFG.bit.CMPB_CMPBHR = 1;
|
||||
|
||||
//
|
||||
// Load on CTR = ZERO_PRD (2) / ZERO (1)
|
||||
//
|
||||
(*ePWM[PWM1]).GLDCTL.bit.GLDMODE = 2;
|
||||
|
||||
//
|
||||
// One shot mode and global load enabled
|
||||
//
|
||||
(*ePWM[PWM1]).GLDCTL.bit.OSHTMODE = 1;
|
||||
(*ePWM[PWM1]).GLDCTL.bit.GLD = 1;
|
||||
|
||||
//
|
||||
// Write to PWM1 GLDCTL2 will result in simultaneous write to PWM2 GLDCTL2
|
||||
//
|
||||
(*ePWM[PWM1]).EPWMXLINK.bit.GLDCTL2LINK = PWM1 - 1;
|
||||
(*ePWM[PWM1]).DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
|
||||
(*ePWM[PWM1]).DBCTL.bit.POLSEL = DB_ACTV_HIC;
|
||||
(*ePWM[PWM1]).DBCTL.bit.IN_MODE = DBA_ALL;
|
||||
(*ePWM[PWM1]).DBCTL.bit.SHDWDBREDMODE = 1;
|
||||
(*ePWM[PWM1]).DBCTL.bit.SHDWDBFEDMODE = 1;
|
||||
(*ePWM[PWM1]).DBCTL.bit.LOADREDMODE = 0; // Load on Counter == 0
|
||||
(*ePWM[PWM1]).DBCTL.bit.LOADFEDMODE = 0; // Load on Counter == 0
|
||||
(*ePWM[PWM1]).DBCTL.bit.HALFCYCLE = 1;
|
||||
(*ePWM[PWM1]).DBRED.bit.DBRED = 4;
|
||||
(*ePWM[PWM1]).DBREDHR.bit.DBREDHR = 0x0;
|
||||
(*ePWM[PWM1]).DBFED.bit.DBFED = 4;
|
||||
(*ePWM[PWM1]).DBFEDHR.bit.DBFEDHR = 0x0;
|
||||
|
||||
(*ePWM[PWM1]).HRCNFG2.bit.EDGMODEDB = HR_BEP; // DBREDHR and DBFEDHR
|
||||
(*ePWM[PWM1]).HRCNFG2.bit.CTLMODEDBRED = 0; // Load on ZRO
|
||||
(*ePWM[PWM1]).HRCNFG2.bit.CTLMODEDBFED = 0; // Load on ZRO
|
||||
(*ePWM[PWM1]).DBREDHR.bit.DBREDHR = (0 << 9);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// HRPWM2_Config - ePWM2 register configuration with HRPWM
|
||||
// ePWM2A toggle low/high with MEP control on Rising edge
|
||||
//
|
||||
void HRPWM2_Config(PeriodConfig)
|
||||
{
|
||||
(*ePWM[PWM2]).TBCTL.bit.PRDLD = TB_SHADOW; // Set shadow load
|
||||
|
||||
//
|
||||
// PWM frequency = 1 / PeriodConfig
|
||||
//
|
||||
(*ePWM[PWM2]).TBPRD = PeriodConfig;
|
||||
|
||||
//
|
||||
// Set duty 50% initially and initialize HRPWM extension
|
||||
//
|
||||
(*ePWM[PWM2]).CMPA.bit.CMPA = PeriodConfig / 2;
|
||||
(*ePWM[PWM2]).CMPA.bit.CMPAHR = (1 << 8);
|
||||
(*ePWM[PWM2]).CMPB.bit.CMPB = PeriodConfig / 2;
|
||||
(*ePWM[PWM2]).CMPB.bit.CMPBHR = (1 << 8);
|
||||
(*ePWM[PWM2]).TBPHS.all = 0;
|
||||
(*ePWM[PWM2]).TBCTR = 0;
|
||||
|
||||
(*ePWM[PWM2]).TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN;
|
||||
(*ePWM[PWM2]).TBCTL.bit.PHSEN = TB_DISABLE; // ePWM1 is the Master
|
||||
(*ePWM[PWM2]).EPWMSYNCINSEL.all = SYNC_IN_SRC_SYNCOUT_EPWM1;
|
||||
(*ePWM[PWM2]).EPWMSYNCOUTEN.all = 1; // syncout on ctr = zero
|
||||
(*ePWM[PWM2]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
(*ePWM[PWM2]).TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
//
|
||||
// LOAD CMPA on CTR = 0
|
||||
//
|
||||
(*ePWM[PWM2]).CMPCTL.bit.LOADAMODE = CC_CTR_ZERO_PRD;
|
||||
(*ePWM[PWM2]).CMPCTL.bit.LOADBMODE = CC_CTR_ZERO_PRD;
|
||||
(*ePWM[PWM2]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
|
||||
(*ePWM[PWM2]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;
|
||||
|
||||
(*ePWM[PWM2]).AQCTLA.bit.CAU = AQ_SET;
|
||||
(*ePWM[PWM2]).AQCTLA.bit.CAD = AQ_CLEAR;
|
||||
|
||||
EALLOW;
|
||||
#if HR_ENABLED
|
||||
(*ePWM[PWM2]).HRCNFG.all = 0x1353;
|
||||
|
||||
//
|
||||
// Turn on high-resolution period control
|
||||
//
|
||||
(*ePWM[PWM2]).HRPCTL.bit.HRPE = 1;
|
||||
|
||||
//
|
||||
// Synchronize high resolution phase to start HR period
|
||||
//
|
||||
(*ePWM[PWM2]).TBCTL.bit.SWFSYNC = 1;
|
||||
#endif
|
||||
|
||||
(*ePWM[PWM2]).TBCTL.bit.PHSDIR = 1; // Count up after SYNC event
|
||||
(*ePWM[PWM2]).TBPHS.bit.TBPHS = 180;
|
||||
|
||||
(*ePWM[PWM2]).GLDCFG.bit.CMPA_CMPAHR = 1;
|
||||
(*ePWM[PWM2]).GLDCFG.bit.CMPB_CMPBHR = 1;
|
||||
|
||||
//
|
||||
// Load on CTR = ZERO_PRD (2) / ZERO (1)
|
||||
//
|
||||
(*ePWM[PWM2]).GLDCTL.bit.GLDMODE = 2;
|
||||
|
||||
//
|
||||
// One shot mode and global load enabled
|
||||
//
|
||||
(*ePWM[PWM2]).GLDCTL.bit.OSHTMODE = 1;
|
||||
(*ePWM[PWM2]).GLDCTL.bit.GLD = 1;
|
||||
|
||||
//
|
||||
// Write to PWM1 GLDCTL2 will result in simultaneous write to PWM2 GLDCTL2
|
||||
//
|
||||
(*ePWM[PWM2]).EPWMXLINK.bit.GLDCTL2LINK = PWM1 - 1;
|
||||
(*ePWM[PWM2]).DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
|
||||
(*ePWM[PWM2]).DBCTL.bit.POLSEL = DB_ACTV_HIC;
|
||||
(*ePWM[PWM2]).DBCTL.bit.IN_MODE = DBA_ALL;
|
||||
(*ePWM[PWM2]).DBCTL.bit.SHDWDBREDMODE = 1;
|
||||
(*ePWM[PWM2]).DBCTL.bit.SHDWDBFEDMODE = 1;
|
||||
(*ePWM[PWM2]).DBCTL.bit.LOADREDMODE = 0; // Load on Counter == 0
|
||||
(*ePWM[PWM2]).DBCTL.bit.LOADFEDMODE = 0; // Load on Counter == 0
|
||||
(*ePWM[PWM2]).DBCTL.bit.HALFCYCLE = 1;
|
||||
(*ePWM[PWM2]).DBRED.bit.DBRED = 4;
|
||||
(*ePWM[PWM2]).DBREDHR.bit.DBREDHR = 0x0;
|
||||
(*ePWM[PWM2]).DBFED.bit.DBFED = 4;
|
||||
(*ePWM[PWM2]).DBFEDHR.bit.DBFEDHR = 0x0;
|
||||
|
||||
(*ePWM[PWM2]).HRCNFG2.bit.EDGMODEDB = HR_BEP; // DBREDHR and DBFEDHR
|
||||
(*ePWM[PWM2]).HRCNFG2.bit.CTLMODEDBRED = 0; // Load on ZRO
|
||||
(*ePWM[PWM2]).HRCNFG2.bit.CTLMODEDBFED = 0; // Load on ZRO
|
||||
(*ePWM[PWM2]).DBREDHR.bit.DBREDHR = (0 << 9);
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// FreqCtl_func - Frequency modulation & phase sync function
|
||||
// This function is called only if frequency sweep is enabled
|
||||
//
|
||||
void FreqCtl_func(void)
|
||||
{
|
||||
if(PeriodOdd)
|
||||
{
|
||||
//
|
||||
// Add 0.5 if period is odd
|
||||
//
|
||||
(*ePWM[PWM1]).CMPA.bit.CMPAHR = (PeriodFine >> 1) + 0x7FFF;
|
||||
(*ePWM[PWM2]).CMPA.bit.CMPAHR = (PeriodFine >> 1) + 0x7FFF;
|
||||
(*ePWM[PWM1]).CMPB.bit.CMPBHR = (PeriodFine >> 1) + 0x7FFF;
|
||||
(*ePWM[PWM2]).CMPB.bit.CMPBHR = (PeriodFine >> 1) + 0x7FFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*ePWM[PWM1]).CMPA.bit.CMPAHR = PeriodFine >> 1;
|
||||
(*ePWM[PWM2]).CMPA.bit.CMPAHR = PeriodFine >> 1;
|
||||
(*ePWM[PWM1]).CMPB.bit.CMPBHR = PeriodFine >> 1;
|
||||
(*ePWM[PWM2]).CMPB.bit.CMPBHR = PeriodFine >> 1;
|
||||
}
|
||||
|
||||
(*ePWM[PWM1]).CMPA.bit.CMPA = (Period >> 1) + 1;
|
||||
(*ePWM[PWM2]).CMPA.bit.CMPA = (Period >> 1) + 1;
|
||||
(*ePWM[PWM1]).CMPB.bit.CMPB = (Period >> 1) + 1;
|
||||
(*ePWM[PWM2]).CMPB.bit.CMPB = (Period >> 1) + 1;
|
||||
|
||||
temp_PHS2 = (Period >> 1);
|
||||
|
||||
switch(PeriodOdd)
|
||||
{
|
||||
case 1:
|
||||
//
|
||||
// Accounting for divide by 2 = 0.5
|
||||
//
|
||||
PhaseFine2 = 0xFF - (PeriodFine >> 9) - 0x7F;
|
||||
break;
|
||||
|
||||
default:
|
||||
PhaseFine2 = 0xFF - (PeriodFine >> 9);
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// No fractional phase shift to account for
|
||||
//
|
||||
temp_REM2 = (Uint16) 0x100 + PhaseFine2;
|
||||
UpdateFine = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// PRDEQfix_ISR - ISR for Translator remainder calculations
|
||||
//
|
||||
interrupt void PRDEQfix_ISR(void)
|
||||
{
|
||||
EALLOW;
|
||||
if(UpdateFine == 1)
|
||||
{
|
||||
//
|
||||
// This should also write to GLDCTL2 of PWM2, PWM3 and PWM4
|
||||
//
|
||||
(*ePWM[PWM1]).GLDCTL2.bit.OSHTLD = 1;
|
||||
|
||||
//
|
||||
// TBCTR phase load on SYNC (required for updown count HR control)
|
||||
//
|
||||
(*ePWM[PWM2]).TBCTL.bit.PHSEN = TB_ENABLE;
|
||||
|
||||
//
|
||||
// Coarse phase offset relative to ePWM1
|
||||
//
|
||||
(*ePWM[PWM2]).TBPHS.bit.TBPHS = temp_PHS2;
|
||||
(*ePWM[PWM2]).TRREM.bit.TRREM = temp_REM2;
|
||||
|
||||
(*ePWM[PWM2]).TBPRDHR = PeriodFine;
|
||||
(*ePWM[PWM2]).TBPRD = Period;
|
||||
|
||||
(*ePWM[PWM1]).TBPRDHR = PeriodFine;
|
||||
(*ePWM[PWM1]).TBPRD = Period;
|
||||
(*ePWM[PWM1]).TRREM.bit.TRREM = 0x100;
|
||||
UpdateFine = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*ePWM[PWM2]).TBCTL.bit.PHSEN = TB_DISABLE;
|
||||
}
|
||||
|
||||
//
|
||||
// Re-initialize for next PWM interrupt
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3; // Acknowledge PIE interrupt
|
||||
(*ePWM[PWM1]).ETCLR.bit.INT = 1; // Clear interrupt bit
|
||||
EDIS;
|
||||
}
|
||||
|
||||
void error (void)
|
||||
{
|
||||
ESTOP0; // Stop here and handle error
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="i2c_ex1_master"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_cputimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../i2c_ex1_master.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="i2c_ex1_slave"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_cputimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../i2c_ex1_slave.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,464 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: i2c_ex1_master.c
|
||||
//
|
||||
// TITLE: I2C Example Master.
|
||||
//
|
||||
//! \addtogroup bitfield_example_list
|
||||
//! <h1>I2C master slave communication using bit-field and without FIFO </h1>
|
||||
//!
|
||||
//! This program shows how to use I2CA in master configuration.
|
||||
//! This example uses polling and does not use interrupts or FIFO
|
||||
//!
|
||||
//! \b Requires two Control Cards - one configured as Master and other as Slave \n
|
||||
//! \b Master will run the binary generated from "i2c_ex1_master.projectspec" \n
|
||||
//! \b Slave will run the binary generated from "i2c_ex1_slave.projectspec" \n
|
||||
//! \b External \b Connections on Control Cards should be made as shown below \n
|
||||
//! ----------------------------------------------------------------
|
||||
//! Signal | I2CA on Board1 | I2CA on Board 2
|
||||
//! -----------------------------------------------------------------
|
||||
//! SCL | GPIO_PIN_SCLA | GPIO_PIN_SCLA
|
||||
//! SDA | GPIO_PIN_SDAA | GPIO_PIN_SDAA
|
||||
//! GND | GND | GND
|
||||
//! -----------------------------------------------------------------
|
||||
//!
|
||||
//! Example1: Master Transmitter and Slave Receiver
|
||||
//! Example2: Master Receiver and Slave Transmitter
|
||||
//! Example3: Master Transmitter and Slave Receiver
|
||||
//! followed by Master Receiver and Slave Transmitter
|
||||
//! Example4: Master Receiver and Slave Transmitter
|
||||
//! followed by Master Transmitter and Slave Receiver
|
||||
//!
|
||||
//! \b Watch \b Variables in memory window\n
|
||||
//! - \b I2CA_TXdata
|
||||
//! - \b I2CA_RXdata
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define I2C_SLAVE_ADDRESS 0x6AU
|
||||
#define I2C_OWN_ADDRESS 0x30U
|
||||
#define MAX_BUFFER_SIZE 0x10
|
||||
#define I2C_NUMBYTES 0x2U
|
||||
|
||||
//
|
||||
// I2C GPIO pins
|
||||
//
|
||||
#define GPIO_PIN_SDAA 26U // GPIO number for I2C SDAA
|
||||
#define GPIO_PIN_SCLA 27U // GPIO number for I2C SCLA
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t I2C_TXdata[MAX_BUFFER_SIZE];
|
||||
uint16_t I2C_RXdata[MAX_BUFFER_SIZE];
|
||||
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void I2CMaster_Init(uint16_t I2CSlave_OwnAddress, uint16_t I2CSlave_Address);
|
||||
void I2CWrite(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition);
|
||||
uint16_t I2CRead(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition);
|
||||
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Locals
|
||||
//
|
||||
uint16_t index = 0U;
|
||||
uint16_t count = 0U;
|
||||
|
||||
//
|
||||
// Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Initialize GPIO
|
||||
//
|
||||
InitGpio();
|
||||
|
||||
//
|
||||
//Configure I2C pins
|
||||
//
|
||||
GPIO_SetupPinMux(GPIO_PIN_SDAA, GPIO_MUX_CPU1, 11);
|
||||
GPIO_SetupPinOptions(GPIO_PIN_SDAA, GPIO_OUTPUT, GPIO_PULLUP);
|
||||
GPIO_SetupPinMux(GPIO_PIN_SCLA, GPIO_MUX_CPU1, 11);
|
||||
GPIO_SetupPinOptions(GPIO_PIN_SCLA, GPIO_OUTPUT, GPIO_PULLUP);
|
||||
|
||||
|
||||
//
|
||||
// Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR)
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Set the buffer to some default non-zero value
|
||||
//
|
||||
for (index=0; index<MAX_BUFFER_SIZE;index++)
|
||||
{
|
||||
I2C_RXdata[index] = 0xBAADU;
|
||||
I2C_TXdata[index] = 0x11 * (index+1);
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize I2C Module as Master Transmitter
|
||||
//
|
||||
I2CMaster_Init(I2C_OWN_ADDRESS,I2C_SLAVE_ADDRESS);
|
||||
|
||||
//
|
||||
// Example 1 : Master as a Transmitter , writes two bytes
|
||||
//
|
||||
I2CWrite(I2C_SLAVE_ADDRESS, I2C_NUMBYTES, true);
|
||||
|
||||
//
|
||||
// Wait for I2C bus to clear
|
||||
//
|
||||
while(I2caRegs.I2CMDR.bit.STP !=0x0);
|
||||
while(I2caRegs.I2CSTR.bit.BB !=0x0);
|
||||
|
||||
//
|
||||
//If code reached below ESTOP0, Example 1 worked correctly
|
||||
//Observe the contents of I2CA_TXdata and I2CB_RXdata in memory browser
|
||||
// Move the PC to next line
|
||||
//
|
||||
ESTOP0;
|
||||
|
||||
//
|
||||
// Example 2 : Master as a Receiver , receives two bytes
|
||||
//
|
||||
count = I2CRead(I2C_SLAVE_ADDRESS,I2C_NUMBYTES,true);
|
||||
|
||||
//
|
||||
// Wait for I2C bus to clear
|
||||
//
|
||||
while(I2caRegs.I2CMDR.bit.STP !=0x0);
|
||||
while(I2caRegs.I2CSTR.bit.BB !=0x0);
|
||||
|
||||
//
|
||||
//If code reached below ESTOP0, Example 2 worked correctly
|
||||
//Observe the contents of I2CA_TXdata and I2CB_RXdata in memory browser
|
||||
// Move the PC to next line
|
||||
//
|
||||
ESTOP0;
|
||||
|
||||
//
|
||||
//clear the Rx buffer
|
||||
//
|
||||
for (index=0; index<count;index++)
|
||||
{
|
||||
I2C_RXdata[index] = 0xBAADU;
|
||||
}
|
||||
|
||||
//
|
||||
// Example 3 : Master Transmitter followed by Master Receiver
|
||||
//
|
||||
I2CWrite(I2C_SLAVE_ADDRESS, I2C_NUMBYTES, false); //Write byte
|
||||
count = I2CRead(I2C_SLAVE_ADDRESS,I2C_NUMBYTES,true);
|
||||
|
||||
//
|
||||
// Wait for I2C bus to clear
|
||||
//
|
||||
while(I2caRegs.I2CMDR.bit.STP !=0x0);
|
||||
while(I2caRegs.I2CSTR.bit.BB !=0x0);
|
||||
|
||||
//
|
||||
//If code reached below ESTOP0, Example 3 worked correctly
|
||||
//Observe the contents of I2CA_TXdata and I2CB_RXdata in memory browser
|
||||
// Move the PC to next line
|
||||
//
|
||||
ESTOP0;
|
||||
|
||||
//
|
||||
//clear the Rx buffer
|
||||
//
|
||||
for (index=0; index<count;index++)
|
||||
{
|
||||
I2C_RXdata[index] = 0xBAADU;
|
||||
}
|
||||
|
||||
//
|
||||
// Exampel 4: Master Receiver followed by Master Receiver
|
||||
//
|
||||
count =I2CRead(I2C_SLAVE_ADDRESS, I2C_NUMBYTES, false); //Write byte
|
||||
I2CWrite(I2C_SLAVE_ADDRESS,I2C_NUMBYTES,true);
|
||||
|
||||
//
|
||||
// Wait for I2C bus to clear
|
||||
//
|
||||
while(I2caRegs.I2CMDR.bit.STP !=0x0);
|
||||
while(I2caRegs.I2CSTR.bit.BB !=0x0);
|
||||
|
||||
//
|
||||
//If code reached below ESTOP0, Example 4 worked correctly
|
||||
//Observe the contents of I2CA_TXdata and I2CB_RXdata in memory browser
|
||||
// Move the PC to next line
|
||||
//
|
||||
ESTOP0;
|
||||
|
||||
//
|
||||
//clear the Rx buffer
|
||||
//
|
||||
for (index=0; index<count;index++)
|
||||
{
|
||||
I2C_RXdata[index] = 0xBAADU;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop forever.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Function to configure I2CA as Master Transmitter.
|
||||
//
|
||||
void I2CMaster_Init(uint16_t I2C_OwnAddress, uint16_t I2CSlave_Address)
|
||||
{
|
||||
EALLOW;
|
||||
//
|
||||
// Must put I2C into reset before configuring it
|
||||
//
|
||||
I2caRegs.I2CMDR.all &= ~(0x20U);
|
||||
|
||||
//
|
||||
// I2C configuration. Use a 400kHz I2CCLK with a 50% duty cycle.
|
||||
//
|
||||
//I2C_initMaster(base, DEVICE_SYSCLK_FREQ, 400000, I2C_DUTYCYCLE_50);
|
||||
I2caRegs.I2CPSC.all = 0xB; // Prescaler - need 7-12 Mhz on module clk
|
||||
I2caRegs.I2CCLKL = 0x7; // NOTE: must be non zero
|
||||
I2caRegs.I2CCLKH = 0x8; // NOTE: must be non zero
|
||||
|
||||
|
||||
//
|
||||
// Configure Master as a Transmitter
|
||||
//
|
||||
I2caRegs.I2CMDR.bit.MST = 0x1;
|
||||
I2caRegs.I2CMDR.bit.TRX = 0x1;
|
||||
|
||||
//
|
||||
// Set data count
|
||||
//
|
||||
I2caRegs.I2CCNT = I2C_NUMBYTES;
|
||||
|
||||
//
|
||||
// Set the bit count to 8 bits per data byte
|
||||
//
|
||||
I2caRegs.I2CMDR.bit.BC = 0x0U;
|
||||
|
||||
//
|
||||
// Configure slave and own address
|
||||
//
|
||||
I2caRegs.I2COAR.all = I2C_OwnAddress; // Own address
|
||||
I2caRegs.I2CSAR.all = I2CSlave_Address; // Slave address
|
||||
|
||||
//
|
||||
// Set emulation mode to FREE
|
||||
//
|
||||
I2caRegs.I2CMDR.bit.FREE = 0x1;
|
||||
|
||||
//
|
||||
//Clear all status
|
||||
//
|
||||
I2caRegs.I2CSTR.all = 0xFFFF;
|
||||
|
||||
//
|
||||
// Enable I2C Interrupts- RRDY
|
||||
//
|
||||
I2caRegs.I2CIER.all = 0x08;
|
||||
|
||||
//
|
||||
// Take I2C out of reset
|
||||
//
|
||||
I2caRegs.I2CMDR.all |= 0x0020;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Function to send data over I2C.
|
||||
//
|
||||
void I2CWrite(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition)
|
||||
{
|
||||
|
||||
//
|
||||
// Locals
|
||||
//
|
||||
uint16_t index = 0;
|
||||
|
||||
//
|
||||
// Configure slave address
|
||||
//
|
||||
I2caRegs.I2CSAR.all = slaveAddr; // Slave address
|
||||
|
||||
//
|
||||
// Configure I2C as Master Transmitter
|
||||
//
|
||||
I2caRegs.I2CMDR.bit.MST = 0x1;
|
||||
I2caRegs.I2CMDR.bit.TRX = 0x1;
|
||||
|
||||
//
|
||||
//Set Data Count
|
||||
//
|
||||
I2caRegs.I2CCNT = byteCount;
|
||||
|
||||
//
|
||||
// send Start condition
|
||||
//
|
||||
I2caRegs.I2CMDR.bit.STT = 0x1;
|
||||
|
||||
//
|
||||
//transmit the bytes
|
||||
//
|
||||
for(index=0; index < I2C_NUMBYTES; index++)
|
||||
{
|
||||
I2caRegs.I2CDXR.all= I2C_TXdata[index];
|
||||
//
|
||||
//wait till byte is sent
|
||||
//
|
||||
while(I2caRegs.I2CSTR.bit.BYTESENT != 0x1);
|
||||
//
|
||||
//clear the byte sent
|
||||
//
|
||||
I2caRegs.I2CSTR.bit.BYTESENT = 0x1;
|
||||
}
|
||||
|
||||
//
|
||||
// Send STOP condition if specified
|
||||
//
|
||||
if(sendStopCondition)
|
||||
{
|
||||
I2caRegs.I2CMDR.bit.STP = 0x1;
|
||||
while(I2caRegs.I2CMDR.bit.STP != 0x0);
|
||||
|
||||
I2caRegs.I2CSTR.bit.BYTESENT = 0x1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Function to read data over I2C. Returns the number of bytes read
|
||||
//
|
||||
uint16_t I2CRead(uint16_t slaveAddr, uint16_t byteCount, bool sendStopCondition)
|
||||
{
|
||||
//
|
||||
// Configure slave address
|
||||
//
|
||||
I2caRegs.I2CSAR.all = slaveAddr;
|
||||
|
||||
//
|
||||
// Configure I2C in Master Receiver mode
|
||||
//
|
||||
I2caRegs.I2CMDR.bit.MST = 0x1;
|
||||
I2caRegs.I2CMDR.bit.TRX = 0x0;
|
||||
|
||||
//
|
||||
//Set Data Count
|
||||
//
|
||||
//I2caRegs.I2CCNT = byteCount;
|
||||
|
||||
//
|
||||
// send Start condition
|
||||
//
|
||||
I2caRegs.I2CMDR.bit.STT = 0x1;
|
||||
|
||||
uint16_t count = 0;
|
||||
|
||||
//
|
||||
// Read the received data into RX buffer
|
||||
//
|
||||
while(count < I2C_NUMBYTES)
|
||||
{
|
||||
if(I2caRegs.I2CSTR.bit.RRDY ==0x1)
|
||||
{
|
||||
I2C_RXdata[count] = I2caRegs.I2CDRR.all;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Send STOP condition
|
||||
//
|
||||
if(sendStopCondition)
|
||||
{
|
||||
I2caRegs.I2CMDR.bit.STP = 0x1;
|
||||
while(I2caRegs.I2CMDR.bit.STP != 0x0);
|
||||
|
||||
I2caRegs.I2CSTR.bit.BYTESENT = 0x1;
|
||||
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
|
||||
@@ -0,0 +1,362 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: i2c_ex1_slave.c
|
||||
//
|
||||
// TITLE: I2C Example Slave.
|
||||
//
|
||||
//! \addtogroup bitfield_example_list
|
||||
//! <h1>I2C master slave communication using bit-field and without FIFO </h1>
|
||||
//!
|
||||
//! This program shows how to use I2CA in slave configuration.
|
||||
//! This example uses I2C interrupts and doesn't use FIFO.
|
||||
//!
|
||||
//! \b Requires two Control Cards - one configured as Master and other as Slave \n
|
||||
//! \b Master will run the binary generated from "i2c_ex1_master.projectspec" \n
|
||||
//! \b Slave will run the binary generated from "i2c_ex1_slave.projectspec" \n
|
||||
//! \b External \b Connections on Control Cards should be made as shown below \n
|
||||
//! --------------------------------------------------------------
|
||||
//! Signal | I2CA on Board1 | I2CA on Board 2
|
||||
//! -----------------------------------------------------------------
|
||||
//! SCL | GPIO_PIN_SCLA | GPIO_PIN_SCLA
|
||||
//! SDA | GPIO_PIN_SDAA | GPIO_PIN_SDAA
|
||||
//! GND | GND | GND
|
||||
//! ---------------------------------------------------------------
|
||||
//!
|
||||
//! \b Watch \b Variables in memory window\n
|
||||
//! - \b I2CA_TXdata
|
||||
//! - \b I2CA_RXdata
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define I2C_SLAVE_ADDR 0x6AU
|
||||
#define MAX_BUFFER_SIZE 0x10
|
||||
#define I2C_NUMBYTES 0x2U
|
||||
|
||||
//
|
||||
// I2C GPIO pins
|
||||
//
|
||||
#define GPIO_PIN_SDAA 26U // GPIO number for I2C SDAA
|
||||
#define GPIO_PIN_SCLA 27U // GPIO number for I2C SCLA
|
||||
//
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t I2C_TXdata[MAX_BUFFER_SIZE];
|
||||
uint16_t I2C_RXdata[MAX_BUFFER_SIZE];
|
||||
uint16_t PassCount=0x0, FailCount =0x0;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void I2CSlave_Init(uint16_t I2CSlave_OwnAddress);
|
||||
__interrupt void I2CISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Locals
|
||||
//
|
||||
uint16_t index = 0U;
|
||||
|
||||
//
|
||||
// Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Initialize GPIO
|
||||
//
|
||||
InitGpio();
|
||||
|
||||
//
|
||||
//Configure I2C pins
|
||||
//
|
||||
|
||||
GPIO_SetupPinMux(GPIO_PIN_SDAA, GPIO_MUX_CPU1, 11);
|
||||
GPIO_SetupPinOptions(GPIO_PIN_SDAA, GPIO_OUTPUT, GPIO_PULLUP);
|
||||
GPIO_SetupPinMux(GPIO_PIN_SCLA, GPIO_MUX_CPU1, 11);
|
||||
GPIO_SetupPinOptions(GPIO_PIN_SCLA, GPIO_OUTPUT, GPIO_PULLUP);
|
||||
|
||||
|
||||
//
|
||||
// .Initialize the PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR)
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Register the interrupt ISR
|
||||
//
|
||||
EALLOW; // This is needed to write to EALLOW protected registers
|
||||
PieVectTable.I2CA_INT = &I2CISR;
|
||||
EDIS; // This is needed to disable write to EALLOW protected registers
|
||||
|
||||
//
|
||||
// Enable Interrupts
|
||||
//
|
||||
PieCtrlRegs.PIEIER8.all = 0x1; // Enable PIE Group 8 INT8
|
||||
IER |= M_INT8; // Enable CPU INT8
|
||||
EINT; // Enable Global Interrupts
|
||||
|
||||
EnableInterrupts();
|
||||
|
||||
//
|
||||
// Set the buffer to some default non-zero value
|
||||
//
|
||||
for (index=0; index<MAX_BUFFER_SIZE;index++)
|
||||
{
|
||||
I2C_RXdata[index] = 0xBAADU;
|
||||
I2C_TXdata[index] = 0x11 * (index+1);
|
||||
}
|
||||
|
||||
|
||||
// Initialize I2C Module
|
||||
I2CSlave_Init(I2C_SLAVE_ADDR);
|
||||
|
||||
// Application loop
|
||||
while(1)
|
||||
{
|
||||
//respond to master commands
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Function to configure I2CA as Slave Receiver.
|
||||
//
|
||||
void I2CSlave_Init(uint16_t I2CSlave_OwnAddress)
|
||||
{
|
||||
|
||||
//
|
||||
// I2C configured as slave receiver mode
|
||||
//
|
||||
|
||||
EALLOW;
|
||||
//
|
||||
// Reset the I2C Module
|
||||
//
|
||||
I2caRegs.I2CMDR.all &= ~(0x20U);
|
||||
|
||||
//
|
||||
// Configure I2C as slave in Receive mode
|
||||
//
|
||||
I2caRegs.I2CMDR.bit.MST = 0x0U;
|
||||
I2caRegs.I2CMDR.bit.TRX = 0x0U;
|
||||
|
||||
//
|
||||
// Set the bit count to 8 bits per data byte
|
||||
//
|
||||
I2caRegs.I2CMDR.bit.BC = 0x0U;
|
||||
|
||||
//
|
||||
// Set emulation mode to FREE
|
||||
//
|
||||
I2caRegs.I2CMDR.bit.FREE = 0x1;
|
||||
|
||||
//
|
||||
// Configure I2C own address
|
||||
//
|
||||
I2caRegs.I2COAR.all = I2CSlave_OwnAddress; // Own address
|
||||
|
||||
//
|
||||
//Clear all status
|
||||
//
|
||||
I2caRegs.I2CSTR.all = 0xFFFF;
|
||||
|
||||
//
|
||||
// Enable I2C Interrupts- AAS, STOP, XRDY and RRDY
|
||||
//
|
||||
I2caRegs.I2CIER.all = 0x78;
|
||||
|
||||
//
|
||||
// Take I2C out of reset
|
||||
//
|
||||
I2caRegs.I2CMDR.all |= 0x0020;
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
|
||||
__interrupt void I2CISR(void)
|
||||
{
|
||||
//
|
||||
// Handle I2C interrupt
|
||||
//
|
||||
uint16_t IntSource, index=0U;
|
||||
static bool bDataReceived = false;
|
||||
static volatile uint16_t count = 0U;
|
||||
|
||||
//
|
||||
// Read Interrupt source
|
||||
//
|
||||
IntSource = I2caRegs.I2CISRC.all;
|
||||
|
||||
//
|
||||
// Interrupt source
|
||||
//
|
||||
if(IntSource == 0x7U) // AAS interrupt
|
||||
{
|
||||
if(I2caRegs.I2CSTR.bit.SDIR)
|
||||
{
|
||||
// Configure slave as transmitter
|
||||
I2caRegs.I2CMDR.bit.TRX = 0x1U;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Configure slave as receiver
|
||||
I2caRegs.I2CMDR.bit.TRX = 0x0U;
|
||||
|
||||
}
|
||||
}
|
||||
else if(IntSource == 0x6U) // STOP interrupt
|
||||
{
|
||||
//
|
||||
// Check if data has been received, then do a compare
|
||||
//
|
||||
if(bDataReceived)
|
||||
{
|
||||
bDataReceived = false;
|
||||
for(index=0; index < count; index++)
|
||||
{
|
||||
if(I2C_RXdata[index] == I2C_TXdata[index])
|
||||
{
|
||||
PassCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
FailCount++;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Reinitialize the RX buffer to non-zero
|
||||
//
|
||||
if(FailCount ==0)
|
||||
{
|
||||
for (index=0; index<count;index++)
|
||||
{
|
||||
I2C_RXdata[index] = 0xBAADU;
|
||||
}
|
||||
}
|
||||
count =0U;
|
||||
}
|
||||
}
|
||||
else if (IntSource == 0x4U) // RRDY interrupt
|
||||
{
|
||||
//
|
||||
// Read the received data into RX buffer
|
||||
//
|
||||
while(I2caRegs.I2CSTR.bit.RRDY!=0)
|
||||
{
|
||||
I2C_RXdata[count] = I2caRegs.I2CDRR.all;
|
||||
count++;
|
||||
//
|
||||
// set the data received flag to true to do a compare
|
||||
//
|
||||
bDataReceived = true;
|
||||
}
|
||||
|
||||
}
|
||||
else if (IntSource == 0x5U) // XRDY interrupt
|
||||
{
|
||||
|
||||
//
|
||||
//configure slave as transmitter
|
||||
//
|
||||
I2caRegs.I2CMDR.bit.TRX = 1;
|
||||
|
||||
//
|
||||
// Disable the interrupt till all the bytes are sent
|
||||
//
|
||||
I2caRegs.I2CIER.bit.XRDY = 0;
|
||||
//
|
||||
//transmit the bytes
|
||||
//
|
||||
for(index=0; index < I2C_NUMBYTES; index++)
|
||||
{
|
||||
I2caRegs.I2CDXR.all= I2C_TXdata[index];
|
||||
//
|
||||
//wait till byte is sent
|
||||
//
|
||||
while(I2caRegs.I2CSTR.bit.BYTESENT != 0x1);
|
||||
//
|
||||
//clear the byte sent
|
||||
//
|
||||
I2caRegs.I2CSTR.bit.BYTESENT = 0x1;
|
||||
}
|
||||
|
||||
//
|
||||
// Enable the interrupt after all the bytes are sent
|
||||
//
|
||||
I2caRegs.I2CIER.bit.XRDY = 1;
|
||||
}
|
||||
//
|
||||
// Clear the current interrupt and enable future I2C (PIE Group 8) interrupts
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="interrupt_ex1_external"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_combined_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../interrupt_ex1_external.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="interrupt_ex2_external_latency"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../interrupt_ex2_external_latency.c" targetDirectory="" />
|
||||
<file action="copy" path="../interrupt_ex2_external_latency_isr.asm" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,303 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: interrupt_ex1_external.c
|
||||
//
|
||||
// TITLE: External Interrupt test program.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1>External Interrupts (ExternalInterrupt)</h1>
|
||||
//!
|
||||
//! This program sets up GPIO0 as XINT1 and GPIO1 as XINT2. Two other
|
||||
//! GPIO signals are used to trigger the interrupt (GPIO30 triggers
|
||||
//! XINT1 and GPIO31 triggers XINT2). The user is required to
|
||||
//! externally connect these signals for the program to work
|
||||
//! properly.
|
||||
//!
|
||||
//! XINT1 input is synced to SYSCLKOUT.
|
||||
//!
|
||||
//! XINT2 has a long qualification - 6 samples at 510*SYSCLKOUT each.
|
||||
//!
|
||||
//! GPIO34 will go high outside of the interrupts and low within the
|
||||
//! interrupts. This signal can be monitored on a scope.
|
||||
//!
|
||||
//! Each interrupt is fired in sequence - XINT1 first and then XINT2
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - Connect GPIO30 to GPIO0. GPIO0 will be assigned to XINT1
|
||||
//! - Connect GPIO31 to GPIO1. GPIO1 will be assigned to XINT2
|
||||
//!
|
||||
//! Monitor GPIO34 with an oscilloscope. GPIO34 will be high outside of the
|
||||
//! ISRs and low within each ISR.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - Xint1Count for the number of times through XINT1 interrupt
|
||||
//! - Xint2Count for the number of times through XINT2 interrupt
|
||||
//! - LoopCount for the number of times through the idle loop
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define DELAY (CPU_RATE/1000*6*510) //Qual period at 6 samples
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
volatile Uint32 Xint1Count;
|
||||
volatile Uint32 Xint2Count;
|
||||
Uint32 LoopCount;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
interrupt void xint1_isr(void);
|
||||
interrupt void xint2_isr(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
Uint32 TempX1Count;
|
||||
Uint32 TempX2Count;
|
||||
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to its default state.
|
||||
//
|
||||
// InitGpio(); // Skipped for this example
|
||||
|
||||
//
|
||||
// Step 3. Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize PIE control registers to their default state.
|
||||
// The default state is all PIE interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU interrupts and clear all CPU interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
//
|
||||
EALLOW; // This is needed to write to EALLOW protected registers
|
||||
PieVectTable.XINT1_INT = &xint1_isr;
|
||||
PieVectTable.XINT2_INT = &xint2_isr;
|
||||
EDIS; // This is needed to disable write to EALLOW protected registers
|
||||
|
||||
//
|
||||
// Step 4. User specific code, enable interrupts:
|
||||
//
|
||||
// Clear the counters
|
||||
//
|
||||
Xint1Count = 0; // Count XINT1 interrupts
|
||||
Xint2Count = 0; // Count XINT2 interrupts
|
||||
LoopCount = 0; // Count times through idle loop
|
||||
|
||||
//
|
||||
// Enable XINT1 and XINT2 in the PIE: Group 1 interrupt 4 & 5
|
||||
// Enable INT1 which is connected to WAKEINT:
|
||||
//
|
||||
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
|
||||
PieCtrlRegs.PIEIER1.bit.INTx4 = 1; // Enable PIE Group 1 INT4
|
||||
PieCtrlRegs.PIEIER1.bit.INTx5 = 1; // Enable PIE Group 1 INT5
|
||||
IER |= M_INT1; // Enable CPU INT1
|
||||
EINT; // Enable Global Interrupts
|
||||
|
||||
//
|
||||
// GPIO30 & GPIO31 are outputs, start GPIO30 high and GPIO31 low
|
||||
//
|
||||
EALLOW;
|
||||
GpioDataRegs.GPASET.bit.GPIO30 = 1; // Load the output latch
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 0; // GPIO
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO30 = 1; // output
|
||||
|
||||
GpioDataRegs.GPACLEAR.bit.GPIO31 = 1; // Load the output latch
|
||||
GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 0; // GPIO
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO31 = 1; // output
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// GPIO0 and GPIO1 are inputs
|
||||
//
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0; // GPIO
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO0 = 0; // input
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO0 = 0; // XINT1 Synch to SYSCLKOUT only
|
||||
|
||||
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0; // GPIO
|
||||
GpioCtrlRegs.GPADIR.bit.GPIO1 = 0; // input
|
||||
GpioCtrlRegs.GPAQSEL1.bit.GPIO1 = 2; // XINT2 Qual using 6 samples
|
||||
GpioCtrlRegs.GPACTRL.bit.QUALPRD0 = 0xFF; // Each sampling window
|
||||
// is 510*SYSCLKOUT
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// GPIO0 is XINT1, GPIO1 is XINT2
|
||||
//
|
||||
GPIO_SetupXINT1Gpio(0);
|
||||
GPIO_SetupXINT2Gpio(1);
|
||||
|
||||
//
|
||||
// Configure XINT1
|
||||
//
|
||||
XintRegs.XINT1CR.bit.POLARITY = 0; // Falling edge interrupt
|
||||
XintRegs.XINT2CR.bit.POLARITY = 1; // Rising edge interrupt
|
||||
|
||||
//
|
||||
// Enable XINT1 and XINT2
|
||||
//
|
||||
XintRegs.XINT1CR.bit.ENABLE = 1; // Enable XINT1
|
||||
XintRegs.XINT2CR.bit.ENABLE = 1; // Enable XINT2
|
||||
|
||||
//
|
||||
// GPIO34 will go low inside each interrupt. Monitor this on a scope
|
||||
//
|
||||
EALLOW;
|
||||
GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // GPIO
|
||||
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // output
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Step 5. IDLE loop:
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
TempX1Count = Xint1Count;
|
||||
TempX2Count = Xint2Count;
|
||||
|
||||
//
|
||||
// Trigger both XINT1
|
||||
//
|
||||
GpioDataRegs.GPBSET.bit.GPIO34 = 1; // GPIO34 is high
|
||||
GpioDataRegs.GPACLEAR.bit.GPIO30 = 1; // Lower GPIO30, trigger XINT1
|
||||
while(Xint1Count == TempX1Count) {}
|
||||
|
||||
//
|
||||
// Trigger both XINT2
|
||||
//
|
||||
GpioDataRegs.GPBSET.bit.GPIO34 = 1; // GPIO34 is high
|
||||
DELAY_US(DELAY); // Wait for Qual period
|
||||
GpioDataRegs.GPASET.bit.GPIO31 = 1; // Raise GPIO31, trigger XINT2
|
||||
while(Xint2Count == TempX2Count) {}
|
||||
|
||||
//
|
||||
// Check that the counts were incremented properly and get ready
|
||||
// to start over.
|
||||
//
|
||||
if((Xint1Count == TempX1Count + 1) && (Xint2Count == TempX2Count + 1))
|
||||
{
|
||||
LoopCount++;
|
||||
GpioDataRegs.GPASET.bit.GPIO30 = 1; // raise GPIO30
|
||||
GpioDataRegs.GPACLEAR.bit.GPIO31 = 1; // lower GPIO31
|
||||
}
|
||||
else
|
||||
{
|
||||
asm(" ESTOP0"); // stop here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// xint1_isr - External Interrupt 1 ISR
|
||||
//
|
||||
interrupt void xint1_isr(void)
|
||||
{
|
||||
GpioDataRegs.GPBCLEAR.all = 0x4; // GPIO34 is low
|
||||
Xint1Count++;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to get more from group 1
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
}
|
||||
|
||||
//
|
||||
// xint2_isr - External Interrupt 2 ISR
|
||||
//
|
||||
interrupt void xint2_isr(void)
|
||||
{
|
||||
GpioDataRegs.GPBCLEAR.all = 0x4; // GPIO34 is low
|
||||
Xint2Count++;
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to get more from group 1
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
+329
@@ -0,0 +1,329 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: interrupt_ex2_external_latency.c
|
||||
//
|
||||
// TITLE: External Interrupt Latency test program.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1>External Interrupts Latency (ExternalInterruptLatency)</h1>
|
||||
//!
|
||||
//! This program triggers external interrupts when GPIO16 is pulled low. GPIO10
|
||||
//! can be used to do this, or an external signal generator can be connected.
|
||||
//! GPIO19 will toggle when the interrupt is entered. A global variable
|
||||
//! (isrType) can be modified at run time to switch between C and assembly ISRs
|
||||
//! running out of RAM (0-wait state) or flash (3-wait states).
|
||||
//!
|
||||
//! Measured delays from GPIO16 falling to GPIO19 rising at SYSCLK=200 MHz:
|
||||
//!
|
||||
//! ISR Delay Cycles \n
|
||||
//! --------------------------- \n
|
||||
//! ASM/RAM 125ns 25 \n
|
||||
//! ASM/Flash 135ns 27 \n
|
||||
//! C/RAM 145ns 29 \n
|
||||
//! C/Flash 155ns 31 \n
|
||||
//!
|
||||
//! Some of the delay is due to the rise and fall times of the IOs. To see
|
||||
//! this, reduce SYSCLK to less than 75 MHz. Under that condition, the ASM/RAM
|
||||
//! delay is 23 cycles, which is close to the theoretical minimum latency of
|
||||
//! 16 cycles.
|
||||
//!
|
||||
//! The extra delay in the flash ISRs is due to the wait states. The extra
|
||||
//! delay in the C ISRs is due to two CLRC instructions that are generated to
|
||||
//! make sure the address and overflow modes match the normal C environment.
|
||||
//! With optimization enabled (-O1 and above), these instructions are removed.
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define CPU_FREQ_MHZ 200ul
|
||||
|
||||
//
|
||||
// Typedefs
|
||||
//
|
||||
|
||||
//
|
||||
// The XINT ISR can be switched at run time to observe the timing differences
|
||||
// between flash, RAM, C, and assembly.
|
||||
//
|
||||
typedef enum
|
||||
{
|
||||
ISR_C_RAM,
|
||||
ISR_C_FLASH,
|
||||
ISR_ASM_RAM,
|
||||
ISR_ASM_FLASH
|
||||
} eIsrType;
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
volatile eIsrType isrType;
|
||||
volatile Uint16 timerFlag;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
interrupt void XINT_C_ISR_RAM(void);
|
||||
interrupt void XINT_C_ISR_FLASH(void);
|
||||
extern interrupt void XINT_ASM_ISR_RAM(void);
|
||||
extern interrupt void XINT_ASM_ISR_FLASH(void);
|
||||
interrupt void TIMER_ISR(void);
|
||||
void WaitLoopFlash(void);
|
||||
void WaitLoopRam(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize system control: PLL, watchdog, and peripheral clocks.
|
||||
// This also copies the RAM functions to RAM.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Disable interrupts and initialize the PIE vector table and CPU interrupt
|
||||
// mask
|
||||
//
|
||||
DINT;
|
||||
InitPieCtrl();
|
||||
InitPieVectTable();
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize and configure the GPIO pins. GPIO16 will be used as the XINT
|
||||
// input. GPIO10 will be a push-pull output that toggles low once per
|
||||
// millisecond. GPIO19 will toggle to indicate ISR entry.
|
||||
//
|
||||
InitGpio();
|
||||
GPIO_SetupPinMux(16, GPIO_MUX_CPU1, 0x0);
|
||||
GPIO_SetupPinOptions(16, GPIO_INPUT, GPIO_PULLUP);
|
||||
GPIO_SetupPinMux(10, GPIO_MUX_CPU1, 0x0);
|
||||
GPIO_SetupPinOptions(10, GPIO_OUTPUT, GPIO_PUSHPULL);
|
||||
GPIO_SetupPinMux(19, GPIO_MUX_CPU1, 0x0);
|
||||
GPIO_SetupPinOptions(19, GPIO_OUTPUT, GPIO_PUSHPULL);
|
||||
|
||||
//
|
||||
// Turn on XCLKOUT on GPIO73
|
||||
//
|
||||
GPIO_SetupPinMux(73, GPIO_MUX_CPU1, 0x3);
|
||||
EALLOW;
|
||||
ClkCfgRegs.CLKSRCCTL3.bit.XCLKOUTSEL = 0;
|
||||
ClkCfgRegs.XCLKOUTDIVSEL.all = 0;
|
||||
|
||||
//
|
||||
// Set the initial GPIO states
|
||||
//
|
||||
GpioDataRegs.GPASET.bit.GPIO10 = 1;
|
||||
GpioDataRegs.GPACLEAR.bit.GPIO19 = 1;
|
||||
|
||||
//
|
||||
// Enable the XINT1 interrupt on PIE channel 1.4 and the Timer0 interrupt
|
||||
// on PIE channel 1.7.
|
||||
//
|
||||
EALLOW;
|
||||
isrType = ISR_ASM_RAM;
|
||||
|
||||
//
|
||||
// Write an XINT1 ISR to the PIE vector table
|
||||
//
|
||||
PieVectTable.XINT1_INT = &XINT_ASM_ISR_RAM;
|
||||
|
||||
//
|
||||
// Write the Timer0 ISR to the PIE vector table
|
||||
//
|
||||
PieVectTable.TIMER0_INT = &TIMER_ISR;
|
||||
|
||||
PieCtrlRegs.PIEIER1.bit.INTx4 = 1; // Enable PIE channel 1.4
|
||||
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // Enable PIE channel 1.7
|
||||
EDIS;
|
||||
IER |= M_INT1; // Enable CPU interrupt group 1
|
||||
|
||||
//
|
||||
// Set up XINT1 to trigger on a falling edge on GPIO16
|
||||
//
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Select GPIO16 as the source for input XBAR channel 4 (XINT1)
|
||||
//
|
||||
InputXbarRegs.INPUT4SELECT = 16;
|
||||
|
||||
XintRegs.XINT1CR.bit.POLARITY = 0; // Trigger XINT1 on a falling edge
|
||||
XintRegs.XINT1CR.bit.ENABLE = 1; // Enable XINT1
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Set up CPU Timer0 to trigger an interrupt once per millisecond
|
||||
//
|
||||
timerFlag = 0;
|
||||
|
||||
EALLOW;
|
||||
CpuTimer0Regs.TCR.bit.TSS = 1;
|
||||
CpuTimer0Regs.PRD.all = 1000ul * CPU_FREQ_MHZ;
|
||||
CpuTimer0Regs.TPR.bit.TDDR = 0;
|
||||
CpuTimer0Regs.TPRH.bit.TDDRH = 0;
|
||||
|
||||
//
|
||||
// Enable the interrupt and reset and start the timer
|
||||
//
|
||||
CpuTimer0Regs.TCR.all = 0x4020;
|
||||
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Enable CPU interrupts
|
||||
//
|
||||
EINT;
|
||||
|
||||
//
|
||||
// Wait for an interrupt
|
||||
//
|
||||
while (1)
|
||||
{
|
||||
if (timerFlag)
|
||||
{
|
||||
//
|
||||
// One tick per millisecond is slow enough that we don't need to
|
||||
// worry about disabling interrupts here.
|
||||
//
|
||||
timerFlag = 0;
|
||||
|
||||
//
|
||||
// Switch the ISR type
|
||||
//
|
||||
EALLOW;
|
||||
switch (isrType)
|
||||
{
|
||||
case ISR_C_RAM:
|
||||
PieVectTable.XINT1_INT = &XINT_C_ISR_RAM;
|
||||
break;
|
||||
case ISR_C_FLASH:
|
||||
PieVectTable.XINT1_INT = &XINT_C_ISR_FLASH;
|
||||
break;
|
||||
case ISR_ASM_RAM:
|
||||
PieVectTable.XINT1_INT = &XINT_ASM_ISR_RAM;
|
||||
break;
|
||||
case ISR_ASM_FLASH:
|
||||
PieVectTable.XINT1_INT = &XINT_ASM_ISR_FLASH;
|
||||
break;
|
||||
}
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Drive GPIO10 low to trigger the XINT. Wait until after the
|
||||
// interrupt is serviced to release GPIO10 again.
|
||||
//
|
||||
GpioDataRegs.GPACLEAR.bit.GPIO10 = 1;
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
asm(" NOP");
|
||||
GpioDataRegs.GPASET.bit.GPIO10 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// XINT1 interrupt handlers. Both of these toggle GPIO19.
|
||||
//
|
||||
|
||||
//
|
||||
// XINT_C_ISR_RAM - This copy of the function runs out of RAM with zero wait
|
||||
// states. The delay from GPIO16 going low to GPIO19 going high was measured
|
||||
// as 145 nanoseconds, which is 29 cycles at 200 MHz.
|
||||
//
|
||||
#pragma CODE_SECTION(XINT_C_ISR_RAM, ".TI.ramfunc")
|
||||
interrupt void
|
||||
XINT_C_ISR_RAM(void)
|
||||
{
|
||||
GpioDataRegs.GPATOGGLE.bit.GPIO19 = 1;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
GpioDataRegs.GPATOGGLE.bit.GPIO19 = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// XINT_C_ISR_FLASH - This copy of the function runs out of flash with three
|
||||
// wait states. The delay from GPIO16 going low to GPIO19 going high was
|
||||
// measured as 155 nanoseconds, which is 31 cycles at 200 MHz.
|
||||
//
|
||||
interrupt void
|
||||
XINT_C_ISR_FLASH(void)
|
||||
{
|
||||
GpioDataRegs.GPATOGGLE.bit.GPIO19 = 1;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
GpioDataRegs.GPATOGGLE.bit.GPIO19 = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// TIMER_ISR - Timer0 interrupt handler. Tells the main loop to pull GPIO10
|
||||
// low.
|
||||
//
|
||||
interrupt void
|
||||
TIMER_ISR(void)
|
||||
{
|
||||
timerFlag = 1;
|
||||
//GpioDataRegs.GPATOGGLE.bit.GPIO19 = 1;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
;******************************************************************************
|
||||
; FILE: interrupt_ex2_external_latency_isr.asm
|
||||
;
|
||||
; DESCRIPTION: External Interrupts in assembly
|
||||
;
|
||||
;//###########################################################################
|
||||
;//
|
||||
;//
|
||||
;//
|
||||
;// C2000Ware v5.04.00.00
|
||||
;//Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
;//
|
||||
;// Redistribution and use in source and binary forms, with or without
|
||||
;// modification, are permitted provided that the following conditions
|
||||
;// are met:
|
||||
;//
|
||||
;// Redistributions of source code must retain the above copyright
|
||||
;// notice, this list of conditions and the following disclaimer.
|
||||
;//
|
||||
;// Redistributions in binary form must reproduce the above copyright
|
||||
;// notice, this list of conditions and the following disclaimer in the
|
||||
;// documentation and/or other materials provided with the
|
||||
;// distribution.
|
||||
;//
|
||||
;// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
;// its contributors may be used to endorse or promote products derived
|
||||
;// from this software without specific prior written permission.
|
||||
;//
|
||||
;// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
;// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
;// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
;// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
;// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
;// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
;// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
;// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
;// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
;// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
;// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;// $
|
||||
;//###########################################################################
|
||||
|
||||
; XINT interrupts in assembly. These are tweaked for the shortest possible
|
||||
; response time. Both of them toggle GPIO19. These only save a couple cycles vs.
|
||||
; their C equivalents.
|
||||
.if __TI_EABI__
|
||||
.asg XINT_ASM_ISR_RAM, _XINT_ASM_ISR_RAM
|
||||
.asg XINT_ASM_ISR_FLASH, _XINT_ASM_ISR_FLASH
|
||||
.endif
|
||||
.global _XINT_ASM_ISR_RAM
|
||||
.global _XINT_ASM_ISR_FLASH
|
||||
|
||||
;This copy of the function runs out of RAM with zero wait states. The delay
|
||||
;from GPIO16 going low to GPIO19 going high was measured as
|
||||
;125 nanoseconds, which is 25 cycles at 200 MHz.
|
||||
.sect ".TI.ramfunc"
|
||||
_XINT_ASM_ISR_RAM:
|
||||
ASP ;Align stack pointer. Real ISRs will probably need this.
|
||||
MOVZ DP, #7f00h >> 6 ;Load DP with the GPIO data registers' base address (0x7f00)
|
||||
MOV @7h, #0008h ;Set bit 19 of GPATOGGLE (address 0x7f06)
|
||||
MOVZ DP, #0cc0h >> 6 ;Load DP with a value close to the PIEACK address (0xcc0).
|
||||
;We can't use the PIE base address of 0xce0 because the
|
||||
;0x20 bit gets dropped during the right-shift.
|
||||
MOV @21h, #0001h ;Write to PIEACK to re-enable the interrupt group
|
||||
NASP ;Unalign stack pointer. Again, this is only here for realism.
|
||||
MOVZ DP, #7f00h >> 6 ;Load DP with the GPIO data registers' base address (0x7f00)
|
||||
MOV @7h, #0008h ;Set bit 19 of GPATOGGLE (address 0x7f06)
|
||||
IRET ;Return from the interrupt
|
||||
|
||||
;This copy of the function runs out of flash with three wait states. It's
|
||||
;aligned to an 8-word (128-bit) boundary so that the first several
|
||||
;instructions will be in a single flash word. The delay from GPIO16 going
|
||||
;low to GPIO19 going high was measured as 135 nanoseconds, which is
|
||||
;27 cycles at 200 MHz.
|
||||
.sect ".text"
|
||||
.align 8
|
||||
_XINT_ASM_ISR_FLASH:
|
||||
ASP ;Align stack pointer. Real ISRs will probably need this.
|
||||
MOVZ DP, #7f00h >> 6 ;Load DP with the GPIO data registers' base address
|
||||
MOV @7h, #0008h ;Set bit 19 of GPATOGGLE (address 0x7f06)
|
||||
MOVZ DP, #0cc0h >> 6 ;Load DP with a value close to the PIEACK address (0xcc0).
|
||||
;We can't use the PIE base address of 0xce0 because the
|
||||
;0x20 bit gets dropped during the right-shift.
|
||||
MOV @21h, #0001h ;Write to PIEACK to re-enable the interrupt group
|
||||
NASP ;Unalign stack pointer. Again, this is only here for realism.
|
||||
MOVZ DP, #7f00h >> 6 ;Load DP with the GPIO data registers' base address (0x7f00)
|
||||
MOV @7h, #0008h ;Set bit 19 of GPATOGGLE (address 0x7f06)
|
||||
IRET ;Return from the interrupt
|
||||
|
||||
;//===========================================================================
|
||||
;// End of file.
|
||||
;//===========================================================================
|
||||
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="led_ex1_blinky"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --cla_background_task=on --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_cputimers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_epwm.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../led_ex1_blinky.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,133 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: led_ex1_blinky.c
|
||||
//
|
||||
// TITLE: LED Blinky Example
|
||||
//
|
||||
//! \addtogroup bitfield_example_list
|
||||
//! <h1> LED Blinky Example </h1>
|
||||
//!
|
||||
//! This example demonstrates how to blink a LED.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - None.
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define DEVICE_GPIO_PIN_LED1 31
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure the GPIO pin as a push-pull output
|
||||
//
|
||||
InitGpio();
|
||||
GPIO_SetupPinMux(DEVICE_GPIO_PIN_LED1, GPIO_MUX_CPU1, 0);
|
||||
GPIO_SetupPinOptions(DEVICE_GPIO_PIN_LED1, GPIO_OUTPUT, GPIO_PUSHPULL);
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
DINT;
|
||||
InitPieCtrl();
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop Forever
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Turn on LED
|
||||
//
|
||||
GPIO_WritePin(DEVICE_GPIO_PIN_LED1, 0);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DELAY_US(500000);
|
||||
|
||||
//
|
||||
// Turn off LED
|
||||
//
|
||||
GPIO_WritePin(DEVICE_GPIO_PIN_LED1, 1);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DELAY_US(500000);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
Binary file not shown.
@@ -0,0 +1,31 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="sci_ex1_echoback"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../sci_ex1_echoback.c" targetDirectory="" />
|
||||
<file action="copy" path="../f2838x_pinmux.c" targetDirectory="" />
|
||||
<file action="copy" path="../f2838x_pinmux.h" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,150 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// f2838x_pinmux.c - Function to write the generated pin mux values to the
|
||||
// appropriate registers.
|
||||
// Created using TI Pinmux 1.0.658 on 2/27/2019 at 10:15:05 AM.
|
||||
//
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
//
|
||||
// NOTE!! This file uses bit field structures and macros from C2000Ware.
|
||||
// This function is provided for your convenience and to serve as an example
|
||||
// of the use of the generated header file, but its use is not required.
|
||||
//
|
||||
// To download C2000Ware: http://www.ti.com/tool/C2000Ware
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include "f28x_project.h"
|
||||
#include "f2838x_pinmux.h"
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Configures the pin mux registers, using the generated register values.
|
||||
//
|
||||
// This function writes the values generated by the pin mux tool to their
|
||||
// corresponding GPIO control registers. These generated values should be found
|
||||
// in the generated "f2838x_pinmux.h."
|
||||
//
|
||||
//*****************************************************************************
|
||||
void
|
||||
GPIO_setPinMuxConfig(void)
|
||||
{
|
||||
Uint32 lockValA;
|
||||
Uint32 lockValB;
|
||||
Uint32 lockValC;
|
||||
Uint32 lockValD;
|
||||
Uint32 lockValE;
|
||||
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Save the current value of the GPIO lock registers
|
||||
//
|
||||
lockValA = GpioCtrlRegs.GPALOCK.all;
|
||||
lockValB = GpioCtrlRegs.GPBLOCK.all;
|
||||
lockValC = GpioCtrlRegs.GPCLOCK.all;
|
||||
lockValD = GpioCtrlRegs.GPDLOCK.all;
|
||||
lockValE = GpioCtrlRegs.GPELOCK.all;
|
||||
|
||||
//
|
||||
// Unlock the GPIO control registers
|
||||
//
|
||||
GpioCtrlRegs.GPALOCK.all = 0x00000000;
|
||||
GpioCtrlRegs.GPBLOCK.all = 0x00000000;
|
||||
GpioCtrlRegs.GPCLOCK.all = 0x00000000;
|
||||
GpioCtrlRegs.GPDLOCK.all = 0x00000000;
|
||||
GpioCtrlRegs.GPELOCK.all = 0x00000000;
|
||||
|
||||
//
|
||||
// Clear the mux register fields that are about to be changed
|
||||
//
|
||||
GpioCtrlRegs.GPAGMUX1.all &= ~GPAMUX1_MASK;
|
||||
GpioCtrlRegs.GPAGMUX2.all &= ~GPAMUX2_MASK;
|
||||
GpioCtrlRegs.GPAMUX1.all &= ~GPAMUX1_MASK;
|
||||
GpioCtrlRegs.GPAMUX2.all &= ~GPAMUX2_MASK;
|
||||
GpioCtrlRegs.GPBGMUX1.all &= ~GPBMUX1_MASK;
|
||||
GpioCtrlRegs.GPBGMUX2.all &= ~GPBMUX2_MASK;
|
||||
GpioCtrlRegs.GPBMUX1.all &= ~GPBMUX1_MASK;
|
||||
GpioCtrlRegs.GPBMUX2.all &= ~GPBMUX2_MASK;
|
||||
GpioCtrlRegs.GPCGMUX1.all &= ~GPCMUX1_MASK;
|
||||
GpioCtrlRegs.GPCGMUX2.all &= ~GPCMUX2_MASK;
|
||||
GpioCtrlRegs.GPCMUX1.all &= ~GPCMUX1_MASK;
|
||||
GpioCtrlRegs.GPCMUX2.all &= ~GPCMUX2_MASK;
|
||||
GpioCtrlRegs.GPDGMUX1.all &= ~GPDMUX1_MASK;
|
||||
GpioCtrlRegs.GPDGMUX2.all &= ~GPDMUX2_MASK;
|
||||
GpioCtrlRegs.GPDMUX1.all &= ~GPDMUX1_MASK;
|
||||
GpioCtrlRegs.GPDMUX2.all &= ~GPDMUX2_MASK;
|
||||
GpioCtrlRegs.GPEGMUX1.all &= ~GPEMUX1_MASK;
|
||||
GpioCtrlRegs.GPEMUX1.all &= ~GPEMUX1_MASK;
|
||||
|
||||
//
|
||||
// Write pin muxing to mux registers
|
||||
//
|
||||
GpioCtrlRegs.GPAGMUX1.all |= GPAGMUX1_VALUE;
|
||||
GpioCtrlRegs.GPAGMUX2.all |= GPAGMUX2_VALUE;
|
||||
GpioCtrlRegs.GPAMUX1.all |= GPAMUX1_VALUE;
|
||||
GpioCtrlRegs.GPAMUX2.all |= GPAMUX2_VALUE;
|
||||
GpioCtrlRegs.GPBGMUX1.all |= GPBGMUX1_VALUE;
|
||||
GpioCtrlRegs.GPBGMUX2.all |= GPBGMUX2_VALUE;
|
||||
GpioCtrlRegs.GPBMUX1.all |= GPBMUX1_VALUE;
|
||||
GpioCtrlRegs.GPBMUX2.all |= GPBMUX2_VALUE;
|
||||
GpioCtrlRegs.GPCGMUX1.all |= GPCGMUX1_VALUE;
|
||||
GpioCtrlRegs.GPCGMUX2.all |= GPCGMUX2_VALUE;
|
||||
GpioCtrlRegs.GPCMUX1.all |= GPCMUX1_VALUE;
|
||||
GpioCtrlRegs.GPCMUX2.all |= GPCMUX2_VALUE;
|
||||
GpioCtrlRegs.GPDGMUX1.all |= GPDGMUX1_VALUE;
|
||||
GpioCtrlRegs.GPDGMUX2.all |= GPDGMUX2_VALUE;
|
||||
GpioCtrlRegs.GPDMUX1.all |= GPDMUX1_VALUE;
|
||||
GpioCtrlRegs.GPDMUX2.all |= GPDMUX2_VALUE;
|
||||
GpioCtrlRegs.GPEGMUX1.all |= GPEGMUX1_VALUE;
|
||||
GpioCtrlRegs.GPEMUX1.all |= GPEMUX1_VALUE;
|
||||
|
||||
//
|
||||
// Write pin analog mode select to registers
|
||||
//
|
||||
GpioCtrlRegs.GPBAMSEL.all &= ~GPBAMSEL_MASK;
|
||||
GpioCtrlRegs.GPBAMSEL.all |= GPBAMSEL_VALUE;
|
||||
|
||||
//
|
||||
// Restore GPIO lock register values
|
||||
//
|
||||
GpioCtrlRegs.GPALOCK.all = lockValA;
|
||||
GpioCtrlRegs.GPBLOCK.all = lockValB;
|
||||
GpioCtrlRegs.GPCLOCK.all = lockValC;
|
||||
GpioCtrlRegs.GPDLOCK.all = lockValD;
|
||||
GpioCtrlRegs.GPELOCK.all = lockValE;
|
||||
|
||||
EDIS;
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
//*****************************************************************************
|
||||
//
|
||||
// f2838x_pinmux.h - Created using TI Pinmux 1.0.658 on 2/27/2019 at 10:15:09 AM.
|
||||
//
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//*****************************************************************************
|
||||
//
|
||||
// These values will provide the functionality requested when written into
|
||||
// the registers for which the #defines are named. For example, using the
|
||||
// C2000Ware device support header files, use the defines like in this
|
||||
// sample function:
|
||||
//
|
||||
// void samplePinMuxFxn(void)
|
||||
// {
|
||||
// EALLOW;
|
||||
// //
|
||||
// // Write generated values to mux registers
|
||||
// //
|
||||
// GpioCtrlRegs.GPAMUX1.all = GPAMUX1_VALUE;
|
||||
// GpioCtrlRegs.GPAMUX2.all = GPAMUX2_VALUE;
|
||||
// GpioCtrlRegs.GPBMUX1.all = GPBMUX1_VALUE;
|
||||
// . . .
|
||||
// EDIS;
|
||||
// }
|
||||
//
|
||||
// NOTE: These GPIO control registers are only available on CPU1.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
//
|
||||
// Port A mux register values
|
||||
//
|
||||
// Pin 64 (GPIO28) to SCIA_RX (mode 1)
|
||||
// Pin 65 (GPIO29) to SCIA_TX (mode 1)
|
||||
#define GPAMUX1_MASK 0x00000000
|
||||
#define GPAMUX2_MASK 0x0f000000
|
||||
#define GPAMUX1_VALUE 0x00000000
|
||||
#define GPAMUX2_VALUE 0x05000000
|
||||
#define GPAGMUX1_VALUE 0x00000000
|
||||
#define GPAGMUX2_VALUE 0x00000000
|
||||
|
||||
//
|
||||
// Port B mux register values
|
||||
//
|
||||
#define GPBMUX1_MASK 0x00000000
|
||||
#define GPBMUX2_MASK 0x00000000
|
||||
#define GPBMUX1_VALUE 0x00000000
|
||||
#define GPBMUX2_VALUE 0x00000000
|
||||
#define GPBGMUX1_VALUE 0x00000000
|
||||
#define GPBGMUX2_VALUE 0x00000000
|
||||
|
||||
//
|
||||
// Port C mux register values
|
||||
//
|
||||
#define GPCMUX1_MASK 0x00000000
|
||||
#define GPCMUX2_MASK 0x00000000
|
||||
#define GPCMUX1_VALUE 0x00000000
|
||||
#define GPCMUX2_VALUE 0x00000000
|
||||
#define GPCGMUX1_VALUE 0x00000000
|
||||
#define GPCGMUX2_VALUE 0x00000000
|
||||
|
||||
//
|
||||
// Port D mux register values
|
||||
//
|
||||
#define GPDMUX1_MASK 0x00000000
|
||||
#define GPDMUX2_MASK 0x00000000
|
||||
#define GPDMUX1_VALUE 0x00000000
|
||||
#define GPDMUX2_VALUE 0x00000000
|
||||
#define GPDGMUX1_VALUE 0x00000000
|
||||
#define GPDGMUX2_VALUE 0x00000000
|
||||
|
||||
//
|
||||
// Port E mux register values
|
||||
//
|
||||
#define GPEMUX1_MASK 0x00000000
|
||||
#define GPEMUX1_VALUE 0x00000000
|
||||
#define GPEGMUX1_VALUE 0x00000000
|
||||
|
||||
//
|
||||
// Port B analog mode register values
|
||||
//
|
||||
#define GPBAMSEL_MASK 0x00000000
|
||||
#define GPBAMSEL_VALUE 0x00000000
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// Function prototype for function to write values above into their
|
||||
// corresponding registers. This function is found in f2838x_pinmux.c. Its use
|
||||
// is completely optional.
|
||||
//
|
||||
//*****************************************************************************
|
||||
extern void GPIO_setPinMuxConfig(void);
|
||||
@@ -0,0 +1,290 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: sci_ex1_echoback.c
|
||||
//
|
||||
// TITLE: SCI Echoback.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1>SCI Echoback (sci_echoback)</h1>
|
||||
//!
|
||||
//! This test receives and echo-backs data through the SCI-A port.
|
||||
//!
|
||||
//! The PC application 'hyperterminal' or another terminal
|
||||
//! such as 'putty' can be used to view the data from the SCI and
|
||||
//! to send information to the SCI. Characters received
|
||||
//! by the SCI port are sent back to the host.
|
||||
//!
|
||||
//! \b Running \b the \b Application
|
||||
//! -# Configure hyperterminal or another terminal such as putty:
|
||||
//!
|
||||
//! For hyperterminal you can use the included hyperterminal configuration
|
||||
//! file SCI_96.ht.
|
||||
//! To load this configuration in hyperterminal
|
||||
//! -# Open hyperterminal
|
||||
//! -# Go to file->open
|
||||
//! -# Browse to the location of the project and
|
||||
//! select the SCI_96.ht file.
|
||||
//! -# Check the COM port.
|
||||
//! The configuration file is currently setup for COM1.
|
||||
//! If this is not correct, disconnect (Call->Disconnect)
|
||||
//! Open the File-Properties dialogue and select the correct COM port.
|
||||
//! -# Connect hyperterminal Call->Call
|
||||
//! and then start the 2838x SCI echoback program execution.
|
||||
//! -# The program will print out a greeting and then ask you to
|
||||
//! enter a character which it will echo back to hyperterminal.
|
||||
//!
|
||||
//! \note If you are unable to open the .ht file, or you are using
|
||||
//! a different terminal, you can open a COM port with the following settings
|
||||
//! - Find correct COM port
|
||||
//! - Bits per second = 9600
|
||||
//! - Date Bits = 8
|
||||
//! - Parity = None
|
||||
//! - Stop Bits = 1
|
||||
//! - Hardware Control = None
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - LoopCount - the number of characters sent
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! Connect the SCI-A port to a PC via a transceiver and cable.
|
||||
//! - GPIO28 is SCI_A-RXD (Connect to Pin3, PC-TX, of serial DB9 cable)
|
||||
//! - GPIO29 is SCI_A-TXD (Connect to Pin2, PC-RX, of serial DB9 cable)
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "f2838x_pinmux.h"
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 LoopCount;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void scia_echoback_init(void);
|
||||
void scia_fifo_init(void);
|
||||
void scia_xmit(int a);
|
||||
void scia_msg(char *msg);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
Uint16 ReceivedChar;
|
||||
char *msg;
|
||||
|
||||
//
|
||||
// Step 1. Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Step 2. Initialize GPIO:
|
||||
// This example function is found in the f2838x_gpio.c file and
|
||||
// illustrates how to set the GPIO to it's default state.
|
||||
//
|
||||
InitGpio();
|
||||
|
||||
//
|
||||
// For this example, only init the pins for the SCI-A port.
|
||||
// GPIO_SetupPinMux() - Sets the GPxMUX1/2 and GPyMUX1/2 register bits
|
||||
// GPIO_SetupPinOptions() - Sets the direction and configuration of the GPIOS
|
||||
// These functions are found in the f2838x_gpio.c file.
|
||||
//
|
||||
GPIO_SetupPinMux(28, GPIO_MUX_CPU1, 1);
|
||||
GPIO_SetupPinOptions(28, GPIO_INPUT, GPIO_PUSHPULL);
|
||||
GPIO_SetupPinMux(29, GPIO_MUX_CPU1, 1);
|
||||
GPIO_SetupPinOptions(29, GPIO_OUTPUT, GPIO_ASYNC);
|
||||
|
||||
//
|
||||
// An alternate to setting up the pin mux through multiple functions would be
|
||||
// to use the pinmux tool to generate the configurations needed for pin muxing.
|
||||
// In that case, uncomment the below code and comment the above 4 lines of code.
|
||||
// For more details on the API configuration, please check the f2838x_pinmux.c and
|
||||
// f2838x_pinmux.h files.
|
||||
//
|
||||
// GPIO_setPinMuxConfig();
|
||||
//
|
||||
|
||||
//
|
||||
// Step 3. Clear all __interrupts and initialize PIE vector table:
|
||||
// Disable CPU __interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize PIE control registers to their default state.
|
||||
// The default state is all PIE __interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU __interrupts and clear all CPU __interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the __interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_defaultisr.c.
|
||||
// This function is found in f2838x_pievect.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Step 4. User specific code:
|
||||
//
|
||||
LoopCount = 0;
|
||||
|
||||
scia_fifo_init(); // Initialize the SCI FIFO
|
||||
scia_echoback_init(); // Initialize SCI for echoback
|
||||
|
||||
msg = "\r\n\n\nHello World!\0";
|
||||
scia_msg(msg);
|
||||
|
||||
msg = "\r\nYou will enter a character, and the DSP will echo it back! \n\0";
|
||||
scia_msg(msg);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
msg = "\r\nEnter a character: \0";
|
||||
scia_msg(msg);
|
||||
|
||||
//
|
||||
// Wait for inc character
|
||||
//
|
||||
while(SciaRegs.SCIFFRX.bit.RXFFST == 0) { } // wait for empty state
|
||||
|
||||
//
|
||||
// Get character
|
||||
//
|
||||
ReceivedChar = SciaRegs.SCIRXBUF.all;
|
||||
|
||||
//
|
||||
// Echo character back
|
||||
//
|
||||
msg = " You sent: \0";
|
||||
scia_msg(msg);
|
||||
scia_xmit(ReceivedChar);
|
||||
|
||||
LoopCount++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// scia_echoback_init - Test 1,SCIA DLB, 8-bit word, baud rate 0x000F,
|
||||
// default, 1 STOP bit, no parity
|
||||
//
|
||||
void scia_echoback_init()
|
||||
{
|
||||
//
|
||||
// Note: Clocks were turned on to the SCIA peripheral
|
||||
// in the InitSysCtrl() function
|
||||
//
|
||||
|
||||
SciaRegs.SCICCR.all = 0x0007; // 1 stop bit, No loopback
|
||||
// No parity,8 char bits,
|
||||
// async mode, idle-line protocol
|
||||
SciaRegs.SCICTL1.all = 0x0003; // enable TX, RX, internal SCICLK,
|
||||
// Disable RX ERR, SLEEP, TXWAKE
|
||||
SciaRegs.SCICTL2.all = 0x0003;
|
||||
SciaRegs.SCICTL2.bit.TXINTENA = 1;
|
||||
SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
|
||||
|
||||
//
|
||||
// SCIA at 9600 baud
|
||||
// @LSPCLK = 50 MHz (200 MHz SYSCLK) HBAUD = 0x02 and LBAUD = 0x8B.
|
||||
// @LSPCLK = 30 MHz (120 MHz SYSCLK) HBAUD = 0x01 and LBAUD = 0x86.
|
||||
//
|
||||
SciaRegs.SCIHBAUD.all = 0x0002;
|
||||
SciaRegs.SCILBAUD.all = 0x008B;
|
||||
|
||||
SciaRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
|
||||
}
|
||||
|
||||
//
|
||||
// scia_xmit - Transmit a character from the SCI
|
||||
//
|
||||
void scia_xmit(int a)
|
||||
{
|
||||
while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
|
||||
SciaRegs.SCITXBUF.all =a;
|
||||
}
|
||||
|
||||
//
|
||||
// scia_msg - Transmit message via SCIA
|
||||
//
|
||||
void scia_msg(char * msg)
|
||||
{
|
||||
int i;
|
||||
i = 0;
|
||||
while(msg[i] != '\0')
|
||||
{
|
||||
scia_xmit(msg[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// scia_fifo_init - Initialize the SCI FIFO
|
||||
//
|
||||
void scia_fifo_init()
|
||||
{
|
||||
SciaRegs.SCIFFTX.all = 0xE040;
|
||||
SciaRegs.SCIFFRX.all = 0x2044;
|
||||
SciaRegs.SCIFFCT.all = 0x0;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="sdfm_ex1_filter_sync_cpuread"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063 --gen_func_subsections=on" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sdfm_drivers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_struct.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_SDFM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../sdfm_ex1_filter_sync_cpuread.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="sdfm_ex2_filter_sync_claread"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063 --gen_func_subsections=on" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sdfm_drivers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_struct.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_SDFM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_SDFM_CLA_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../sdfm_ex2_filter_sync_claread_cla.cla" targetDirectory="" />
|
||||
<file action="copy" path="../sdfm_ex2_filter_sync_claread.c" targetDirectory="" />
|
||||
<file action="copy" path="../sdfm_ex2_filter_sync_claread_shared.h" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="sdfm_ex3_filter_sync_dmaread"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063 --gen_func_subsections=on" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sdfm_drivers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_struct.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_SDFM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../sdfm_ex3_filter_sync_dmaread.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="sdfm_ex4_pwm_sync_cpuread"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063 --gen_func_subsections=on" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_COMMON_INCLUDE} -I${C2000WARE_HEADERS_INCLUDE} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=_FLASH --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--stack_size=0x100 --entry_point code_start" />
|
||||
<pathVariable name="C2000WARE_COMMON_INCLUDE" path="../../../../common/include/" scope="project" />
|
||||
<pathVariable name="C2000WARE_HEADERS_INCLUDE" path="../../../../headers/include/" scope="project" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_codestartbranch.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_defaultisr.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_dma.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_gpio.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_piectrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_pievect.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sdfm_drivers.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_struct.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_sysctrl.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/source/f2838x_usdelay.asm" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/cmd/f2838x_headers_nonBIOS_cpu1.cmd" targetDirectory="" />
|
||||
<file action="copy" path="../../../../headers/source/f2838x_globalvariabledefs.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_RAM_SDFM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../sdfm_ex4_pwm_sync_cpuread.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,430 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: sdfm_ex1_filter_sync_cpuread.c
|
||||
//
|
||||
// TITLE: SDFM Filter sync CPU Example for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> SDFM Filter Sync CPU</h1>
|
||||
//!
|
||||
//! In this example, SDFM filter data is read by CPU in SDFM ISR routine. The
|
||||
//! SDFM configuration is shown below:
|
||||
//! - SDFM1 is used in this example. For using SDFM2, few modifications
|
||||
//! would be needed in the example.
|
||||
//! - Input control mode selected - MODE0
|
||||
//! - Comparator settings
|
||||
//! - Sinc3 filter selected
|
||||
//! - OSR = 32
|
||||
//! - HLT = 0x7FFF (Higher threshold setting)
|
||||
//! - LLT = 0x0000(Lower threshold setting)
|
||||
//! - Data filter settings
|
||||
//! - All the 4 filter modules enabled
|
||||
//! - Sinc3 filter selected
|
||||
//! - OSR = 256
|
||||
//! - All the 4 filters are synchronized by using MFE
|
||||
//! (Master Filter enable bit)
|
||||
//! - Filter output represented in 16 bit format
|
||||
//! - In order to convert 25 bit Data filter
|
||||
//! into 16 bit format user needs to right shift by 10 bits for
|
||||
//! Sinc3 filter with OSR = 256
|
||||
//! - Interrupt module settings for SDFM filter
|
||||
//! - All the 4 higher threshold comparator interrupts disabled
|
||||
//! - All the 4 lower threshold comparator interrupts disabled
|
||||
//! - All the 4 modulator failure interrupts disabled
|
||||
//! - All the 4 filter will generate interrupt when a new filter data
|
||||
//! is available.
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - SDFM_PIN_MUX_OPTION1 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO16-GPIO31
|
||||
//! - SDFM_PIN_MUX_OPTION2 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO48-GPIO63
|
||||
//! - SDFM_PIN_MUX_OPTION3 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO122-GPIO137
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b Filter1_Result - Output of filter 1
|
||||
//! - \b Filter2_Result - Output of filter 2
|
||||
//! - \b Filter3_Result - Output of filter 3
|
||||
//! - \b Filter4_Result - Output of filter 4
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "f2838x_struct.h"
|
||||
#include "f2838x_sdfm_drivers.h"
|
||||
#include <stdio.h>
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define MAX_SAMPLES 1024
|
||||
#define SDFM_PIN_MUX_OPTION1 1
|
||||
#define SDFM_PIN_MUX_OPTION2 2
|
||||
#define SDFM_PIN_MUX_OPTION3 3
|
||||
#define SDFM_INT_MASK 0x8000F000U
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t gPeripheralNumber;
|
||||
int16_t Filter1_Result[MAX_SAMPLES];
|
||||
int16_t Filter3_Result[MAX_SAMPLES];
|
||||
int16_t Filter2_Result[MAX_SAMPLES];
|
||||
int16_t Filter4_Result[MAX_SAMPLES];
|
||||
#pragma DATA_SECTION(Filter1_Result,"Filter1_RegsFile");
|
||||
#pragma DATA_SECTION(Filter2_Result,"Filter2_RegsFile");
|
||||
#pragma DATA_SECTION(Filter3_Result,"Filter3_RegsFile");
|
||||
#pragma DATA_SECTION(Filter4_Result,"Filter4_RegsFile");
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void Sdfm_configurePins(uint16_t);
|
||||
void done(void);
|
||||
__interrupt void Sdfm1_ISR(void);
|
||||
__interrupt void Sdfm2_ISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
int main(void)
|
||||
{
|
||||
uint16_t pinMuxoption; // Variable for selecting pin mux option
|
||||
uint16_t HLT, LLT; // Variables for comparator thresholds
|
||||
|
||||
//
|
||||
// Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Clear all interrupts and initialize PIE vector table:
|
||||
// Disable CPU interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize PIE control registers to their default state.
|
||||
// The default state is all PIE __interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU __interrupts and clear all CPU __interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_sysctrl.c.
|
||||
// This function is found in f2838x_sysctrl.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
//
|
||||
EALLOW;
|
||||
PieVectTable.SDFM1_INT = &Sdfm1_ISR;
|
||||
PieVectTable.SDFM2_INT = &Sdfm2_ISR;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Enable CPU INT5 which is connected to SDFM INT
|
||||
//
|
||||
IER |= M_INT5;
|
||||
|
||||
//
|
||||
// Enable SDFM INTn in the PIE: Group 5 __interrupt 9-10
|
||||
//
|
||||
PieCtrlRegs.PIEIER5.bit.INTx9 = 1; // SDFM1 interrupt enabled
|
||||
PieCtrlRegs.PIEIER5.bit.INTx10 = 1; // SDFM2 interrupt enabled
|
||||
EINT;
|
||||
|
||||
//
|
||||
// Configure SDFM type to 0
|
||||
//
|
||||
EALLOW;
|
||||
DevCfgRegs.SDFMTYPE.all = 0x8000;
|
||||
EDIS;
|
||||
|
||||
#ifdef CPU1
|
||||
pinMuxoption = SDFM_PIN_MUX_OPTION1;
|
||||
//
|
||||
// Configure GPIO pins as SDFM pins
|
||||
//
|
||||
Sdfm_configurePins(pinMuxoption);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Select SDFM1
|
||||
//
|
||||
gPeripheralNumber = SDFM1;
|
||||
|
||||
//
|
||||
// Input Control Module
|
||||
//
|
||||
// Configure Input Control Mode: Modulator Clock rate = Modulator data rate
|
||||
//
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER1, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER2, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER3, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER4, MODE_0);
|
||||
|
||||
//
|
||||
// Comparator Module
|
||||
//
|
||||
HLT = 0x7FFF; // Over value threshold settings
|
||||
LLT = 0x0000; // Under value threshold settings
|
||||
|
||||
//
|
||||
// Configure Comparator module's comparator filter type and comparator's OSR
|
||||
// value, higher threshold, lower threshold
|
||||
//
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER1, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER2, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER3, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER4, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
|
||||
//
|
||||
// Data filter Module
|
||||
//
|
||||
// Configure Data filter modules filter type, OSR value and
|
||||
// enable / disable data filter
|
||||
//
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER1, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER2, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER3, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER4, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
|
||||
//
|
||||
// Enable Master filter bit: Unless this bit is set none of the filter modules
|
||||
// can be enabled. All the filter modules are synchronized when master filter
|
||||
// bit is enabled after individual filter modules are enabled.
|
||||
//
|
||||
Sdfm_enableMFE(gPeripheralNumber);
|
||||
|
||||
//
|
||||
// PWM11.CMPC, PWM11.CMPD signals can synchronize SDFM1 filters and
|
||||
// PWM12.CMPC and PWM12.CMPD signals can synchronize SDFM2 filters. This
|
||||
// option is not being used in this example for SDFM1.
|
||||
//
|
||||
Sdfm_configureExternalreset(gPeripheralNumber,FILTER_1_EXT_RESET_DISABLE,
|
||||
FILTER_2_EXT_RESET_DISABLE,
|
||||
FILTER_3_EXT_RESET_DISABLE,
|
||||
FILTER_4_EXT_RESET_DISABLE);
|
||||
|
||||
//
|
||||
// Enable interrupts
|
||||
//
|
||||
// Following SDFM interrupts can be enabled / disabled using this function.
|
||||
// Enable / disable comparator high threshold
|
||||
// Enable / disable comparator low threshold
|
||||
// Enable / disable modulator clock failure
|
||||
// Enable / disable data filter acknowledge
|
||||
//
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER1, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER2, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER3, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER4, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
|
||||
//
|
||||
// Enable master interrupt so that any of the filter interrupts can trigger
|
||||
// by SDFM interrupt to CPU
|
||||
//
|
||||
Sdfm_enableMIE(gPeripheralNumber);
|
||||
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Sdfm1_ISR - SDFM 1 ISR
|
||||
//
|
||||
__interrupt void Sdfm1_ISR(void)
|
||||
{
|
||||
static uint16_t loopCounter1 = 0;
|
||||
|
||||
//
|
||||
// Wait for result from all the filters (SDIFLG)
|
||||
//
|
||||
while((Sdfm_readFlagRegister(gPeripheralNumber) &
|
||||
SDFM_INT_MASK) != SDFM_INT_MASK);
|
||||
|
||||
//
|
||||
// Reset the loop counter
|
||||
//
|
||||
if(loopCounter1 >= MAX_SAMPLES)
|
||||
{
|
||||
loopCounter1 = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Read each SDFM filter output and store it in respective filter
|
||||
// result array
|
||||
//
|
||||
Filter1_Result[loopCounter1] = SDFM1_READ_FILTER1_DATA_16BIT;
|
||||
Filter2_Result[loopCounter1] = SDFM1_READ_FILTER2_DATA_16BIT;
|
||||
Filter3_Result[loopCounter1] = SDFM1_READ_FILTER3_DATA_16BIT;
|
||||
Filter4_Result[loopCounter1++] = SDFM1_READ_FILTER4_DATA_16BIT;
|
||||
|
||||
//
|
||||
// Clear SDFM flag register
|
||||
//
|
||||
Sdfm_clearFlagRegister(gPeripheralNumber,SDFM_INT_MASK);
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 5
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
|
||||
}
|
||||
|
||||
//
|
||||
// Sdfm2_ISR - SDFM 2 ISR
|
||||
//
|
||||
__interrupt void Sdfm2_ISR(void)
|
||||
{
|
||||
static uint16_t loopCounter1 = 0;
|
||||
|
||||
//
|
||||
// Wait for result from all the filters (SDIFLG)
|
||||
//
|
||||
while((Sdfm_readFlagRegister(gPeripheralNumber) &
|
||||
SDFM_INT_MASK) != SDFM_INT_MASK);
|
||||
|
||||
//
|
||||
// Reset the loop counter
|
||||
//
|
||||
if(loopCounter1 >= MAX_SAMPLES)
|
||||
{
|
||||
loopCounter1 = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Read each SDFM filter output and store it in respective filter
|
||||
// result array
|
||||
//
|
||||
Filter1_Result[loopCounter1] = SDFM2_READ_FILTER1_DATA_16BIT;
|
||||
Filter2_Result[loopCounter1] = SDFM2_READ_FILTER2_DATA_16BIT;
|
||||
Filter3_Result[loopCounter1] = SDFM2_READ_FILTER3_DATA_16BIT;
|
||||
Filter4_Result[loopCounter1++] = SDFM2_READ_FILTER4_DATA_16BIT;
|
||||
|
||||
//
|
||||
// Clear SDFM flag register
|
||||
//
|
||||
Sdfm_clearFlagRegister(gPeripheralNumber,SDFM_INT_MASK);
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt to receive more interrupts from group 5
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
|
||||
}
|
||||
|
||||
//
|
||||
// Sdfm_configurePins - Configure SDFM GPIOs
|
||||
//
|
||||
void Sdfm_configurePins(uint16_t sdfmPinOption)
|
||||
{
|
||||
uint16_t pin;
|
||||
|
||||
switch (sdfmPinOption)
|
||||
{
|
||||
case SDFM_PIN_MUX_OPTION1:
|
||||
for(pin=16;pin<=31;pin++)
|
||||
{
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDFM_PIN_MUX_OPTION2:
|
||||
for(pin=48;pin<=63;pin++)
|
||||
{
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDFM_PIN_MUX_OPTION3:
|
||||
for(pin=122;pin<=137;pin++)
|
||||
{
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// done - Function to halt debugger and stop application
|
||||
//
|
||||
void done(void)
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
for (;;);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,523 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: sdfm_ex2_filter_sync_claread.c
|
||||
//
|
||||
// TITLE: SDFM Filter sync CLA Example for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> SDFM Filter Sync CLA</h1>
|
||||
//!
|
||||
//! In this example, SDFM filter data is read by CLA in Cla1Task1. The
|
||||
//! SDFM configuration is shown below:
|
||||
//! - SDFM1 used in this example.For using SDFM2, few modifications
|
||||
//! would be needed in the example.
|
||||
//! - MODE0 Input control mode selected
|
||||
//! - Comparator settings
|
||||
//! - Sinc3 filter selected
|
||||
//! - OSR = 32
|
||||
//! - HLT = 0x7FFF (Higher threshold setting)
|
||||
//! - LLT = 0x0000(Lower threshold setting)
|
||||
//! - Data filter settings
|
||||
//! - All the 4 filter modules enabled
|
||||
//! - Sinc3 filter selected
|
||||
//! - OSR = 256
|
||||
//! - All the 4 filters are synchronized by using MFE
|
||||
//! (Master Filter enable bit)
|
||||
//! - Filter output represented in 16 bit format
|
||||
//! - In order to convert 25 bit Data filter
|
||||
//! into 16 bit format user needs to right shift by 10 bits for
|
||||
//! Sinc3 filter with OSR = 256
|
||||
//! - Interrupt module settings for SDFM filter
|
||||
//! - All the 4 higher threshold comparator interrupts disabled
|
||||
//! - All the 4 lower threshold comparator interrupts disabled
|
||||
//! - All the 4 modulator failure interrupts disabled
|
||||
//! - All the 4 filter will generate interrupt when a new filter data
|
||||
//! is available
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - SDFM_PIN_MUX_OPTION1 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO16-GPIO31
|
||||
//! - SDFM_PIN_MUX_OPTION2 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO48-GPIO63
|
||||
//! - SDFM_PIN_MUX_OPTION3 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO122-GPIO137
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b Filter1_Result - Output of filter 1
|
||||
//! - \b Filter2_Result - Output of filter 2
|
||||
//! - \b Filter3_Result - Output of filter 3
|
||||
//! - \b Filter4_Result - Output of filter 4
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "sdfm_ex2_filter_sync_claread_shared.h"
|
||||
#include "f2838x_sdfm_drivers.h"
|
||||
#include "f2838x_struct.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define MAX_SAMPLES 1024
|
||||
#define SDFM_PIN_MUX_OPTION1 1
|
||||
#define SDFM_PIN_MUX_OPTION2 2
|
||||
#define SDFM_PIN_MUX_OPTION3 3
|
||||
#define WAITSTEP asm(" RPT #255 || NOP")
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 gPeripheralNumber;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void Sdfm_configurePins(Uint16);
|
||||
void Cla_initMemoryMap(void);
|
||||
void CLA_initCpu1Cla(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
int main(void)
|
||||
{
|
||||
Uint16 pinMuxoption;
|
||||
Uint16 HLT, LLT;
|
||||
|
||||
//
|
||||
// Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Clear all __interrupts and initialize PIE vector table:
|
||||
// Disable CPU __interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize PIE control registers to their default state.
|
||||
// The default state is all PIE __interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU __interrupts and clear all CPU __interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the __interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_sysctrl.c.
|
||||
// This function is found in f2838x_sysctrl.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Configure SDFM type to 0
|
||||
//
|
||||
EALLOW;
|
||||
DevCfgRegs.SDFMTYPE.all = 0x8000;
|
||||
EDIS;
|
||||
|
||||
pinMuxoption = SDFM_PIN_MUX_OPTION1;
|
||||
|
||||
//
|
||||
// Configure GPIO pins as SDFM pins
|
||||
//
|
||||
Sdfm_configurePins(pinMuxoption);
|
||||
|
||||
//
|
||||
// Configure the CLA memory spaces
|
||||
//
|
||||
Cla_initMemoryMap();
|
||||
|
||||
//
|
||||
// Configure the CLA task vectors & end-of task interrupts
|
||||
//
|
||||
CLA_initCpu1Cla();
|
||||
|
||||
//
|
||||
// Force task 8
|
||||
//
|
||||
Cla1ForceTask8andWait();
|
||||
WAITSTEP;
|
||||
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Trigger Source for TASK1 of CLA1 = SDFM1
|
||||
//
|
||||
DmaClaSrcSelRegs.CLA1TASKSRCSEL1.bit.TASK1=CLA_TRIG_SD1INT;
|
||||
|
||||
//
|
||||
// Trigger Source for TASK1 of CLA1 = SDFM2
|
||||
//
|
||||
DmaClaSrcSelRegs.CLA1TASKSRCSEL1.bit.TASK2=CLA_TRIG_SD2INT;
|
||||
|
||||
//
|
||||
// Lock CLA1TASKSRCSEL1 register
|
||||
//
|
||||
DmaClaSrcSelRegs.CLA1TASKSRCSELLOCK.bit.CLA1TASKSRCSEL1=1;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Select SDFM1
|
||||
//
|
||||
gPeripheralNumber = SDFM1;
|
||||
|
||||
//
|
||||
// Input Control Module
|
||||
//
|
||||
// Configure Input Control Mode: Modulator Clock rate = Modulator data rate
|
||||
//
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER1, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER2, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER3, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER4, MODE_0);
|
||||
|
||||
//
|
||||
// Comparator Module
|
||||
//
|
||||
HLT = 0x7FFF; //Over value threshold settings
|
||||
LLT = 0x0000; //Under value threshold settings
|
||||
|
||||
//
|
||||
// Configure Comparator module's comparator filter type and comparator's OSR
|
||||
// value, higher threshold, lower threshold
|
||||
//
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER1, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER2, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER3, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER4, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
|
||||
//
|
||||
// Data filter Module
|
||||
//
|
||||
// Configure Data filter modules filter type, OSR value and
|
||||
// enable / disable data filter
|
||||
//
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER1, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER2, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER3, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER4, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
|
||||
//
|
||||
// Enable Master filter bit: Unless this bit is set none of the filter
|
||||
// modules can be enabled. All the filter modules are synchronized when
|
||||
// master filter bit is enabled after individual filter modules are enabled.
|
||||
//
|
||||
Sdfm_enableMFE(gPeripheralNumber);
|
||||
|
||||
//
|
||||
// PWM11.CMPC, PWM11.CMPD, PWM12.CMPC and PWM12.CMPD signals can synchronize
|
||||
// the filters. This option is not being used in this example.
|
||||
//
|
||||
Sdfm_configureExternalreset(gPeripheralNumber,FILTER_1_EXT_RESET_DISABLE,
|
||||
FILTER_2_EXT_RESET_DISABLE,
|
||||
FILTER_3_EXT_RESET_DISABLE,
|
||||
FILTER_4_EXT_RESET_DISABLE);
|
||||
|
||||
//
|
||||
// Enable interrupts
|
||||
//
|
||||
// Following SDFM interrupts can be enabled / disabled using this function.
|
||||
// Enable / disable comparator high threshold
|
||||
// Enable / disable comparator low threshold
|
||||
// Enable / disable modulator clock failure
|
||||
// Enable / disable filter acknowledge
|
||||
//
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER1, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER2, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER3, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER4, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
|
||||
//
|
||||
// Enable master interrupt so that any of the filter interrupts can
|
||||
// trigger by SDFM interrupt to CPU
|
||||
//
|
||||
Sdfm_enableMIE(gPeripheralNumber);
|
||||
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Sdfm_configurePins - Configure the SDFM GPIO pins
|
||||
//
|
||||
void Sdfm_configurePins(Uint16 sdfmPinOption)
|
||||
{
|
||||
Uint16 pin;
|
||||
|
||||
switch (sdfmPinOption)
|
||||
{
|
||||
case SDFM_PIN_MUX_OPTION1:
|
||||
for(pin=16;pin<=31;pin++)
|
||||
{
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDFM_PIN_MUX_OPTION2:
|
||||
for(pin=48;pin<=63;pin++)
|
||||
{
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDFM_PIN_MUX_OPTION3:
|
||||
for(pin=122;pin<=137;pin++)
|
||||
{
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cla_initMemoryMap - Initialize Memory map
|
||||
//
|
||||
void Cla_initMemoryMap(void)
|
||||
{
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Initialize and wait for CLA1ToCPUMsgRAM
|
||||
//
|
||||
MemCfgRegs.MSGxINIT.bit.INIT_CLA1TOCPU = 1;
|
||||
while(MemCfgRegs.MSGxINITDONE.bit.INITDONE_CLA1TOCPU != 1){};
|
||||
|
||||
//
|
||||
// Initialize and wait for CPUToCLA1MsgRAM
|
||||
//
|
||||
MemCfgRegs.MSGxINIT.bit.INIT_CPUTOCLA1 = 1;
|
||||
while(MemCfgRegs.MSGxINITDONE.bit.INITDONE_CPUTOCLA1 != 1){};
|
||||
|
||||
//
|
||||
// Copy the program and constants from FLASH to RAM before configuring
|
||||
// the CLA
|
||||
//
|
||||
#if defined(_FLASH)
|
||||
memcpy((uint32_t *)&Cla1funcsRunStart, (uint32_t *)&Cla1funcsLoadStart,
|
||||
(uint32_t)&Cla1funcsLoadSize );
|
||||
memcpy((uint32_t *)&Cla1ConstRunStart, (uint32_t *)&Cla1ConstLoadStart,
|
||||
(uint32_t)&Cla1ConstLoadSize );
|
||||
#endif //defined(_FLASH)
|
||||
|
||||
//
|
||||
// Select LS0 and LS1 RAM to be data RAM for the CLA and LS5 to be
|
||||
// programming space for the CLA as per linker cmd file used in this
|
||||
// example. This configuration should be updated as per the linker cmd file
|
||||
// used in the application.
|
||||
//
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS0 = 1; //LS0RAM is shared between CPU and CLA
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS0 = 0; // LS0RAM is configured as
|
||||
// data memory
|
||||
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS1 = 1; //LS1RAM is shared between CPU and CLA
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS1 = 0; // LS1RAM is configured as
|
||||
// data memory
|
||||
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS5 = 1; //LS5RAM is shared between CPU and CLA
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS5 = 1; // LS5RAM is configured as
|
||||
// program memory
|
||||
|
||||
//
|
||||
// Filter1 and Filter2 data memory is mapped to LS6 RAM in linker cmd file
|
||||
// used in this example. This configuration should be updated as per the
|
||||
// linker cmd file used in the application.
|
||||
//
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS6 = 1; //LS6RAM is shared between CPU and CLA
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS6 = 0; // LS6RAM is configured as
|
||||
// data memory
|
||||
|
||||
//
|
||||
// Filter3 and Filter4 data memory is mapped to LS7 RAM in linker cmd file
|
||||
// used in this example. This configuration should be updated as per the
|
||||
// linker cmd file used in the application.
|
||||
//
|
||||
MemCfgRegs.LSxMSEL.bit.MSEL_LS7 = 1; //LS7RAM is shared between CPU and CLA
|
||||
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS7 = 0; // LS7RAM is configured as
|
||||
// data memory
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// CLA_initCpu1Cla - Initialize CLA1 task vectors and end of task interrupts
|
||||
//
|
||||
void CLA_initCpu1Cla(void)
|
||||
{
|
||||
//
|
||||
// Compute all CLA task vectors
|
||||
// Beyond Type-1 CLAs the MVECT registers accept full 16-bit task addresses
|
||||
// as opposed to offsets used on older Type-0 CLAs
|
||||
//
|
||||
EALLOW;
|
||||
Cla1Regs.MVECT1 = (uint16_t)(&Cla1Task1);
|
||||
Cla1Regs.MVECT2 = (uint16_t)(&Cla1Task2);
|
||||
Cla1Regs.MVECT8 = (uint16_t)(&Cla1Task8);
|
||||
|
||||
//
|
||||
// Enable IACK instruction to start a task on CLA in software
|
||||
// for all 8 CLA tasks
|
||||
//
|
||||
asm(" RPT #3 || NOP");
|
||||
Cla1Regs.MCTL.bit.IACKE = 1;
|
||||
Cla1Regs.MIER.all = 0x0083;
|
||||
|
||||
//
|
||||
// Configure the vectors for the end-of-task interrupt for all
|
||||
// 8 tasks
|
||||
//
|
||||
PieVectTable.CLA1_1_INT = &cla1Isr1;
|
||||
PieVectTable.CLA1_2_INT = &cla1Isr2;
|
||||
PieVectTable.CLA1_3_INT = &cla1Isr3;
|
||||
PieVectTable.CLA1_4_INT = &cla1Isr4;
|
||||
PieVectTable.CLA1_5_INT = &cla1Isr5;
|
||||
PieVectTable.CLA1_6_INT = &cla1Isr6;
|
||||
PieVectTable.CLA1_7_INT = &cla1Isr7;
|
||||
PieVectTable.CLA1_8_INT = &cla1Isr8;
|
||||
|
||||
//
|
||||
// Enable CLA interrupts at the group and subgroup levels
|
||||
//
|
||||
PieCtrlRegs.PIEIER11.all = 0xFFFF;
|
||||
IER |= (M_INT11 );
|
||||
|
||||
EINT; // Enable Global interrupt INTM
|
||||
ERTM; // Enable Global realtime interrupt DBGM
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 1
|
||||
//
|
||||
interrupt void cla1Isr1 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
PieCtrlRegs.PIEACK.all = M_INT11;
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 2
|
||||
//
|
||||
interrupt void cla1Isr2 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
PieCtrlRegs.PIEACK.all = M_INT11;
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 3
|
||||
//
|
||||
interrupt void cla1Isr3 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 4
|
||||
//
|
||||
interrupt void cla1Isr4 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 5
|
||||
//
|
||||
interrupt void cla1Isr5 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 6
|
||||
//
|
||||
interrupt void cla1Isr6 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 7
|
||||
//
|
||||
interrupt void cla1Isr7 ()
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
}
|
||||
|
||||
//
|
||||
// cla1Isr1 - CLA1 ISR 8
|
||||
//
|
||||
interrupt void cla1Isr8 ()
|
||||
{
|
||||
// asm(" ESTOP0");
|
||||
PieCtrlRegs.PIEACK.all = M_INT11;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
//#############################################################################
|
||||
// \file sdfm_ex2_filter_sync_claread_cla.cla
|
||||
//
|
||||
// \brief SDFM filter sync
|
||||
// \author
|
||||
// \date
|
||||
//
|
||||
//
|
||||
// Group: C2000
|
||||
// Target Family: f2838x
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "sdfm_ex2_filter_sync_claread_shared.h"
|
||||
#include "f2838x_cla.h"
|
||||
#include "f2838x_piectrl.h"
|
||||
#include "f2838x_sdfm_drivers.h"
|
||||
#include "f2838x_struct.h"
|
||||
|
||||
//
|
||||
// Whether MDEBUGSTOP needs to be compiled or not
|
||||
//
|
||||
#define CLA_DEBUG 1
|
||||
#define PIEACK_GROUP5 0x0010
|
||||
|
||||
#pragma DATA_SECTION(Filter1_Result,"Filter1_RegsFile");
|
||||
#pragma DATA_SECTION(Filter2_Result,"Filter2_RegsFile");
|
||||
#pragma DATA_SECTION(Filter3_Result,"Filter3_RegsFile");
|
||||
#pragma DATA_SECTION(Filter4_Result,"Filter4_RegsFile");
|
||||
|
||||
short Filter1_Result[MAX_SAMPLES];
|
||||
short Filter2_Result[MAX_SAMPLES];
|
||||
short Filter3_Result[MAX_SAMPLES];
|
||||
short Filter4_Result[MAX_SAMPLES];
|
||||
|
||||
int16 loopCounter1;
|
||||
int16 loopCounter2;
|
||||
|
||||
//
|
||||
// Task 1
|
||||
//
|
||||
__interrupt void Cla1Task1 ( void )
|
||||
{
|
||||
#if (CLA_DEBUG==1)
|
||||
__mdebugstop();
|
||||
#endif
|
||||
Uint32 sdfmReadFlagRegister;
|
||||
|
||||
//
|
||||
// Read SDIFLG of SDFM1
|
||||
//
|
||||
sdfmReadFlagRegister = Sdfm1Regs.SDIFLG.all;
|
||||
|
||||
//
|
||||
// Reset the loop counter
|
||||
//
|
||||
if(loopCounter1 >= MAX_SAMPLES)
|
||||
{
|
||||
loopCounter1 = 0;
|
||||
}
|
||||
|
||||
Filter1_Result[loopCounter1] = *(Uint16 *)((Uint16)0x5E17);
|
||||
Filter2_Result[loopCounter1] = *(Uint16 *)((Uint16)0x5E27);
|
||||
Filter3_Result[loopCounter1] = *(Uint16 *)((Uint16)0x5E37);
|
||||
Filter4_Result[loopCounter1++] = *(Uint16 *)((Uint16)0x5E47);
|
||||
|
||||
//
|
||||
// Clear SDFM1.SDIFLG register
|
||||
//
|
||||
Sdfm1Regs.SDIFLGCLR.all = sdfmReadFlagRegister;
|
||||
}
|
||||
|
||||
//
|
||||
// Task 2
|
||||
//
|
||||
__interrupt void Cla1Task2 ( void )
|
||||
{
|
||||
#if (CLA_DEBUG==1)
|
||||
__mdebugstop();
|
||||
#endif
|
||||
Uint32 sdfmReadFlagRegister;
|
||||
|
||||
//
|
||||
// Read SDIFLG of SDFM2
|
||||
//
|
||||
sdfmReadFlagRegister = Sdfm2Regs.SDIFLG.all;
|
||||
|
||||
//
|
||||
// Reset the loop counter
|
||||
//
|
||||
if(loopCounter2 >= MAX_SAMPLES)
|
||||
{
|
||||
loopCounter2 = 0;
|
||||
}
|
||||
|
||||
Filter1_Result[loopCounter2] = *(Uint16 *)((Uint16)0x5E97);
|
||||
Filter2_Result[loopCounter2] = *(Uint16 *)((Uint16)0x5EA7);
|
||||
Filter3_Result[loopCounter2] = *(Uint16 *)((Uint16)0x5EB7);
|
||||
Filter4_Result[loopCounter2++] = *(Uint16 *)((Uint16)0x5EC7);
|
||||
|
||||
//
|
||||
// Clear SDFM2.SDIFLG register
|
||||
//
|
||||
Sdfm2Regs.SDIFLGCLR.all = sdfmReadFlagRegister;
|
||||
}
|
||||
|
||||
//
|
||||
// Task 3
|
||||
//
|
||||
__interrupt void Cla1Task3 ( void )
|
||||
{
|
||||
#if (CLA_DEBUG==1)
|
||||
__mdebugstop();
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Task 4
|
||||
//
|
||||
__interrupt void Cla1Task4 ( void )
|
||||
{
|
||||
#if (CLA_DEBUG==1)
|
||||
__mdebugstop();
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Task 5
|
||||
//
|
||||
__interrupt void Cla1Task5 ( void )
|
||||
{
|
||||
#if (CLA_DEBUG==1)
|
||||
__mdebugstop();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Task 6
|
||||
//
|
||||
__interrupt void Cla1Task6 ( void )
|
||||
{
|
||||
#if (CLA_DEBUG==1)
|
||||
__mdebugstop();
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Task 7
|
||||
//
|
||||
__interrupt void Cla1Task7 ( void )
|
||||
{
|
||||
#if (CLA_DEBUG==1)
|
||||
__mdebugstop();
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Task 8
|
||||
//
|
||||
__interrupt void Cla1Task8 ( void )
|
||||
{
|
||||
loopCounter1 = 0;
|
||||
loopCounter2 = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
#ifndef _CLA_SDFM_FILTER_SYNCH_SHARED_H_
|
||||
#define _CLA_SDFM_FILTER_SYNCH_SHARED_H_
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: sdfm_ex2_filter_sync_claread_shared.h
|
||||
//
|
||||
// TITLE: SDFM filter sync CLA
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f2838x_cla_defines.h"
|
||||
#include "f2838x_cla_typedefs.h"
|
||||
#include "f2838x_sdfm.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define FLT_MAX 1.1754944e+38
|
||||
#define FLT_MIN 1.1754944e-38
|
||||
#define NUM_DATA 8
|
||||
#define TO_CPU1 0
|
||||
#define CONNECT_TO_CLA1 0
|
||||
#define CONNECT_TO_DMA 1
|
||||
#define CONNECT_TO_CLA2 2
|
||||
#define ENABLE 1
|
||||
#define DISABLE 0
|
||||
#define MAX_SAMPLES 1024
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
extern short Filter1_Result[MAX_SAMPLES];
|
||||
extern short Filter2_Result[MAX_SAMPLES];
|
||||
extern short Filter3_Result[MAX_SAMPLES];
|
||||
extern short Filter4_Result[MAX_SAMPLES];
|
||||
|
||||
//
|
||||
// The following are symbols defined in the CLA code
|
||||
// Including them in the shared header file makes them
|
||||
// .global and the main CPU can make use of them.
|
||||
//
|
||||
//
|
||||
|
||||
// CLA C Tasks
|
||||
//
|
||||
__interrupt void Cla1Task1();
|
||||
__interrupt void Cla1Task2();
|
||||
__interrupt void Cla1Task3();
|
||||
__interrupt void Cla1Task4();
|
||||
__interrupt void Cla1Task5();
|
||||
__interrupt void Cla1Task6();
|
||||
__interrupt void Cla1Task7();
|
||||
__interrupt void Cla1Task8();
|
||||
|
||||
__interrupt void cla1Isr1();
|
||||
__interrupt void cla1Isr2();
|
||||
__interrupt void cla1Isr3();
|
||||
__interrupt void cla1Isr4();
|
||||
__interrupt void cla1Isr5();
|
||||
__interrupt void cla1Isr6();
|
||||
__interrupt void cla1Isr7();
|
||||
__interrupt void cla1Isr8();
|
||||
|
||||
//
|
||||
// Linker command variables
|
||||
//
|
||||
extern Uint32 Cla1funcsLoadStart;
|
||||
extern Uint32 Cla1funcsLoadEnd;
|
||||
extern Uint32 Cla1funcsRunStart;
|
||||
extern Uint32 Cla1funcsLoadSize;
|
||||
extern Uint32 Cla1ConstLoadStart;
|
||||
extern Uint32 Cla1ConstLoadEnd;
|
||||
extern Uint32 Cla1ConstRunStart;
|
||||
extern Uint32 Cla1ConstLoadSize;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // extern "C"
|
||||
|
||||
#endif //end of _CLA_SDFM_FILTER_SYNCH_SHARED_H_ definition
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,525 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: sdfm_ex3_filter_sync_dmaread.c
|
||||
//
|
||||
// TITLE: SDFM Filter sync SDM Example for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> SDFM Filter Sync DMA </h1>
|
||||
//!
|
||||
//! In this example, SDFM filter data is read by DMA. The
|
||||
//! SDFM configuration is shown below:
|
||||
//! - SDFM1 used in this example. For using SDFM2, few modifications
|
||||
//! would be needed in the example.
|
||||
//! - MODE0 Input control mode selected
|
||||
//! - Comparator settings
|
||||
//! - Sinc3 filter selected
|
||||
//! - OSR = 32
|
||||
//! - HLT = 0x7FFF (Higher threshold setting)
|
||||
//! - LLT = 0x0000(Lower threshold setting)
|
||||
//! - Data filter settings
|
||||
//! - All the 4 filter modules enabled
|
||||
//! - Sinc3 filter selected
|
||||
//! - OSR = 256
|
||||
//! - All the 4 filters are synchronized by using MFE
|
||||
//! (Master Filter enable bit)
|
||||
//! - Filter output represented in 16 bit format
|
||||
//! - In order to convert 25 bit Data filter
|
||||
//! into 16 bit format user needs to right shift by 10 bits for
|
||||
//! Sinc3 filter with OSR = 256
|
||||
//! - Interrupt module settings for SDFM filter
|
||||
//! - All the 4 higher threshold comparator interrupts disabled
|
||||
//! - All the 4 lower threshold comparator interrupts disabled
|
||||
//! - All the 4 modulator failure interrupts disabled
|
||||
//! - All the 4 filter will generate interrupt when a new filter
|
||||
//! data is available
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - SDFM_PIN_MUX_OPTION1 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO16-GPIO31
|
||||
//! - SDFM_PIN_MUX_OPTION2 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO48-GPIO63
|
||||
//! - SDFM_PIN_MUX_OPTION3 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO122-GPIO137
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b Filter1_Result - Output of filter 1
|
||||
//! - \b Filter2_Result - Output of filter 2
|
||||
//! - \b Filter3_Result - Output of filter 3
|
||||
//! - \b Filter4_Result - Output of filter 4
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "f2838x_struct.h"
|
||||
#include "f2838x_sdfm_drivers.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define MAX_SAMPLES 1024
|
||||
#define SDFM_PIN_MUX_OPTION1 1
|
||||
#define SDFM_PIN_MUX_OPTION2 2
|
||||
#define SDFM_PIN_MUX_OPTION3 3
|
||||
#define ONE_WORD_BURST 0
|
||||
#define SOURCE_NO_ADDRESS_CHANGE 0
|
||||
#define DESTINATION_INCREMENT_ONE_ADDRESS 1
|
||||
#define TRANSFER_SIZE_0x800 0x07FF
|
||||
#define TRANSFER_SIZE_0x400 0x03FF
|
||||
#define TRANSFER_STEP_SOURCE_NO_CHANGE 0
|
||||
#define TRANSFER_STEP_DEST_INCREMENT_ONE_ADDRESS 1
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
Uint16 gPeripheralNumber;
|
||||
int16 Filter1_Result[MAX_SAMPLES];
|
||||
int16 Filter3_Result[MAX_SAMPLES];
|
||||
int16 Filter2_Result[MAX_SAMPLES];
|
||||
int16 Filter4_Result[MAX_SAMPLES];
|
||||
#pragma DATA_SECTION(Filter1_Result,"Filter1_RegsFile");
|
||||
#pragma DATA_SECTION(Filter2_Result,"Filter2_RegsFile");
|
||||
#pragma DATA_SECTION(Filter3_Result,"Filter3_RegsFile");
|
||||
#pragma DATA_SECTION(Filter4_Result,"Filter4_RegsFile");
|
||||
|
||||
//
|
||||
// Pointers for DMA source & dest addresses
|
||||
//
|
||||
volatile int16 *DMA1Source, *DMA1Dest;
|
||||
volatile int16 *DMA2Source, *DMA2Dest;
|
||||
volatile int16 *DMA3Source, *DMA3Dest;
|
||||
volatile int16 *DMA4Source, *DMA4Dest;
|
||||
|
||||
volatile Uint16 DMA_Done = 0; // Variable to update DMA transfer status
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void Sdfm_configurePins(Uint16);
|
||||
__interrupt void SDFM1_ISR(void);
|
||||
__interrupt void SDFM2_ISR(void);
|
||||
__interrupt void local_DMACH1_ISR(void);
|
||||
__interrupt void local_DMACH2_ISR(void);
|
||||
__interrupt void local_DMACH3_ISR(void);
|
||||
__interrupt void local_DMACH4_ISR(void);
|
||||
void DMA_setup(void);
|
||||
void DMA_configure(void);
|
||||
__interrupt void SDFM1_ISR(void);
|
||||
__interrupt void SDFM2_ISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
Uint16 pinMuxoption;
|
||||
Uint16 HLT, LLT;
|
||||
|
||||
//
|
||||
// Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Clear all __interrupts and initialize PIE vector table:
|
||||
// Disable CPU __interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize PIE control registers to their default state.
|
||||
// The default state is all PIE __interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU __interrupts and clear all CPU __interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the __interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_sysctrl.c.
|
||||
// This function is found in f2838x_sysctrl.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
//
|
||||
EALLOW;
|
||||
PieVectTable.DMA_CH1_INT = &local_DMACH1_ISR;
|
||||
PieVectTable.DMA_CH2_INT = &local_DMACH2_ISR;
|
||||
PieVectTable.DMA_CH3_INT = &local_DMACH3_ISR;
|
||||
PieVectTable.DMA_CH4_INT = &local_DMACH4_ISR;
|
||||
|
||||
//
|
||||
// Enable DMA INTn in the PIE: Group 7 __interrupt 1-6
|
||||
//
|
||||
PieCtrlRegs.PIEIER7.bit.INTx1 = 1; //DMACH1 interrupt
|
||||
PieCtrlRegs.PIEIER7.bit.INTx2 = 1; //DMACH2 interrupt
|
||||
PieCtrlRegs.PIEIER7.bit.INTx3 = 1; //DMACH3 interrupt
|
||||
PieCtrlRegs.PIEIER7.bit.INTx4 = 1; //DMACH4 interrupt
|
||||
|
||||
//
|
||||
// Enable CPU INT7 interrupts are enabled
|
||||
//
|
||||
IER |= M_INT7;
|
||||
EINT;
|
||||
|
||||
//
|
||||
// Configure DMA for the transfer
|
||||
//
|
||||
DMA_configure();
|
||||
|
||||
//
|
||||
// Configure SDFM type to 0
|
||||
//
|
||||
EALLOW;
|
||||
DevCfgRegs.SDFMTYPE.all = 0x8000;
|
||||
EDIS;
|
||||
|
||||
#ifdef CPU1
|
||||
pinMuxoption = SDFM_PIN_MUX_OPTION1;
|
||||
|
||||
//
|
||||
// Configure GPIO pins as SDFM pins
|
||||
//
|
||||
Sdfm_configurePins(pinMuxoption);
|
||||
#endif
|
||||
|
||||
gPeripheralNumber = SDFM1;
|
||||
|
||||
//
|
||||
// Input Control Module
|
||||
//
|
||||
// Configure Input Control Mode: Modulator Clock rate = Modulator data rate
|
||||
//
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER1, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER2, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER3, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER4, MODE_0);
|
||||
|
||||
//
|
||||
// Comparator Module
|
||||
//
|
||||
HLT = 0x7FFF; // Over value threshold settings
|
||||
LLT = 0x0000; // Under value threshold settings
|
||||
|
||||
//
|
||||
// Configure Comparator module's comparator filter type and comparator's OSR
|
||||
// value, higher threshold, lower threshold
|
||||
//
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER1, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER2, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER3, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER4, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
|
||||
//
|
||||
// Data filter Module
|
||||
//
|
||||
// Configure Data filter modules filter type, OSR value and
|
||||
// enable / disable data filter
|
||||
//
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER1, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER2, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER3, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER4, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
|
||||
//
|
||||
// Enable Master filter bit: Unless this bit is set none of the filter
|
||||
// modules can be enabled. All the filter modules are synchronized when
|
||||
// master filter bit is enabled after individual filter modules are enabled.
|
||||
//
|
||||
Sdfm_enableMFE(gPeripheralNumber);
|
||||
|
||||
//
|
||||
// PWM11.CMPC, PWM11.CMPD signals can synchronize SDFM1 filters and
|
||||
// PWM12.CMPC and PWM12.CMPD signals can synchronize SDFM2 filters. This
|
||||
// option is not being used in this example for SDFM1.
|
||||
//
|
||||
Sdfm_configureExternalreset(gPeripheralNumber,FILTER_1_EXT_RESET_DISABLE,
|
||||
FILTER_2_EXT_RESET_DISABLE,
|
||||
FILTER_3_EXT_RESET_DISABLE,
|
||||
FILTER_4_EXT_RESET_DISABLE);
|
||||
|
||||
//
|
||||
// Enable interrupts
|
||||
//
|
||||
// Following SDFM interrupts can be enabled / disabled using this function.
|
||||
// Enable / disable comparator high threshold
|
||||
// Enable / disable comparator low threshold
|
||||
// Enable / disable modulator clock failure
|
||||
// Enable / disable filter acknowledge
|
||||
//
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER1, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER2, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER3, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER4, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
|
||||
//
|
||||
// Enable master interrupt so that any of the filter interrupts can trigger
|
||||
// by SDFM interrupt to CPU
|
||||
//
|
||||
Sdfm_enableMIE(gPeripheralNumber);
|
||||
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Sdfm_configurePins - Configure SDFM GPIOs
|
||||
//
|
||||
void Sdfm_configurePins(Uint16 sdfmPinOption)
|
||||
{
|
||||
Uint16 pin;
|
||||
|
||||
switch (sdfmPinOption)
|
||||
{
|
||||
case SDFM_PIN_MUX_OPTION1:
|
||||
for(pin=16;pin<=31;pin++)
|
||||
{
|
||||
//
|
||||
// Configure GPIOs as asynchronous input
|
||||
//
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
|
||||
//
|
||||
// Configure this pin to be owned by CPU1 and configure this
|
||||
// pin as SDFM pin
|
||||
//
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDFM_PIN_MUX_OPTION2:
|
||||
for(pin=48;pin<=63;pin++)
|
||||
{
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDFM_PIN_MUX_OPTION3:
|
||||
for(pin=122;pin<=137;pin++)
|
||||
{
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// local_DMACH1_ISR - DMA Channel 1 ISR
|
||||
//
|
||||
__interrupt void local_DMACH1_ISR(void)
|
||||
{
|
||||
DMA_Done |= 0x0001;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP7;
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// local_DMACH2_ISR - DMA Channel 2 ISR
|
||||
//
|
||||
__interrupt void local_DMACH2_ISR(void)
|
||||
{
|
||||
DMA_Done |= 0x0002;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP7;
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// local_DMACH3_ISR - DMA Channel 3 ISR
|
||||
//
|
||||
__interrupt void local_DMACH3_ISR(void)
|
||||
{
|
||||
DMA_Done |= 0x0004;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP7;
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// local_DMACH4_ISR - DMA Channel 4 ISR
|
||||
//
|
||||
__interrupt void local_DMACH4_ISR(void)
|
||||
{
|
||||
DMA_Done |= 0x0008;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP7;
|
||||
ESTOP0;
|
||||
}
|
||||
|
||||
//
|
||||
// DMA_setup - Initialize DMA burst, transfer, and wrap configurations
|
||||
//
|
||||
void DMA_setup()
|
||||
{
|
||||
//
|
||||
// Initialize the DMA
|
||||
// DMA Source is buffer 2, destination is buffer 1
|
||||
//
|
||||
DMA1Source = (int16 *)(0x5E17);
|
||||
DMA1Dest = &Filter1_Result[0];
|
||||
DMA2Source = (int16 *)(0x5E27);
|
||||
DMA2Dest = &Filter2_Result[0];
|
||||
DMA3Source = (int16 *)(0x5E37);
|
||||
DMA3Dest = &Filter3_Result[0];
|
||||
DMA4Source = (int16 *)(0x5E47);
|
||||
DMA4Dest = &Filter4_Result[0];
|
||||
|
||||
DMACH1AddrConfig((Uint16 *)DMA1Dest, (Uint16 *)DMA1Source);
|
||||
DMACH2AddrConfig((Uint16 *)DMA2Dest, (Uint16 *)DMA2Source);
|
||||
DMACH3AddrConfig((Uint16 *)DMA3Dest, (Uint16 *)DMA3Source);
|
||||
DMACH4AddrConfig((Uint16 *)DMA4Dest, (Uint16 *)DMA4Source);
|
||||
|
||||
//
|
||||
// Set up to use 16-bit data size
|
||||
// Pointers are based on 16-bit words
|
||||
// Increment by 1 (16 16-bit words)
|
||||
//
|
||||
|
||||
//
|
||||
// BURST size = 1 | Source step size = 0 | Dest step size += 1
|
||||
//
|
||||
DMACH1BurstConfig(ONE_WORD_BURST,SOURCE_NO_ADDRESS_CHANGE,
|
||||
DESTINATION_INCREMENT_ONE_ADDRESS);
|
||||
|
||||
//
|
||||
// BURST size = 1 | Source step size = 0 | Dest step size += 1
|
||||
//
|
||||
DMACH2BurstConfig(ONE_WORD_BURST,SOURCE_NO_ADDRESS_CHANGE,
|
||||
DESTINATION_INCREMENT_ONE_ADDRESS);
|
||||
|
||||
//
|
||||
// BURST size = 1 | Source step size = 0 | Dest step size += 1
|
||||
//
|
||||
DMACH3BurstConfig(ONE_WORD_BURST,SOURCE_NO_ADDRESS_CHANGE,
|
||||
DESTINATION_INCREMENT_ONE_ADDRESS);
|
||||
|
||||
//
|
||||
// BURST size = 1 | Source step size = 0 | Dest step size += 1
|
||||
//
|
||||
DMACH4BurstConfig(ONE_WORD_BURST,SOURCE_NO_ADDRESS_CHANGE,
|
||||
DESTINATION_INCREMENT_ONE_ADDRESS);
|
||||
|
||||
//
|
||||
// Transfer size = 0x400 | Source step size = 0 | Dest step size += 1
|
||||
//
|
||||
DMACH1TransferConfig(TRANSFER_SIZE_0x400,TRANSFER_STEP_SOURCE_NO_CHANGE,
|
||||
TRANSFER_STEP_DEST_INCREMENT_ONE_ADDRESS);
|
||||
|
||||
//
|
||||
// Transfer size = 0x400 | Source step size = 0 | Dest step size += 1
|
||||
//
|
||||
DMACH2TransferConfig(TRANSFER_SIZE_0x400,TRANSFER_STEP_SOURCE_NO_CHANGE,
|
||||
TRANSFER_STEP_DEST_INCREMENT_ONE_ADDRESS);
|
||||
|
||||
//
|
||||
// Transfer size = 0x400 | Source step size = 0 | Dest step size += 1
|
||||
//
|
||||
DMACH3TransferConfig(TRANSFER_SIZE_0x400,TRANSFER_STEP_SOURCE_NO_CHANGE,
|
||||
TRANSFER_STEP_DEST_INCREMENT_ONE_ADDRESS);
|
||||
|
||||
//
|
||||
// Transfer size = 0x400 | Source step size = 0 | Dest step size += 1
|
||||
//
|
||||
DMACH4TransferConfig(TRANSFER_SIZE_0x400,TRANSFER_STEP_SOURCE_NO_CHANGE,
|
||||
TRANSFER_STEP_DEST_INCREMENT_ONE_ADDRESS);
|
||||
|
||||
DMACH1WrapConfig(0xFFFF,0,0xFFFF,0);
|
||||
DMACH2WrapConfig(0xFFFF,0,0xFFFF,0);
|
||||
DMACH3WrapConfig(0xFFFF,0,0xFFFF,0);
|
||||
DMACH4WrapConfig(0xFFFF,0,0xFFFF,0);
|
||||
}
|
||||
|
||||
//
|
||||
// DMA_configure - Configure DMA channels 1,2,3, and 4
|
||||
//
|
||||
void DMA_configure(void)
|
||||
{
|
||||
DMAInitialize();
|
||||
DMA_setup();
|
||||
|
||||
DMACH1ModeConfig(DMA_SD1FLT1,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,
|
||||
SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,SIXTEEN_BIT,
|
||||
CHINT_END,CHINT_ENABLE);
|
||||
DMACH2ModeConfig(DMA_SD1FLT2,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,
|
||||
SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,SIXTEEN_BIT,
|
||||
CHINT_END,CHINT_ENABLE);
|
||||
DMACH3ModeConfig(DMA_SD1FLT3,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,
|
||||
SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,SIXTEEN_BIT,
|
||||
CHINT_END,CHINT_ENABLE);
|
||||
DMACH4ModeConfig(DMA_SD1FLT4,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,
|
||||
SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,SIXTEEN_BIT,
|
||||
CHINT_END,CHINT_ENABLE);
|
||||
|
||||
StartDMACH1();
|
||||
StartDMACH2();
|
||||
StartDMACH3();
|
||||
StartDMACH4();
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
@@ -0,0 +1,497 @@
|
||||
//###########################################################################
|
||||
//
|
||||
// FILE: sdfm_ex4_pwm_sync_cpuread.c
|
||||
//
|
||||
// TITLE: SDFM PWM sync Example for f2838x.
|
||||
//
|
||||
//! \addtogroup cpu01_example_list
|
||||
//! <h1> SDFM PWM Sync </h1>
|
||||
//!
|
||||
//! In this example, SDFM filter data is read by CPU in SDFM ISR routine. The
|
||||
//! SDFM configuration is shown below:
|
||||
//! - SDFM1 is used in this example. For using SDFM2, few modifications
|
||||
//! would be needed in the example.
|
||||
//! - MODE0 Input control mode selected
|
||||
//! - Comparator settings
|
||||
//! - Sinc3 filter selected
|
||||
//! - OSR = 32
|
||||
//! - HLT = 0x7FFF (Higher threshold setting)
|
||||
//! - LLT = 0x0000(Lower threshold setting)
|
||||
//! - Data filter settings
|
||||
//! - All the 4 filter modules enabled
|
||||
//! - Sinc3 filter selected
|
||||
//! - OSR = 256
|
||||
//! - All the 4 filters are synchronized by using PWM
|
||||
//! (Master Filter enable bit)
|
||||
//! - Filter output represented in 16 bit format
|
||||
//! - In order to convert 25 bit Data filter
|
||||
//! into 16 bit format user needs to right shift by 10 bits for
|
||||
//! Sinc3 filter with OSR = 256
|
||||
//! - Interrupt module settings for SDFM filter
|
||||
//! - All the 4 higher threshold comparator interrupts disabled
|
||||
//! - All the 4 lower threshold comparator interrupts disabled
|
||||
//! - All the 4 modulator failure interrupts disabled
|
||||
//! - All the 4 filter will generate interrupt when a new filter data
|
||||
//! is available
|
||||
//! \b External \b Connections \n
|
||||
//! - SDFM_PIN_MUX_OPTION1 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO16-GPIO31
|
||||
//! - SDFM_PIN_MUX_OPTION2 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO48-GPIO63
|
||||
//! - SDFM_PIN_MUX_OPTION3 Connect Sigma-Delta streams to
|
||||
//! (SDx-D1, SDx-C1 to SDx-D4,SDx-C4) on GPIO122-GPIO137
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b Filter1_Result - Output of filter 1
|
||||
//! - \b Filter2_Result - Output of filter 2
|
||||
//! - \b Filter3_Result - Output of filter 3
|
||||
//! - \b Filter4_Result - Output of filter 4
|
||||
//!
|
||||
//
|
||||
//###########################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//###########################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "f28x_project.h"
|
||||
#include "f2838x_struct.h"
|
||||
#include "f2838x_sdfm_drivers.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define MAX_SAMPLES 1024
|
||||
#define SDFM_PIN_MUX_OPTION1 1
|
||||
#define SDFM_PIN_MUX_OPTION2 2
|
||||
#define SDFM_PIN_MUX_OPTION3 3
|
||||
#define EPWM_TIMER_TBPRD 65535 // ePWM Period register
|
||||
#define SDFM_INT_MASK 0x8000F000U
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
uint16_t gPeripheralNumber;
|
||||
uint16_t gPWM_number = 11; // ePWM 11 for synchronizing SDFM1 filters
|
||||
int16_t Filter1_Result[MAX_SAMPLES];
|
||||
int16_t Filter3_Result[MAX_SAMPLES];
|
||||
int16_t Filter2_Result[MAX_SAMPLES];
|
||||
int16_t Filter4_Result[MAX_SAMPLES];
|
||||
#pragma DATA_SECTION(Filter1_Result,"Filter1_RegsFile");
|
||||
#pragma DATA_SECTION(Filter2_Result,"Filter2_RegsFile");
|
||||
#pragma DATA_SECTION(Filter3_Result,"Filter3_RegsFile");
|
||||
#pragma DATA_SECTION(Filter4_Result,"Filter4_RegsFile");
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
void Sdfm_configurePins(uint16_t);
|
||||
void InitEPwm(void);
|
||||
void done(void);
|
||||
__interrupt void Sdfm1_ISR(void);
|
||||
__interrupt void Sdfm2_ISR(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint16_t pinMuxoption;
|
||||
uint16_t HLT, LLT;
|
||||
|
||||
//
|
||||
// Initialize System Control:
|
||||
// PLL, WatchDog, enable Peripheral Clocks
|
||||
// This example function is found in the f2838x_sysctrl.c file.
|
||||
//
|
||||
InitSysCtrl();
|
||||
|
||||
//
|
||||
// Clear all __interrupts and initialize PIE vector table:
|
||||
// Disable CPU __interrupts
|
||||
//
|
||||
DINT;
|
||||
|
||||
//
|
||||
// Initialize PIE control registers to their default state.
|
||||
// The default state is all PIE __interrupts disabled and flags
|
||||
// are cleared.
|
||||
// This function is found in the f2838x_piectrl.c file.
|
||||
//
|
||||
InitPieCtrl();
|
||||
|
||||
//
|
||||
// Disable CPU __interrupts and clear all CPU __interrupt flags:
|
||||
//
|
||||
IER = 0x0000;
|
||||
IFR = 0x0000;
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
// This will populate the entire table, even if the __interrupt
|
||||
// is not used in this example. This is useful for debug purposes.
|
||||
// The shell ISR routines are found in f2838x_sysctrl.c.
|
||||
// This function is found in f2838x_sysctrl.c.
|
||||
//
|
||||
InitPieVectTable();
|
||||
|
||||
//
|
||||
// Interrupts that are used in this example are re-mapped to
|
||||
// ISR functions found within this file.
|
||||
//
|
||||
EALLOW;
|
||||
PieVectTable.SDFM1_INT = &Sdfm1_ISR;
|
||||
PieVectTable.SDFM2_INT = &Sdfm2_ISR;
|
||||
EDIS;
|
||||
|
||||
//
|
||||
// Enable CPU INT5 which is connected to SDFM INT
|
||||
//
|
||||
IER |= M_INT5;
|
||||
|
||||
//
|
||||
// Enable SDFM INTn in the PIE: Group 5 __interrupt 9-10
|
||||
//
|
||||
PieCtrlRegs.PIEIER5.bit.INTx9 = 1; // SDFM1 interrupt enabled
|
||||
PieCtrlRegs.PIEIER5.bit.INTx10 = 1; // SDFM2 interrupt enabled
|
||||
EINT;
|
||||
|
||||
//
|
||||
// Configure SDFM type to 0
|
||||
//
|
||||
EALLOW;
|
||||
DevCfgRegs.SDFMTYPE.all = 0x8000;
|
||||
EDIS;
|
||||
|
||||
#ifdef CPU1
|
||||
pinMuxoption = SDFM_PIN_MUX_OPTION1;
|
||||
//
|
||||
// Configure GPIO pins as SDFM pins
|
||||
//
|
||||
Sdfm_configurePins(pinMuxoption);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Select SDFM1
|
||||
//
|
||||
gPeripheralNumber = SDFM1;
|
||||
|
||||
//
|
||||
// Input Control Module
|
||||
//
|
||||
// Configure Input Control Mode: Modulator Clock rate = Modulator data rate
|
||||
//
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER1, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER2, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER3, MODE_0);
|
||||
Sdfm_configureInputCtrl(gPeripheralNumber, FILTER4, MODE_0);
|
||||
|
||||
//
|
||||
// Comparator Module
|
||||
//
|
||||
HLT = 0x7FFF; //Over value threshold settings
|
||||
LLT = 0x0000; //Under value threshold settings
|
||||
|
||||
//
|
||||
// Configure Comparator module's comparator filter type and comparator's OSR
|
||||
// value, higher threshold, lower threshold
|
||||
//
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER1, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER2, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER3, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
Sdfm_configureComparator(gPeripheralNumber, FILTER4, SINC3, OSR_32,
|
||||
HLT, LLT);
|
||||
|
||||
//
|
||||
// Enable Master filter bit: Unless this bit is set none of the filter modules
|
||||
// can be enabled. All the filter modules are synchronized when master filter
|
||||
// bit is enabled after individual filter modules are enabled. All the filter
|
||||
// modules are asynchronized when master filter bit is enabled before
|
||||
// individual filter modules are enabled.
|
||||
//
|
||||
Sdfm_enableMFE(gPeripheralNumber);
|
||||
|
||||
//
|
||||
// Data filter Module
|
||||
//
|
||||
// Configure Data filter modules filter type, OSR value and
|
||||
// enable / disable data filter
|
||||
//
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER1, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER2, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER3, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
Sdfm_configureData_filter(gPeripheralNumber, FILTER4, FILTER_ENABLE, SINC3,
|
||||
OSR_256, DATA_16_BIT, SHIFT_10_BITS);
|
||||
|
||||
//
|
||||
// PWM11.CMPC, PWM11.CMPD signals can synchronize SDFM1 filters and
|
||||
// PWM12.CMPC and PWM12.CMPD signals can synchronize SDFM2 filters. This
|
||||
// option is being used in this example for SDFM1.
|
||||
//
|
||||
Sdfm_configureExternalreset(gPeripheralNumber,FILTER_1_EXT_RESET_ENABLE,
|
||||
FILTER_2_EXT_RESET_ENABLE,
|
||||
FILTER_3_EXT_RESET_ENABLE,
|
||||
FILTER_4_EXT_RESET_ENABLE);
|
||||
//
|
||||
// Init EPWMs
|
||||
//
|
||||
InitEPwm();
|
||||
|
||||
//
|
||||
// Enable interrupts
|
||||
//
|
||||
// Following SDFM interrupts can be enabled / disabled using this function.
|
||||
// Enable / disable comparator high threshold
|
||||
// Enable / disable comparator low threshold
|
||||
// Enable / disable modulator clock failure
|
||||
// Enable / disable filter acknowledge
|
||||
//
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER1, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER2, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER3, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
Sdfm_configureInterrupt(gPeripheralNumber, FILTER4, IEH_DISABLE,
|
||||
IEL_DISABLE, MFIE_ENABLE, AE_ENABLE);
|
||||
|
||||
while((*EPWM[gPWM_number]).TBCTR < 550);
|
||||
|
||||
//
|
||||
// Enable master interrupt so that any of the filter interrupts can trigger
|
||||
// by SDFM interrupt to CPU
|
||||
//
|
||||
Sdfm_enableMIE(gPeripheralNumber);
|
||||
|
||||
while(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Sdfm1_ISR - SDFM 1 ISR
|
||||
//
|
||||
__interrupt void Sdfm1_ISR(void)
|
||||
{
|
||||
static uint16_t loopCounter1 = 0;
|
||||
|
||||
//
|
||||
// Wait for result from all the filters (SDIFLG)
|
||||
//
|
||||
while((Sdfm_readFlagRegister(gPeripheralNumber) &
|
||||
SDFM_INT_MASK) != SDFM_INT_MASK);
|
||||
|
||||
//
|
||||
// Reset the loop counter
|
||||
//
|
||||
if(loopCounter1 >= MAX_SAMPLES)
|
||||
{
|
||||
loopCounter1 = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Read each SDFM filter output and store it in respective filter
|
||||
// result array
|
||||
//
|
||||
Filter1_Result[loopCounter1] = SDFM1_READ_FILTER1_DATA_16BIT;
|
||||
Filter2_Result[loopCounter1] = SDFM1_READ_FILTER2_DATA_16BIT;
|
||||
Filter3_Result[loopCounter1] = SDFM1_READ_FILTER3_DATA_16BIT;
|
||||
Filter4_Result[loopCounter1++] = SDFM1_READ_FILTER4_DATA_16BIT;
|
||||
|
||||
//
|
||||
// Clear SDFM flag register
|
||||
//
|
||||
Sdfm_clearFlagRegister(gPeripheralNumber,SDFM_INT_MASK);
|
||||
|
||||
//
|
||||
// Acknowledge this __interrupt to receive more __interrupts from group 5
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
|
||||
}
|
||||
|
||||
//
|
||||
// Sdfm2_ISR - SDFM 2 ISR
|
||||
//
|
||||
__interrupt void Sdfm2_ISR(void)
|
||||
{
|
||||
static uint16_t loopCounter1 = 0;
|
||||
|
||||
//
|
||||
// Wait for result from all the filters (SDIFLG)
|
||||
//
|
||||
while((Sdfm_readFlagRegister(gPeripheralNumber) &
|
||||
SDFM_INT_MASK) != SDFM_INT_MASK);
|
||||
|
||||
//
|
||||
// Reset the loop counter
|
||||
//
|
||||
if(loopCounter1 >= MAX_SAMPLES)
|
||||
{
|
||||
loopCounter1 = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Read each SDFM filter output and store it in respective filter
|
||||
// result array
|
||||
//
|
||||
Filter1_Result[loopCounter1] = SDFM2_READ_FILTER1_DATA_16BIT;
|
||||
Filter2_Result[loopCounter1] = SDFM2_READ_FILTER2_DATA_16BIT;
|
||||
Filter3_Result[loopCounter1] = SDFM2_READ_FILTER3_DATA_16BIT;
|
||||
Filter4_Result[loopCounter1++] = SDFM2_READ_FILTER4_DATA_16BIT;
|
||||
|
||||
//
|
||||
// Clear SDFM flag register
|
||||
//
|
||||
Sdfm_clearFlagRegister(gPeripheralNumber,SDFM_INT_MASK);
|
||||
|
||||
//
|
||||
// Acknowledge this __interrupt to receive more __interrupts from group 5
|
||||
//
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
|
||||
}
|
||||
|
||||
//
|
||||
// Sdfm_configurePins - Configure SDFM GPIOs
|
||||
//
|
||||
void Sdfm_configurePins(uint16_t sdfmPinOption)
|
||||
{
|
||||
uint16_t pin;
|
||||
switch (sdfmPinOption)
|
||||
{
|
||||
case SDFM_PIN_MUX_OPTION1:
|
||||
for(pin=16;pin<=31;pin++)
|
||||
{
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDFM_PIN_MUX_OPTION2:
|
||||
for(pin=48;pin<=63;pin++)
|
||||
{
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDFM_PIN_MUX_OPTION3:
|
||||
for(pin=122;pin<=137;pin++)
|
||||
{
|
||||
GPIO_SetupPinOptions(pin, GPIO_INPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(pin,GPIO_MUX_CPU1,7);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// InitEPwm - Initialize specified EPWM settings
|
||||
//
|
||||
void InitEPwm(void)
|
||||
{
|
||||
uint16_t CMPC,CMPD;
|
||||
|
||||
CMPC = 200;
|
||||
CMPD = 200;
|
||||
|
||||
#ifdef CPU1
|
||||
GPIO_SetupPinOptions(4, GPIO_OUTPUT, GPIO_ASYNC);
|
||||
GPIO_SetupPinMux(4,GPIO_MUX_CPU1,1);
|
||||
#endif
|
||||
|
||||
EALLOW;
|
||||
|
||||
//
|
||||
// Allows all users to globally synchronize all enabled ePWM modules to
|
||||
// the time-base clock (TBCLK)
|
||||
//
|
||||
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
|
||||
|
||||
//
|
||||
// Setup TBCLK
|
||||
//
|
||||
(*EPWM[gPWM_number]).TBPHS.bit.TBPHS = 0x0000; // Phase is 0
|
||||
(*EPWM[gPWM_number]).TBCTR = 0x0000; // Clear counter
|
||||
(*EPWM[gPWM_number]).TBPRD = EPWM_TIMER_TBPRD; // Set timer period
|
||||
// 801 TBCLKs.
|
||||
|
||||
(*EPWM[gPWM_number]).CMPC = CMPC; // Set Compare C value
|
||||
(*EPWM[gPWM_number]).CMPD = CMPD; // Set Compare D value
|
||||
|
||||
(*EPWM[gPWM_number]).CMPA.bit.CMPA = CMPC; // Set Compare C value
|
||||
(*EPWM[gPWM_number]).CMPB.bit.CMPB = CMPD; // Set Compare D value
|
||||
|
||||
//
|
||||
// Setup counter mode
|
||||
//
|
||||
(*EPWM[gPWM_number]).TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
|
||||
(*EPWM[gPWM_number]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
|
||||
(*EPWM[gPWM_number]).TBCTL.bit.CLKDIV = TB_DIV1;
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
(*EPWM[gPWM_number]).AQCTLA.bit.CAU = 3; // Toggle PWM1A on event A,
|
||||
// up-count
|
||||
|
||||
//
|
||||
// Set actions
|
||||
//
|
||||
(*EPWM[gPWM_number]).AQCTLB.bit.CBU = 3; // Toggle PWM1B on event B,
|
||||
// up-count
|
||||
|
||||
EDIS;
|
||||
}
|
||||
|
||||
//
|
||||
// done - Function to halt debugger and stop application
|
||||
//
|
||||
void done(void)
|
||||
{
|
||||
asm(" ESTOP0");
|
||||
for (;;);
|
||||
}
|
||||
|
||||
//
|
||||
// End of file
|
||||
//
|
||||
Loaded 100 of 14950 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user