csm7 0 8 ноября, 2018 Опубликовано 8 ноября, 2018 · Жалоба On 11/6/2018 at 8:41 PM, Herz said: У Вас знаков препинания на клавиатуре нет? Или в школе не проходили? В мире программистов принято знаки препинания, некоторые буквы ... опускать Дабы ускорить процесс общения Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
csm7 0 8 ноября, 2018 Опубликовано 8 ноября, 2018 · Жалоба Запустил Переписал код и порты заработали Похоже #include "stm32l1xx.h" #include "stm32l1xx_gpio.h" #include "stm32l1xx_rcc.h" #include "stm32l1xx_usart.h" #include "myinit.h" int main() { initPereherial(); myUsartInit(USART1, 115200); Usart1Send(USART1, 'A'); do { Usart1Send(USART1, 'S'); GPIO_SetBits(GPIOB, LD_GREEN_GPIO_PIN); Delay_ms(100); Usart1Send(USART3, 'T'); GPIO_SetBits(GPIOB, LD_BLUE_GPIO_PIN); Delay_ms(100); GPIO_ResetBits(GPIOB, LD_GREEN_GPIO_PIN | LD_BLUE_GPIO_PIN); Delay_ms(500); }while(1); } в файле myinit.c #include "misc.h" #include "stm32l1xx_adc.h" #include "stm32l1xx_pwr.h" #include "stm32l1xx_rcc.h" //#include "stm32l1xx_rtc.h" #include "stm32l1xx_exti.h" #include "stm32l1xx_gpio.h" #include "main.h" #include "stm32l1xx_syscfg.h" //#include "stm32l1xx_dbgmcu.h" #include "stm32l1xx_usart.h" void initPereherial(void) { GPIO_InitTypeDef GPIO_InitStructure; /* configure gpios */ /* Enable GPIOs clock */ RCC_AHBPeriphClockCmd(LD_GPIO_PORT_CLK, ENABLE); /* Configure the LED_pin as output push-pull for LD3 & LD4 usage*/ GPIO_InitStructure.GPIO_Pin = LD_GREEN_GPIO_PIN | LD_BLUE_GPIO_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(LD_GPIO_PORT, &GPIO_InitStructure); /* Force a low level on LEDs*/ GPIO_LOW(LD_GPIO_PORT,LD_GREEN_GPIO_PIN); GPIO_LOW(LD_GPIO_PORT,LD_BLUE_GPIO_PIN); /* Enable USARTx Clock */ RCC_AHBPeriphClockCmd(RCC_AHBENR_GPIOAEN, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); // GPIO_InitTypeDef GPIO_InitStructure; /* USART1 Rx (PA10) input */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_Init(GPIOA, &GPIO_InitStructure); /* USART1 Tx (PA9) output */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Configuration port PA9, PA10 how alternative function for USART1 */ GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1); GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1); /* Enable the GPIOs clocks */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); /* Enable PWR, USART3 mngt clocks */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_USART3, ENABLE); /* USART3 Tx (PB10) output */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_Init(GPIOC, &GPIO_InitStructure); /* USART3 Rx (PB11) input */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_Init(GPIOB, &GPIO_InitStructure); /* Configuration prts PC10, PC11 how alternative function for USART3 */ GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_USART3); GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_USART3); } void myUsartInit(USART_TypeDef* USARTx, int BaudRate) { USART_InitTypeDef USART_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; /* Configuration USART1 */ USART_InitStructure.USART_BaudRate = BaudRate; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; /* Take On USART1 */ USART_Init(USART1, &USART_InitStructure); USART_Cmd(USART1, ENABLE); /* Take On USART1 */ /* Initialization USART3 */ USART_Init(USART3, &USART_InitStructure); USART_Cmd(USART3, ENABLE); //after configuration USART configure interrupt // NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; //channel // NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //priority // NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;//priority subgroup // NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //enable channel // NVIC_Init(&NVIC_InitStructure); //initialization // USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); //take on interrupt for input } void Delay_ms(uint32_t ms) { volatile uint32_t nCount; RCC_ClocksTypeDef RCC_Clocks; RCC_GetClocksFreq (&RCC_Clocks); nCount=(RCC_Clocks.HCLK_Frequency/10000)*ms; for (; nCount!=0; nCount--); } void Usart1Send(USART_TypeDef* USARTx, uint8_t ch) { USART_SendData(USARTx, (uint8_t) ch); //Loop until the end of transmission while(USART_GetFlagStatus(USARTx, USART_FLAG_TC) == RESET) {} } uint8_t Usart1Get(void) { while ( USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET) {} return (uint8_t)USART_ReceiveData(USART1); } /*************** End My creation ****************/ Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
csm7 0 8 ноября, 2018 Опубликовано 8 ноября, 2018 · Жалоба Спасибо всем за рекомендации. Сейчас разбираюсь с прерываниями для USART. Также хочу прикрутить библиотеку GSM для STM32. Какую библиотеку посоветуете ув. форумчане. Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
Сергей Борщ 117 8 ноября, 2018 Опубликовано 8 ноября, 2018 · Жалоба 33 минуты назад, csm7 сказал: В мире программистов принято знаки препинания, некоторые буквы ... опускать Дабы ускорить процесс общения На этом форуме принято использовать русский язык. Желающих общаться с вами на "языке программистов" вы можете здесь и не дождаться... Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
csm7 0 8 ноября, 2018 Опубликовано 8 ноября, 2018 · Жалоба Спасибо учту. Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
csm7 0 27 ноября, 2018 Опубликовано 27 ноября, 2018 · Жалоба Доброго времени ! При использовании дебаггера Keil uVision попробовал написать Debugger script. Попытки оказались безуспешными. define char USART1_RxBuffer[256]; define uint8_t index; FUNC void Filling_Buffer (void) { USART1_RxBuffer[0] = "\r"; USART1_RxBuffer[1] = "\n"; USART1_RxBuffer[2] = "+"; USART1_RxBuffer[3] = "C"; USART1_RxBuffer[4] = "S"; USART1_RxBuffer[5] = "Q"; USART1_RxBuffer[6] = ":"; USART1_RxBuffer[7] = " "; USART1_RxBuffer[8] = "1"; USART1_RxBuffer[9] = "7"; USART1_RxBuffer[10] = ","; USART1_RxBuffer[11] = "0"; USART1_RxBuffer[12] = "\r"; USART1_RxBuffer[13] = "\n"; USART1_RxBuffer[14] = "\r"; USART1_RxBuffer[15] = "\n"; USART1_RxBuffer[16] = "O"; USART1_RxBuffer[17] = "K"; USART1_RxBuffer[18] = "\r"; USART1_RxBuffer[19] = "\n"; } define button "FillBuffer" , "Filling_Buffer()" Скрипт не работает. В чем проблема, может скрипты вообще в среде IDE не работают. Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться
csm7 0 27 ноября, 2018 Опубликовано 27 ноября, 2018 · Жалоба Запустил, оказалось необходимо USART1_RxBuffer[0] = '\r'; но все же хотелось бы заполнять массив строкой FUNC Filling_Buffer(char *str) { uint8_t index = 0; while (*str != 0) { USART1_RxBuffer[index] = *str; str++; index++; } } define button "FillBuffer" , "Filling_Buffer(\"\r\n+CSQ: 17,0\r\n\r\nOK\r\n\")" почему-то говорит что ошибка. Не понимает указателей. Цитата Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты Поделиться