hello! i m using stm32lo73rz in keil micro vresion 5 in hll format. I cant initialize char and int. I m using unsigned char i[]= "giga" but warning will generate that i not decleared. and when compile the programe in docklight giga will not print correctly any other word will come there at rx side when tx something according to code.this is my email abhij752@gmail.com please help me out from this.
#include "main.h" #include "string.h" /* USER CODE BEGIN Includes */ uint8_t rx_byte; char rx_buffer[8]; const uint8_t MSG[]="skit"; /* USER CODE END Includes */ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ /* Private variables ---------------------------------------------------------*/ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ static void LL_Init(void); void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_USART2_UART_Init(void); static void MX_I2C1_Init(void); void USART2_IRQHandler(void); /* USER CODE BEGIN PFP */ /* 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. */ LL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART2_UART_Init(); MX_I2C1_Init(); /* USER CODE BEGIN 2 */ LL_USART_ReceiveData8(USART2); LL_USART_EnableRxTimeout(USART2); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ USART2_IRQHandler(); if(rx_byte == 4) { if( strncmp( ( const char* )rx_buffer, ( const char* )MSG, 4 ) == 0 ) { rx_byte=0; unsigned char i[] = "genus"; USART2->TDR = i[4]; USART2->TDR = i[3]; USART2->TDR = i[2]; //LL_USART_TransmitData8(USART2, *i); //LL_USART_TransmitData8(USART2,'e'); //LL_USART_TransmitData8(USART2,i[2]); //LL_USART_TransmitData8(USART2,i[3]); //LL_USART_TransmitData8(USART2,i[4]); //LL_USART_TransmitData8(USART2,i[5]); //LL_USART_TransmitData8(USART2,i[6]); //LL_USART_DisableRxTimeout(USART2); } else { rx_byte=0; LL_USART_TransmitData8(USART2, ('w')); } } if(rx_byte>4) { rx_byte=0; LL_USART_TransmitData8(USART2, 'l'); } if(rx_byte<4 && rx_byte>0) { rx_byte=0; //char i = 'd'; LL_USART_TransmitData8(USART2, 's'); } } //LL_USART_ISR_RTOF; //LL_USART_CR1_RTOIE; //LL_mDelay(1000); LL_GPIO_TogglePin(GPIOA, LL_GPIO_PIN_5); /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */
You haven't shown the actual error/warning message(s) that you get, and you haven't shown exactly where they occur, but:
{ rx_byte=0; unsigned char i[] = "genus"; USART2->TDR = i[4]; USART2->TDR = i[3]; USART2->TDR = i[2]; //LL_USART_TransmitData8(USART2, *i); //LL_USART_TransmitData8(USART2,'e'); //LL_USART_TransmitData8(USART2,i[2]); //LL_USART_TransmitData8(USART2,i[3]); //LL_USART_TransmitData8(USART2,i[4]); //LL_USART_TransmitData8(USART2,i[5]); //LL_USART_TransmitData8(USART2,i[6]); //LL_USART_DisableRxTimeout(USART2); }
As pointed out in the post of 1-Mar-2018 08:25 GMT, C90 requires that all definitions must appear before any executable code in a block.
The assignment to rx_byte is "executable code" - so the definition of i[] is not allowed (in C90) to come after it.
i have gone project>option for target>c/c++>and then i ticked the c99 block and press ok. so please tell me my complier is c99 or c90. how could i check my complier.