demande de correction de code de la communication série entre deux cartes stm32
Répondre à la discussion
Affichage des résultats 1 à 2 sur 2

demande de correction de code de la communication série entre deux cartes stm32



  1. #1
    hichooo1991

    demande de correction de code de la communication série entre deux cartes stm32


    ------

    salutation
    jai travailler avec code ppour lenvoie dun seule caractere entre 2 cartes stm32f4 et je veux l'amiliorer pour quil puisse envoyer une chaine complaite de caractere jai fait des modifications mais ça n'a pas marché j'espere bien que vous m'aider a le corriger et merci bien d'avance
    voici le code
    Code:
    #include "stm32f4xx.h"
    #include "stm32f4xx_rcc.h"
    #include "stm32f4xx_gpio.h"
    #include "stm32f4xx_sdio.h"
    #include "stm32f4xx_usart.h" // 4
    //#include "LCD2x16.c"
    //#include "dd.h"
    
    char *OutString; // string must be terminated by '\0' // 8
    char  *car_recu[];
    int j ;
    void USART3init(int BaudRate) {
    GPIO_InitTypeDef GPIO_InitStructure; // 2
    USART_InitTypeDef USART_InitStructure; // 3
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); // 5
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9; // 6
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; // 7
     GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; // 8
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // 9
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // 10
     GPIO_Init(GPIOD, &GPIO_InitStructure); // 11
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource8, GPIO_AF_USART3); // 12
     GPIO_PinAFConfig(GPIOD, GPIO_PinSource9, GPIO_AF_USART3); // 13
    
     RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); // 15
     USART_InitStructure.USART_BaudRate = 9600; // 16
     USART_InitStructure.USART_WordLength = USART_WordLength_8b; // 17
     USART_InitStructure.USART_StopBits = USART_StopBits_1; // 18
     USART_InitStructure.USART_Parity = USART_Parity_No; // 19
     USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; // 20
     USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // 21
     USART_Init(USART3, &USART_InitStructure); // 22
    
     USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); // enable IRQ on RX // 24
     NVIC_EnableIRQ(USART3_IRQn); // Enable IRQ for USART3 in NVIC // 25
    USART_Cmd(USART3, ENABLE); // 27
    }
    
    void USART3_IRQHandler(void) {
     // RX IRQ part
    
     if (USART3->SR & USART_SR_RXNE) { // if RXNE flag in SR is on then // 4
     *car_recu[j]= *USART3->DR[j]; // save received character & clear flag // 5
     //LCD_uInt16(RXch, 0x05, 1); // show ASCII on LCD // 6
     //if (RXch == 'a') LED_BL_ON; // 7
     //if (RXch == 'b') LED_BL_OFF; // 8
     //if (RXch >= 'A' && RXch <= 'Z') USART3->DR = ++RXch; // echo this character // 9
     //if (RXch == 'c') { // if 'c' => return string // 10
     //OutString = "ABCDEFGH"; // Init string & ptr // 11
     //USART_ITConfig(USART3, USART_IT_TXE, ENABLE); // 12
     //USART3->DR = *OutString++; // Send first character // 13
     }; 
     };
     // TX IRQ part
     //if (USART3->SR & USART_SR_TXE) { // If TXE flag in SR is on then // 18
     //if (*OutString != '\0') // if not end of string // 19
     //USART3->DR = *OutString++; // send next character & increment pointer // 20
    // else // else // 21
    // USART_ITConfig(USART3, USART_IT_TXE, DISABLE); // 22
     //};
    
    //}
     
    int main(void) {
     int i; 
    	int j ;
    	//LEDinit(); // 12
     //SWITCHinit(); // 13
     //LCD_init(); // 14
     USART3init(9600); // 15
    
     while (1) {
    	 while (j < long(USART3->DR))
    	 {	 	USART3->DR[j];
    		 j++;
        
    // if (GPIOE->IDR & S370) LED_GR_ON; else LED_GR_OFF; // 18
     for ( i = 0; i<100000; i++) {}; }// waste time // 19
     };
    }

    -----
    Dernière modification par Antoane ; 17/09/2015 à 18h00. Motif: Ajout balises [code]

  2. #2
    DAUDET78

    Re : demande de correction de code de la communication série entre deux cartes stm32

    Tu ne connais pas les balises [CODE]...[/CODE] ... ça rend le code plus lisible !
    J'aime pas le Grec

Discussions similaires

  1. communication série entre deux pic
    Par boch19 dans le forum Électronique
    Réponses: 1
    Dernier message: 25/05/2014, 13h21
  2. communication série rs232 et tchat entre deux pc
    Par moby75 dans le forum Électronique
    Réponses: 6
    Dernier message: 15/05/2013, 09h54
  3. Communication entre 2 cartes électroniques via RS232
    Par invite99aaa6a7 dans le forum Électronique
    Réponses: 1
    Dernier message: 20/05/2010, 00h23
  4. cherche code pour communication SPI entre deux PICs...
    Par invite8f8ffe44 dans le forum Électronique
    Réponses: 1
    Dernier message: 24/04/2008, 19h12
Découvrez nos comparatifs produits sur l'informatique et les technologies.