Part Number:TMS470MF03107
看了好多论坛PCNT配置不是很难的,但是自己还是没有把Capture功能使用起来。记录下配置过程:
1、时钟配置使用默认;
2、Pwm0-7设置,选用HET[2]作为PWM输出,周期10000us,50%,Enable,Pin2;
3、pwm interrupt、Edge0-7、Edge interrupts没有使用;
4、Cap0-7,Capture使用HET6,使用默认的CAP3;
5、Pin0-7,HET2配置为输出,HET6配置为输入;
6、配置完生成代码,然后根据论坛中讲HR share功能需要去修改代码,参考
https://e2echina.ti.com/support/microcontrollers/hercules/f/hercules-safety-microcontrollers-forum/17465/tms570-nhet-hal-code-generatr/58413?tisearch=e2e-sitesearch&keymatch=HET%25252520PCNT#58413
https://blog.csdn.net/weixin_38457349/article/details/95784468
/* PCNT: Capture Duty 3*- Instruction= 31*- Next instruction= 32*- Conditional next instruction = na*- Interrupt= na*- Pin= 6*/{/* Program */0x00020700U | (1U << 5U) | (6U),/* Control */0x00000000U,/* Data */0x00000000U, /* Reserved */ 0x00000000U},/* PCNT: Capture Period 3*- Instruction= 32*- Next instruction= 33*- Conditional next instruction = na*- Interrupt= na*- Pin= 6 + 1*/{/* Program *//*原代码0x00021700U | (1U << 5U) | ((6U) + 1U),*/0x00021700U | (3U << 5U) | ((6U) + 0U),/* Control */0x00000000U,/* Data */0x00000000U, /* Reserved */ 0x00000000U},
7、main部分代码;
#include "system.h" #include "het.h" /* USER CODE BEGIN (0) */ hetSIGNAL_t pluse10; hetSIGNAL_t pluse_pwm; /* USER CODE END */ /* USER CODE BEGIN (1) */ /* USER CODE END */ int main(void) { /* USER CODE BEGIN (2) */hetInit();pwmStart(pwm0);while (1){pwmSetDuty(pwm0, 30);pluse_pwm = pwmGetSignal(pwm0);pluse10 = capGetSignal(cap3);} /* USER CODE END */return 0; }
8、PWM使用示波器实测波形如下:
9、读取变量值如下;
实物已经将HET2和HET6连接到一起了,pluse10变量中值一直是0,疑问???
附件是相关工程。
20210525-TMS470-08_HET-Capture.rar
Susan Yang:
谢谢您的详细说明。但我们手边没有Herculers的板子,所以不方便为您测试。建议您在英文E2E上咨询相关的BU
https://e2e.ti.com/support/microcontrollers/hercules-safety-microcontrollers-group/hercules/
请您看一下文档
https://www.ti.com/lit/an/spna225/spna225.pdf
,
xq zhang:
ok
,
Susan Yang:
谢谢理解