{"id":413999,"date":"2024-06-29T23:29:06","date_gmt":"2024-06-29T23:29:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=413999"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=413999","title":{"rendered":"<span>Artery AT32F403A. \u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0425\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0432\u0441\u0435\u043c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0442\u043e\u0440\u0430\u043c \u043c\u043e\u0438\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0435 \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0438\u043a\u0440\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 (\u041c\u041a) Artery AT32F403A. \u0427\u0442\u043e-\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0437\u044c\u043c\u0443 \u043d\u0430 \u0437\u0430\u043c\u0435\u0442\u043a\u0443. \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u043c\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438, \u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0443, \u0432 \u043f\u043e\u043b\u0435\u0432\u044b\u0445 \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u044f\u0445 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043e \u0431\u043e\u043b\u0435\u0435 600 \u043a\u043c \u0438 \u0431\u043e\u043b\u0435\u0435 21 \u0447\u0430\u0441\u0430 \u0440\u0430\u0431\u043e\u0442\u044b, \u0431\u0435\u0437 \u0441\u0431\u043e\u0435\u0432 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u043a\u0430\u043d\u0431\u0430\u0441\u0430 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u043e \u043d\u0435\u0442, \u0432\u0440\u0443. \u041e\u0434\u0438\u043d \u0441\u0431\u043e\u0439 \u0431\u044b\u043b. \u041f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u0441\u043d\u0430 \u043c\u0430\u0433\u043d\u0438\u0442\u043e\u043b\u044b, \u043a\u0430\u043d\u0431\u0430\u0441 &#171;\u0437\u0430\u0432\u0438\u0441\u0430\u043b&#187;, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043f\u043e \u043f\u0438\u0442\u0430\u043d\u0438\u044e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a \u043c\u0430\u0433\u043d\u0438\u0442\u043e\u043b\u0435. \u041d\u043e \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u0440\u0435\u0448\u0435\u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<pre><code>int main(void) {     nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);     system_clock_config();     delay_init();     delay_ms(2000);     init_usb_device(); ****** \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u043a\u043e\u0434<\/code><\/pre>\n<p>\u0422\u043e\u043f\u043e\u0440\u043d\u043e? \u041d\u0435 \u0441\u043f\u043e\u0440\u044e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442. \u041e\u0442 \u0441\u043b\u043e\u0432\u0430 \u0441\u043e\u0432\u0441\u0435\u043c. \u041c\u0430\u0433\u043d\u0438\u0442\u043e\u043b\u0430 \u0434\u043e\u043b\u044c\u0448\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u0445\u043e\u0447\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u0431\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u043d\u0438\u0442\u044c \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u044f \u043d\u0435 \u0441\u0442\u0430\u0432\u0438\u043b \u0437\u0430\u0434\u0430\u0447\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0435\u0432\u0430\u0440\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p><em>\u0427\u0442\u043e \u0435\u0449\u0451 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u0438 \u043d\u0443\u0436\u043d\u043e\u0433\u043e.<\/em><\/p>\n<p><em>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 USART<\/em>. \u041a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c AT32F403A_407_Firmware_Library_V2.1.4\\project\\at_start_f403a\\examples\\usart.<br \/>\u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u0441\u0435\u0431\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438. \u041d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0442\u0430\u043c \u0442\u043e\u0436\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043d\u0435\u0442, \u0432\u044b \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u0441\u044c.<\/p>\n<pre><code>uint8_t LIN_Buffer_C6[7] = {0}; ******** while(tx_counter &lt; 7) {    while(usart_flag_get(USART3, USART_TDBE_FLAG) == RESET);    usart_data_transmit(USART3, LIN_Buffer_C6[tx_counter++]); } tx_counter = 0;<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u0430\u043a\u0435\u0442\u0430 \u0438\u0437 7 \u0431\u0430\u0439\u0442. \u041a\u043e\u0434 \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0432 \u043b\u044e\u0431\u043e\u043c \u0443\u0434\u043e\u0431\u043d\u043e\u043c \u0434\u043b\u044f \u0432\u0430\u0441 \u043c\u0435\u0441\u0442\u0435.<\/p>\n<p><em>\u041f\u043e\u0440\u0442\u044b \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430<\/em>. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u043d\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 LED \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 GPIO_Init.gpio_mode \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439, \u0435\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c GPIO_MODE_INPUT \u0438\u043b\u0438 GPIO_MODE_OUTPUT.<\/p>\n<pre><code>gpio_init_type GPIO_Init;  GPIO_Init.gpio_mode = GPIO_MODE_INPUT; GPIO_Init.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; GPIO_Init.gpio_pull = GPIO_PULL_NONE; GPIO_Init.gpio_pins = GPIO_PINS_6;  GPIO_Init.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; gpio_init(GPIOC, &amp;GPIO_Init);  GPIO_Init.gpio_mode = GPIO_MODE_OUTPUT; GPIO_Init.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; GPIO_Init.gpio_pull = GPIO_PULL_NONE; GPIO_Init.gpio_pins = GPIO_PINS_7;  GPIO_Init.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; gpio_init(GPIOC, &amp;GPIO_Init);<\/code><\/pre>\n<pre><code>gpio_bits_reset(GPIOC, GPIO_PINS_7); \/\/ \u041d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435 \u043d\u0438\u0437\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f gpio_bits_set(GPIOC, GPIO_PINS_7); \/\/ \u041d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u0430<\/p>\n<pre><code>if (gpio_output_data_bit_read(GPIOC, GPIO_PINS_7)) {    \/\/ \u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c } else {    \/\/ \u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0435 \u043d\u0438\u0437\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c }<\/code><\/pre>\n<p><strong>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u0439 \u0431\u0443\u0444\u0435\u0440<\/strong><\/p>\n<pre><code>uint32_t ptrWriteUserTxBufferFS = 0 ; uint32_t ptrReadUserTxBufferFS = 0 ;  uint8_t CDC_add_buf_to_transmit(uint8_t* Buf, uint16_t Len) {   uint16_t _cnt = Len ;   while(_cnt) {     UserTxBufferFS[ptrWriteUserTxBufferFS] = *Buf ;     ptrWriteUserTxBufferFS++;     Buf++ ;     ptrWriteUserTxBufferFS %= APP_TX_DATA_SIZE ;     _cnt--;   }   return(0); }  uint8_t CDC_periodic_callback(void) {   uint32_t buffptr;   uint32_t buffsize;    if(ptrReadUserTxBufferFS != ptrWriteUserTxBufferFS) {     if(ptrReadUserTxBufferFS > ptrWriteUserTxBufferFS) { \/* Rollback *\/       buffsize = APP_TX_DATA_SIZE - ptrReadUserTxBufferFS;     } else {       buffsize = ptrWriteUserTxBufferFS - ptrReadUserTxBufferFS;     }     buffptr = ptrReadUserTxBufferFS;     if (usb_vcp_send_data(&amp;usb_core_dev, (uint8_t*)&amp;UserTxBufferFS[buffptr], buffsize) == SUCCESS) {       ptrReadUserTxBufferFS += buffsize;       if (ptrReadUserTxBufferFS == APP_TX_DATA_SIZE) {         ptrReadUserTxBufferFS = 0;       }     }   }   return(0); }<\/code><\/pre>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u0439 \u0431\u0443\u0444\u0435\u0440 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0441 \u043a\u0430\u043d\u0448\u0438\u043d\u044b<\/p>\n<pre><code>CDC_add_buf_to_transmit(CDC_Tx2_Buffer, 0x0010); \/\/ 10hex - \u0434\u043b\u0438\u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u0430<\/code><\/pre>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u0433\u043e \u0431\u0443\u0444\u0435\u0440\u0430 \u0432 \u0442\u0435\u043b\u0435 main<\/p>\n<pre><code>while(1) {   CDC_periodic_callback(); \/\/ \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430   \/*.....*\/ }<\/code><\/pre>\n<p><strong>WatchDog \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 &#171;\u043d\u0430 \u0445\u043e\u0434\u0443&#187;<\/strong><\/p>\n<p>\u041e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0437\u0430\u0432\u0438\u0441\u043b\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041c\u043e\u0436\u043d\u043e \u0435\u0451 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043b\u0438\u0448\u0438\u0432 \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u043f\u043b\u0430\u0442\u0443, \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u0442\u0430\u0439\u043c\u0435\u0440 watchdog. \u0415\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0435, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e 300 (\u0432\u0440\u0435\u043c\u044f 300 \u043c\u0441), \u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e. \u0427\u0442\u043e \u0431\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f<\/p>\n<pre><code>void ini_watchdog(void) {   if(crm_flag_get(CRM_WDT_RESET_FLAG) != RESET) {     \/* reset from wdt *\/     crm_flag_clear(CRM_WDT_RESET_FLAG);   }   \/* disable register write protection *\/   wdt_register_write_enable(TRUE);    \/* set the wdt divider value *\/   wdt_divider_set(WDT_CLK_DIV_4);    \/* set reload value     timeout = reload_value * (divider \/ lick_freq )    (s)     lick_freq    = 40000 Hz    divider      = 4    reload_value = 3000     timeout = 3000 * (4 \/ 40000 ) = 0.3s = 300ms   *\/   wdt_reload_value_set(3000 - 1);    \/* reload wdt counter *\/   wdt_counter_reload();    \/* enable wdt *\/   wdt_enable(); }  int main(void) {   system_clock_config();    \/* get system clock *\/   crm_clocks_freq_get(&amp;crm_clocks_freq_struct);    \/* config nvic priority group *\/   nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);    ini_watchdog();    \/*...\u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043e\u0434.....*\/    while(1) {     \/* reload wdt counter *\/     wdt_counter_reload();      \/*...\u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043e\u0434......*\/   } }<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u0436\u0430\u043b\u0443\u0439 \u0432\u0441\u0451.<br \/>\u041c\u0430\u0442\u0451\u0440\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0435. \u042f \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043b\u0438\u043b\u0441\u044f \u0441\u0432\u043e\u0438\u043c\u0438 \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0445\u043e\u0434\u0435 \u0440\u0430\u0431\u043e\u0442\u044b. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043d\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u044d\u0442\u043e\u043c \u041c\u041a. \u0410 \u0441\u0435\u0439\u0447\u0430\u0441 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u0442\u043e.<\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u043e\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u041c\u041a AT32F403A \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043a\u043e\u043c\u0443-\u0442\u043e \u0440\u0435\u0448\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0441 STM32 \u043d\u0430 AT32, \u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u043e\u043c \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u043e\u043b\u0438, \u0438\u043b\u0438 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043c\u043e\u043b\u043e\u0434\u044b\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c \u0432 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438. \u0412\u0441\u0435\u043c \u043f\u043e\u043a\u0430, \u0443\u0448\u0451\u043b \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 Java<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/727898\/\"> https:\/\/habr.com\/ru\/articles\/727898\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0425\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0432\u0441\u0435\u043c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0442\u043e\u0440\u0430\u043c \u043c\u043e\u0438\u0445 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0435 \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0438\u043a\u0440\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 (\u041c\u041a) Artery AT32F403A. \u0427\u0442\u043e-\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0437\u044c\u043c\u0443 \u043d\u0430 \u0437\u0430\u043c\u0435\u0442\u043a\u0443. \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u043c\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438, \u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0443, \u0432 \u043f\u043e\u043b\u0435\u0432\u044b\u0445 \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u044f\u0445 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043e \u0431\u043e\u043b\u0435\u0435 600 \u043a\u043c \u0438 \u0431\u043e\u043b\u0435\u0435 21 \u0447\u0430\u0441\u0430 \u0440\u0430\u0431\u043e\u0442\u044b, \u0431\u0435\u0437 \u0441\u0431\u043e\u0435\u0432 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u043a\u0430\u043d\u0431\u0430\u0441\u0430 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u043e \u043d\u0435\u0442, \u0432\u0440\u0443. \u041e\u0434\u0438\u043d \u0441\u0431\u043e\u0439 \u0431\u044b\u043b. \u041f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u0441\u043d\u0430 \u043c\u0430\u0433\u043d\u0438\u0442\u043e\u043b\u044b, \u043a\u0430\u043d\u0431\u0430\u0441 &#171;\u0437\u0430\u0432\u0438\u0441\u0430\u043b&#187;, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043f\u043e \u043f\u0438\u0442\u0430\u043d\u0438\u044e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a \u043c\u0430\u0433\u043d\u0438\u0442\u043e\u043b\u0435. \u041d\u043e \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u0440\u0435\u0448\u0435\u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<pre><code>int main(void) {     nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);     system_clock_config();     delay_init();     delay_ms(2000);     init_usb_device(); ****** \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u043a\u043e\u0434<\/code><\/pre>\n<p>\u0422\u043e\u043f\u043e\u0440\u043d\u043e? \u041d\u0435 \u0441\u043f\u043e\u0440\u044e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442. \u041e\u0442 \u0441\u043b\u043e\u0432\u0430 \u0441\u043e\u0432\u0441\u0435\u043c. \u041c\u0430\u0433\u043d\u0438\u0442\u043e\u043b\u0430 \u0434\u043e\u043b\u044c\u0448\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u0445\u043e\u0447\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0443\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u0431\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u043d\u0438\u0442\u044c \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u044f \u043d\u0435 \u0441\u0442\u0430\u0432\u0438\u043b \u0437\u0430\u0434\u0430\u0447\u0443 \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0435\u0432\u0430\u0440\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p><em>\u0427\u0442\u043e \u0435\u0449\u0451 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u0438 \u043d\u0443\u0436\u043d\u043e\u0433\u043e.<\/em><\/p>\n<p><em>\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 USART<\/em>. \u041a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c AT32F403A_407_Firmware_Library_V2.1.4\\project\\at_start_f403a\\examples\\usart.<br \/>\u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u044f \u043d\u0435 \u0431\u0443\u0434\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u0441\u0435\u0431\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438. \u041d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0442\u0430\u043c \u0442\u043e\u0436\u0435 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043d\u0435\u0442, \u0432\u044b \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u0441\u044c.<\/p>\n<pre><code>uint8_t LIN_Buffer_C6[7] = {0}; ******** while(tx_counter &lt; 7) {    while(usart_flag_get(USART3, USART_TDBE_FLAG) == RESET);    usart_data_transmit(USART3, LIN_Buffer_C6[tx_counter++]); } tx_counter = 0;<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u0430\u043a\u0435\u0442\u0430 \u0438\u0437 7 \u0431\u0430\u0439\u0442. \u041a\u043e\u0434 \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0432 \u043b\u044e\u0431\u043e\u043c \u0443\u0434\u043e\u0431\u043d\u043e\u043c \u0434\u043b\u044f \u0432\u0430\u0441 \u043c\u0435\u0441\u0442\u0435.<\/p>\n<p><em>\u041f\u043e\u0440\u0442\u044b \u0432\u0432\u043e\u0434\u0430\/\u0432\u044b\u0432\u043e\u0434\u0430<\/em>. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u043d\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 LED \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 GPIO_Init.gpio_mode \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439, \u0435\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c GPIO_MODE_INPUT \u0438\u043b\u0438 GPIO_MODE_OUTPUT.<\/p>\n<pre><code>gpio_init_type GPIO_Init;  GPIO_Init.gpio_mode = GPIO_MODE_INPUT; GPIO_Init.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; GPIO_Init.gpio_pull = GPIO_PULL_NONE; GPIO_Init.gpio_pins = GPIO_PINS_6;  GPIO_Init.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; gpio_init(GPIOC, &amp;GPIO_Init);  GPIO_Init.gpio_mode = GPIO_MODE_OUTPUT; GPIO_Init.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; GPIO_Init.gpio_pull = GPIO_PULL_NONE; GPIO_Init.gpio_pins = GPIO_PINS_7;  GPIO_Init.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; gpio_init(GPIOC, &amp;GPIO_Init);<\/code><\/pre>\n<pre><code>gpio_bits_reset(GPIOC, GPIO_PINS_7); \/\/ \u041d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435 \u043d\u0438\u0437\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f gpio_bits_set(GPIOC, GPIO_PINS_7); \/\/ \u041d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u043e\u0440\u0442\u0430<\/p>\n<pre><code>if (gpio_output_data_bit_read(GPIOC, GPIO_PINS_7)) {    \/\/ \u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c } else {    \/\/ \u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0435 \u043d\u0438\u0437\u043a\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c }<\/code><\/pre>\n<p><strong>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u0439 \u0431\u0443\u0444\u0435\u0440<\/strong><\/p>\n<pre><code>uint32_t ptrWriteUserTxBufferFS = 0 ; uint32_t ptrReadUserTxBufferFS = 0 ;  uint8_t CDC_add_buf_to_transmit(uint8_t* Buf, uint16_t Len) {   uint16_t _cnt = Len ;   while(_cnt) {     UserTxBufferFS[ptrWriteUserTxBufferFS] = *Buf ;     ptrWriteUserTxBufferFS++;     Buf++ ;     ptrWriteUserTxBufferFS %= APP_TX_DATA_SIZE ;     _cnt--;   }   return(0); }  uint8_t CDC_periodic_callback(void) {   uint32_t buffptr;   uint32_t buffsize;    if(ptrReadUserTxBufferFS != ptrWriteUserTxBufferFS) {     if(ptrReadUserTxBufferFS > ptrWriteUserTxBufferFS) { \/* Rollback *\/       buffsize = APP_TX_DATA_SIZE - ptrReadUserTxBufferFS;     } else {       buffsize = ptrWriteUserTxBufferFS - ptrReadUserTxBufferFS;     }     buffptr = ptrReadUserTxBufferFS;     if (usb_vcp_send_data(&amp;usb_core_dev, (uint8_t*)&amp;UserTxBufferFS[buffptr], buffsize) == SUCCESS) {       ptrReadUserTxBufferFS += buffsize;       if (ptrReadUserTxBufferFS == APP_TX_DATA_SIZE) {         ptrReadUserTxBufferFS = 0;       }     }   }   return(0); }<\/code><\/pre>\n<p>\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u0439 \u0431\u0443\u0444\u0435\u0440 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0438\u0433\u043d\u0430\u043b\u0430 \u0441 \u043a\u0430\u043d\u0448\u0438\u043d\u044b<\/p>\n<pre><code>CDC_add_buf_to_transmit(CDC_Tx2_Buffer, 0x0010); \/\/ 10hex - \u0434\u043b\u0438\u043d\u0430 \u043f\u0430\u043a\u0435\u0442\u0430<\/code><\/pre>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u043e\u0433\u043e \u0431\u0443\u0444\u0435\u0440\u0430 \u0432 \u0442\u0435\u043b\u0435 main<\/p>\n<pre><code>while(1) {   CDC_periodic_callback(); \/\/ \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430   \/*.....*\/ }<\/code><\/pre>\n<p><strong>WatchDog \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 &#171;\u043d\u0430 \u0445\u043e\u0434\u0443&#187;<\/strong><\/p>\n<p>\u041e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0437\u0430\u0432\u0438\u0441\u043b\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041c\u043e\u0436\u043d\u043e \u0435\u0451 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043b\u0438\u0448\u0438\u0432 \u043f\u0438\u0442\u0430\u043d\u0438\u044f \u043f\u043b\u0430\u0442\u0443, \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 \u0442\u0430\u0439\u043c\u0435\u0440 watchdog. \u0415\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0435, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e 300 (\u0432\u0440\u0435\u043c\u044f 300 \u043c\u0441), \u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e. \u0427\u0442\u043e \u0431\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c. \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430\u044f<\/p>\n<pre><code>void ini_watchdog(void) {   if(crm_flag_get(CRM_WDT_RESET_FLAG) != RESET) {     \/* reset from wdt *\/     crm_flag_clear(CRM_WDT_RESET_FLAG);   }   \/* disable register write protection *\/   wdt_register_write_enable(TRUE);    \/* set the wdt divider value *\/   wdt_divider_set(WDT_CLK_DIV_4);    \/* set reload value     timeout = reload_value * (divider \/ lick_freq )    (s)     lick_freq    = 40000 Hz    divider      = 4    reload_value = 3000     timeout = 3000 * (4 \/ 40000 ) = 0.3s = 300ms   *\/   wdt_reload_value_set(3000 - 1);    \/* reload wdt counter *\/   wdt_counter_reload();    \/* enable wdt *\/   wdt_enable(); }  int main(void) {   system_clock_config();    \/* get system clock *\/   crm_clocks_freq_get(&amp;crm_clocks_freq_struct);    \/* config nvic priority group *\/   nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);    ini_watchdog();    \/*...\u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043e\u0434.....*\/    while(1) {     \/* reload wdt counter *\/     wdt_counter_reload();      \/*...\u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043e\u0434......*\/   } }<\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u0436\u0430\u043b\u0443\u0439 \u0432\u0441\u0451.<br \/>\u041c\u0430\u0442\u0451\u0440\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0435. \u042f \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u043b\u0438\u043b\u0441\u044f \u0441\u0432\u043e\u0438\u043c\u0438 \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u0445\u043e\u0434\u0435 \u0440\u0430\u0431\u043e\u0442\u044b. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043d\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u044d\u0442\u043e\u043c \u041c\u041a. \u0410 \u0441\u0435\u0439\u0447\u0430\u0441 \u0435\u0441\u0442\u044c \u0445\u043e\u0442\u044c \u0447\u0442\u043e-\u0442\u043e.<\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u043e\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u041c\u041a AT32F403A \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043a\u043e\u043c\u0443-\u0442\u043e \u0440\u0435\u0448\u0438\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0441 STM32 \u043d\u0430 AT32, \u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u043e\u043c \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u043e\u043b\u0438, \u0438\u043b\u0438 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043c\u043e\u043b\u043e\u0434\u044b\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c \u0432 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0438. \u0412\u0441\u0435\u043c \u043f\u043e\u043a\u0430, \u0443\u0448\u0451\u043b \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 Java<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/727898\/\"> https:\/\/habr.com\/ru\/articles\/727898\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-413999","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/413999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=413999"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/413999\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=413999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=413999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=413999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}