С код написан в Keil-е с использованием HAL. Пробовал и без HAL-а, настраивал все в ручную, результат тот же.
/* Includes ------------------------------------------------------------------*/
#include "stm32f7xx_hal.h"
#include "gpio.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
volatile uint16_t Imp_time, Imp_delay, Wait, Window;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
void TDC12(void);
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; //Disable IRQ SysTick
SysTick->CTRL |= SysTick_CTRL_CLKSOURCE_Msk;
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; //Disable SysTick !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SysTick->LOAD = 39; // 200 ns
while (1)
{
Imp_time=100; Imp_delay=100; Wait=100; Window=100;
TDC12();
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
/** System Clock Configuration
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
__PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 12;
RCC_OscInitStruct.PLL.PLLN = 192;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 2;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
HAL_PWREx_ActivateOverDrive();
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6);
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}
/* USER CODE BEGIN 4 */
void TDC12(void)
{
register uint32_t temp __asm("r3");
register uint32_t adr __asm("r4");
register uint32_t PosP __asm("r5");
register uint32_t NegP __asm("r6");
register uint32_t NoP __asm("r7");
register uint32_t MUX __asm("r8");
register uint32_t win1 __asm("r9");
register uint32_t win2 __asm("r10");
__disable_irq ();
__asm {
STR PosP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab1:
ADDS adr,adr,#1
CMP adr,win1 //1 Cikl
BCC lab1 }
__asm {
STR NoP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab2:
ADDS adr,adr,#1
CMP adr,win2 //2 Cikl
BCC lab2 }
__asm {
STR NegP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab3:
ADDS adr,adr,#1
CMP adr,win1 //3 Cikl
BCC lab3 }
__asm {
STR NoP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab4:
ADDS adr,adr,#1
CMP adr,win2 //4 Cikl
BCC lab4 }
__asm {
STR PosP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab10:
ADDS adr,adr,#1
CMP adr,win1 //5 Cikl
BCC lab10 }
__asm {
STR NoP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab20:
ADDS adr,adr,#1
CMP adr,win2 //6 Cikl
BCC lab20 }
__asm {
STR NegP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab30:
ADDS adr,adr,#1
CMP adr,win1 //7 Cikl
BCC lab30 }
__asm {
STR NoP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab40:
ADDS adr,adr,#1
CMP adr,win2 //8 Cikl
BCC lab40 }
__asm {
STR PosP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab100:
ADDS adr,adr,#1
CMP adr,win1 //9 Cikl
BCC lab100 }
__asm {
STR NoP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab200:
ADDS adr,adr,#1
CMP adr,win2 //10 Cikl
BCC lab200 }
__asm {
STR NegP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab300:
ADDS adr,adr,#1
CMP adr,win1 //11 Cikl
BCC lab300 }
__asm {
STR NoP,[#0x40020800,#0x18] // PortC
MOV adr,#0x00000000
lab400:
ADDS adr,adr,#1
CMP adr,win2 //12 Cikl
BCC lab400 }
}
/* USER CODE END 4 */
Вроде бы все лишние выкинул. Крайне простая программа...
Пардон, в подпрограмме TDC12:
win1=Imp_time;
win2=Imp_delay;
удалилось случайно...