From c58de0f903c92399b96eb877765e40837123cec9 Mon Sep 17 00:00:00 2001 From: dplimin Date: Tue, 12 Dec 2023 16:51:08 +0300 Subject: [PATCH] needReloadCheck --- .settings/language.settings.xml | 4 ++-- Core/Inc/flash.h | 7 ++++++- Core/Inc/modbus.h | 8 ++++++-- Core/Src/flash.c | 5 +++++ Core/Src/main.c | 4 +++- Core/Src/modbus.c | 18 +++++++++++++----- Core/Src/usart.c | 2 +- 7 files changed, 36 insertions(+), 12 deletions(-) diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 91dfc9c..364735a 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -4,7 +4,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/Core/Inc/flash.h b/Core/Inc/flash.h index 48466d6..8452e1c 100644 --- a/Core/Inc/flash.h +++ b/Core/Inc/flash.h @@ -14,9 +14,14 @@ #include "main.h" -#define USERPAGECOR ((uint32_t) 0x08040000) +#define USERPAGECOR ((uint32_t) 0x08040000) //Sector 6 0x0804 0000 - 0x0805 FFFF 128 Kbytes + + + #define USERPAGEPAR ((uint32_t) 0x08060000) +//#define USERPAGEPAR ((uint32_t) 0x08010000) //Sector 4 0x0801 0000 - 0x0801 FFFF 64 Kbytes + void MX_FLASH_Init(void); diff --git a/Core/Inc/modbus.h b/Core/Inc/modbus.h index 835eb4c..96054b4 100644 --- a/Core/Inc/modbus.h +++ b/Core/Inc/modbus.h @@ -47,8 +47,12 @@ static const uint16_t Crc16Table[256] = 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 }; -static const uint16_t sendtime[]={ 2400, 1600, 1200, 800, 600, 308, 200, 108, 94, 54 }; -static const uint16_t time35[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }; +static const uint16_t sendtime[]={ 3400, 1700, 1200, 800, 600, 308, 200, 108, 94, 54 }; +static const uint16_t time35[] = { 3, 3, 2, 2, 2, 2, 2, 2, 2, 2 }; + + +//static const uint16_t sendtime[]={ 2400, 1600, 1200, 800, 600, 308, 200, 108, 94, 54 }; +//static const uint16_t time35[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }; uint16_t Crc16_SENS(uint16_t len); uint16_t Crc16(uint16_t len); diff --git a/Core/Src/flash.c b/Core/Src/flash.c index 85bdf3c..dec4bf0 100644 --- a/Core/Src/flash.c +++ b/Core/Src/flash.c @@ -34,6 +34,10 @@ void MX_FLASH_Init(void) FlashEraseInitPar.TypeErase = FLASH_TYPEERASE_SECTORS; FlashEraseInitPar.Banks = FLASH_BANK_1; + + + + //FlashEraseInitPar.Sector = FLASH_SECTOR_4; FlashEraseInitPar.Sector = FLASH_SECTOR_7; FlashEraseInitPar.NbSectors = 1; FlashEraseInitPar.VoltageRange = FLASH_VOLTAGE_RANGE_3; @@ -44,6 +48,7 @@ void MX_FLASH_Init(void) FlashEraseInitCor.NbSectors = 1; FlashEraseInitCor.VoltageRange = FLASH_VOLTAGE_RANGE_3; + rdPar(); rdCor(); } diff --git a/Core/Src/main.c b/Core/Src/main.c index 39eaf95..a636c3e 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -151,7 +151,9 @@ int main(void) screenDrawCallibration(); // todo: !!! DAC. kNormToDAC=1;//todo: currentData.SENS =1; - currentData.IKU=1; + currentData.IKU=1; // ??)) + currentData.IFN=Lp100000; + currentData.IFV=Hp0_2; sh_applysetting(¤tData); }// while (workMode==CALLIBRATION){ check_reload(); diff --git a/Core/Src/modbus.c b/Core/Src/modbus.c index 7c518ca..6878bcc 100644 --- a/Core/Src/modbus.c +++ b/Core/Src/modbus.c @@ -418,13 +418,15 @@ void Receive_Complete(void){ //я сейчас попробую раскоме else { currentData=recivedData; // значения правильные копируем в рабочую структуру - needSave = true; + if(iobuf[0]) //если адрес не широковещательный отвечаем { for(j = 0; j < 6; j++) { tx[j] = iobuf[j]; } + strtOut(6); + needSave = true;//перенес ниже, может он сначала даст полноценный ответ, потом сохранит } } } @@ -462,8 +464,9 @@ void Receive_Complete(void){ //я сейчас попробую раскоме { for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[7 + j]; - //ввести проверку и прочую чепуху + // todo: ввести проверку и прочую чепуху currentData.SENS = f.fl; + strtOut(6);//перенес выше, надеюсь я не безнадежен if(currentData.SENS==1000) { currentData.IK0=1; currentData.IK1=0; @@ -504,8 +507,11 @@ void Receive_Complete(void){ //я сейчас попробую раскоме currentData.IK4=str[4]-48; currentData.IK5=str[5]-48; } - needSave = true; - strtOut(6); + + + + needSave = true;//перенес ниже, может он сначала даст полноценный ответ, потом сохранит + } else if(iobuf[6] == 8) @@ -513,8 +519,10 @@ void Receive_Complete(void){ //я сейчас попробую раскоме for(j = 0; j < 4; j++) f.ch[3 - j] = iobuf[7 + j]; currentData.ACCEL = f.fl; - needSave = true; + strtOut(6); + + needSave = true; } else { diff --git a/Core/Src/usart.c b/Core/Src/usart.c index b6c0af6..21b82c2 100644 --- a/Core/Src/usart.c +++ b/Core/Src/usart.c @@ -136,7 +136,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* USER CODE BEGIN USART1_MspInit 1 */ - HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); + HAL_NVIC_SetPriority(USART1_IRQn, 5, 0); HAL_NVIC_EnableIRQ(USART1_IRQn); /* USER CODE END USART1_MspInit 1 */ }