Bonjour à tous !
Dans mon projet réalisé sous AVR32, je souhaite réaliser deux type de communication sur ma carte atmel AT32UC3A0512.
La première est la communication série et la seconde une communication telnet.
Séparément elle fonctionne mais lorsque je relis les 2 dans mon main, je ne peut communiquer qu'avec une d'entre elle (celle situé en premier)
Voici le code.
Code:/* This source file is part of the ATMEL AVR-UC3-SoftwareFramework-1.7.0 Release */ /*This file has been prepared for Doxygen automatic documentation generation.*/ /*! \file ********************************************************************* * * \brief FreeRTOS and lwIP example for AVR32 UC3. * * - Compiler: GNU GCC for AVR32 * - Supported devices: All AVR32 devices can be used. * - AppNote: * * \author Atmel Corporation: http://www.atmel.com \n * Support and FAQ: http://support.atmel.no/ * *****************************************************************************/ /* Copyright (c) 2009 Atmel Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. The name of Atmel may not be used to endorse or promote products derived * from this software without specific prior written permission. * * 4. This software may only be redistributed and used in connection with an Atmel * AVR product. * * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE * */ /* Environment include files. */ //#include <stdlib.h> //#include <string.h> #include "pm.h" #include "flashc.h" /* Scheduler include files. */ #include "FreeRTOS.h" #include "task.h" /* Demo file headers. */ #include "partest.h" #include "SERIAL/serial.h" #include "ethernet.h" #include "netif/etharp.h" #include "flash.h" /* Serial files */ //#include <avr32/io.h> #include "compiler.h" #include "board.h" #include "power_clocks_lib.h" #include "gpio.h" #include "SOFTWARE_FRAMEWORK/DRIVERS/USART/usart.h" /* Priority definitions for most of the tasks in the demo application. */ #define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) #define mainETH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) #define display_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) /* Baud rate used by the serial port tasks. */ #define mainCOM_BAUD_RATE ( ( unsigned portLONG ) 57600 ) #define mainCOM_BUFFER_LEN ( ( unsigned portLONG ) 70 ) /* An address in the internal Flash used to count resets. This is used to check that the demo application is not unexpectedly resetting. */ #define mainRESET_COUNT_ADDRESS ( ( void * ) 0xC0000000 ) # define EXAMPLE_TARGET_PBACLK_FREQ_HZ FOSC0 // PBA clock target frequency, in Hz #if BOARD == EVK1100 # define EXAMPLE_USART (&AVR32_USART1) # define EXAMPLE_USART_RX_PIN AVR32_USART1_RXD_0_0_PIN # define EXAMPLE_USART_RX_FUNCTION AVR32_USART1_RXD_0_0_FUNCTION # define EXAMPLE_USART_TX_PIN AVR32_USART1_TXD_0_0_PIN # define EXAMPLE_USART_TX_FUNCTION AVR32_USART1_TXD_0_0_FUNCTION # define EXAMPLE_USART_CLOCK_MASK AVR32_USART1_CLK_PBA # define EXAMPLE_PDCA_CLOCK_HSB AVR32_PDCA_CLK_HSB # define EXAMPLE_PDCA_CLOCK_PB AVR32_PDCA_CLK_PBA #elif BOARD == EVK1101 # define EXAMPLE_USART (&AVR32_USART1) # define EXAMPLE_USART_RX_PIN AVR32_USART1_RXD_0_0_PIN # define EXAMPLE_USART_RX_FUNCTION AVR32_USART1_RXD_0_0_FUNCTION # define EXAMPLE_USART_TX_PIN AVR32_USART1_TXD_0_0_PIN # define EXAMPLE_USART_TX_FUNCTION AVR32_USART1_TXD_0_0_FUNCTION # define EXAMPLE_USART_CLOCK_MASK AVR32_USART1_CLK_PBA # define EXAMPLE_PDCA_CLOCK_HSB AVR32_PDCA_CLK_HSB # define EXAMPLE_PDCA_CLOCK_PB AVR32_PDCA_CLK_PBA #elif BOARD == UC3C_EK # define EXAMPLE_USART (&AVR32_USART2) # define EXAMPLE_USART_RX_PIN AVR32_USART2_RXD_0_1_PIN # define EXAMPLE_USART_RX_FUNCTION AVR32_USART2_RXD_0_1_FUNCTION # define EXAMPLE_USART_TX_PIN AVR32_USART2_TXD_0_1_PIN # define EXAMPLE_USART_TX_FUNCTION AVR32_USART2_TXD_0_1_FUNCTION # define EXAMPLE_USART_CLOCK_MASK AVR32_USART2_CLK_PBA # define EXAMPLE_PDCA_CLOCK_HSB AVR32_PDCA_CLK_HSB # define EXAMPLE_PDCA_CLOCK_PB AVR32_PDCA_CLK_PBB #elif BOARD == EVK1104 # define EXAMPLE_USART (&AVR32_USART1) # define EXAMPLE_USART_RX_PIN AVR32_USART1_RXD_0_0_PIN # define EXAMPLE_USART_RX_FUNCTION AVR32_USART1_RXD_0_0_FUNCTION # define EXAMPLE_USART_TX_PIN AVR32_USART1_TXD_0_0_PIN # define EXAMPLE_USART_TX_FUNCTION AVR32_USART1_TXD_0_0_FUNCTION # define EXAMPLE_USART_CLOCK_MASK AVR32_USART1_CLK_PBA # define EXAMPLE_PDCA_CLOCK_HSB AVR32_PDCA_CLK_HSB # define EXAMPLE_PDCA_CLOCK_PB AVR32_PDCA_CLK_PBA #elif BOARD == EVK1105 # define EXAMPLE_USART (&AVR32_USART0) # define EXAMPLE_USART_RX_PIN AVR32_USART0_RXD_0_0_PIN # define EXAMPLE_USART_RX_FUNCTION AVR32_USART0_RXD_0_0_FUNCTION # define EXAMPLE_USART_TX_PIN AVR32_USART0_TXD_0_0_PIN # define EXAMPLE_USART_TX_FUNCTION AVR32_USART0_TXD_0_0_FUNCTION # define EXAMPLE_USART_CLOCK_MASK AVR32_USART0_CLK_PBA # define EXAMPLE_PDCA_CLOCK_HSB AVR32_PDCA_CLK_HSB # define EXAMPLE_PDCA_CLOCK_PB AVR32_PDCA_CLK_PBA #elif BOARD == STK600_RCUC3L0 # define EXAMPLE_USART (&AVR32_USART1) # define EXAMPLE_USART_RX_PIN AVR32_USART1_RXD_0_1_PIN # define EXAMPLE_USART_RX_FUNCTION AVR32_USART1_RXD_0_1_FUNCTION // For the RX pin, connect STK600.PORTE.PE3 to STK600.RS232 SPARE.RXD # define EXAMPLE_USART_TX_PIN AVR32_USART1_TXD_0_1_PIN # define EXAMPLE_USART_TX_FUNCTION AVR32_USART1_TXD_0_1_FUNCTION // For the TX pin, connect STK600.PORTE.PE2 to STK600.RS232 SPARE.TXD # define EXAMPLE_USART_CLOCK_MASK AVR32_USART1_CLK_PBA # define EXAMPLE_PDCA_CLOCK_HSB AVR32_PDCA_CLK_HSB # define EXAMPLE_PDCA_CLOCK_PB AVR32_PDCA_CLK_PBA #elif BOARD == UC3L_EK # define EXAMPLE_USART (&AVR32_USART3) # define EXAMPLE_USART_RX_PIN AVR32_USART3_RXD_0_0_PIN # define EXAMPLE_USART_RX_FUNCTION AVR32_USART3_RXD_0_0_FUNCTION # define EXAMPLE_USART_TX_PIN AVR32_USART3_TXD_0_0_PIN # define EXAMPLE_USART_TX_FUNCTION AVR32_USART3_TXD_0_0_FUNCTION # define EXAMPLE_USART_CLOCK_MASK AVR32_USART3_CLK_PBA # define EXAMPLE_TARGET_DFLL_FREQ_HZ 96000000 // DFLL target frequency, in Hz # define EXAMPLE_TARGET_MCUCLK_FREQ_HZ 12000000 // MCU clock target frequency, in Hz # undef EXAMPLE_TARGET_PBACLK_FREQ_HZ # define EXAMPLE_TARGET_PBACLK_FREQ_HZ 12000000 // PBA clock target frequency, in Hz # define EXAMPLE_PDCA_CLOCK_HSB AVR32_PDCA_CLK_HSB # define EXAMPLE_PDCA_CLOCK_PB AVR32_PDCA_CLK_PBA #endif #if !defined(EXAMPLE_USART) || \ !defined(EXAMPLE_USART_RX_PIN) || \ !defined(EXAMPLE_USART_RX_FUNCTION) || \ !defined(EXAMPLE_USART_TX_PIN) || \ !defined(EXAMPLE_USART_TX_FUNCTION) # error The USART configuration to use in this example is missing. #endif #if BOARD == UC3L_EK /*! \name Parameters to pcl_configure_clocks(). */ //! @{ static scif_gclk_opt_t gc_dfllif_ref_opt = { SCIF_GCCTRL_SLOWCLOCK, 0, OFF }; static pcl_freq_param_t pcl_dfll_freq_param = { .main_clk_src = PCL_MC_DFLL0, .cpu_f = EXAMPLE_TARGET_MCUCLK_FREQ_HZ, .pba_f = EXAMPLE_TARGET_PBACLK_FREQ_HZ, .pbb_f = EXAMPLE_TARGET_PBACLK_FREQ_HZ, .dfll_f = EXAMPLE_TARGET_DFLL_FREQ_HZ, .pextra_params = &gc_dfllif_ref_opt }; //! @} #endif //! //! \fn main //! \brief start the software here //! 1) Initialize the microcontroller and the shared hardware resources //! of the board. //! 2) Launch the IP modules. //! 3) Start FreeRTOS. //! \return 42, which should never occur. //! \note //! int main( void ) { static const gpio_map_t USART_GPIO_MAP = { {EXAMPLE_USART_RX_PIN, EXAMPLE_USART_RX_FUNCTION}, {EXAMPLE_USART_TX_PIN, EXAMPLE_USART_TX_FUNCTION} }; // USART options. static const usart_options_t USART_OPTIONS = { .baudrate = 57600, .charlength = 8, .paritytype = USART_NO_PARITY, .stopbits = USART_1_STOPBIT, .channelmode = USART_NORMAL_CHMODE }; // Ajout pour la communication série // #if BOARD == UC3L_EK // Note: on the AT32UC3L-EK board, there is no crystal/external clock connected // to the OSC0 pinout XIN0/XOUT0. We shall then program the DFLL and switch the // main clock source to the DFLL. pcl_configure_clocks(&pcl_dfll_freq_param); // Note: since it is dynamically computing the appropriate field values of the // configuration registers from the parameters structure, this function is not // optimal in terms of code size. For a code size optimal solution, it is better // to create a new function from pcl_configure_clocks_dfll0() and modify it // to use preprocessor computation from pre-defined target frequencies. #else // Configure Osc0 in crystal mode (i.e. use of an external crystal source, with // frequency FOSC0) with an appropriate startup time then switch the main clock // source to Osc0. pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP); #endif // Assign GPIO to USART. gpio_enable_module(USART_GPIO_MAP, sizeof(USART_GPIO_MAP) / sizeof(USART_GPIO_MAP[0])); // Initialize USART in RS232 mode. usart_init_rs232(EXAMPLE_USART, &USART_OPTIONS, EXAMPLE_TARGET_PBACLK_FREQ_HZ); // Hello world! usart_write_line(EXAMPLE_USART, "Bienvenue sur la carte d'atmel! (tapez votre texte)\n"); // Press enter to continue. while (usart_get_echo_line(EXAMPLE_USART) == USART_FAILURE); // Get and echo characters until end of line. usart_write_line(EXAMPLE_USART, "A bientot.\n"); //*** Sleep mode // This program won't be doing anything else from now on, so it might as well // sleep. // Modules communicating with external circuits should normally be disabled // before entering a sleep mode that will stop the module operation. // Make sure the USART dumps the last message completely before turning it off. while(!usart_tx_empty(EXAMPLE_USART)); pcl_disable_module(EXAMPLE_USART_CLOCK_MASK); // Since we're going into a sleep mode deeper than IDLE, all HSB masters must // be stopped before entering the sleep mode. pcl_disable_module(EXAMPLE_PDCA_CLOCK_HSB); pcl_disable_module(EXAMPLE_PDCA_CLOCK_PB); // If there is a chance that any PB write operations are incomplete, the CPU // should perform a read operation from any register on the PB bus before // executing the sleep instruction. AVR32_INTC.ipr[0]; // Dummy read // Go to STATIC sleep mode. SLEEP(AVR32_PM_SMODE_STATIC); while (TRUE); // Fin de l'ajout pour la communication série// volatile avr32_pm_t* pm = &AVR32_PM; /* 1) Initialize the microcontroller and the shared hardware resources of the board. */ /* Switch to external oscillator 0 */ pm_switch_to_osc0( pm, FOSC0, OSC0_STARTUP ); /* Setup PLL0 on OSC0, mul+1=16 ,divisor by 1, lockcount=16, ie. 12Mhzx16/1 = 192MHz output. Extra div by 2 => 96MHz */ pm_pll_setup(pm, /* volatile avr32_pm_t* pm */ 0, /* unsigned int pll */ 15, /* unsigned int mul */ 1, /* unsigned int div, Sel Osc0/PLL0 or Osc1/Pll1 */ 0, /* unsigned int osc */ 16); /* unsigned int lockcount */ pm_pll_set_option( pm, 0, // pll0 0, // Choose the range 160-240MHz. 1, // div2 0 ); // wbwdisable /* Enable PLL0 */ pm_pll_enable(pm,0); /* Wait for PLL0 locked */ pm_wait_for_pll0_locked(pm) ; /* switch to clock */ pm_cksel( pm, 1, 1, 1, 0, 1, 0 ); flashc_set_wait_state( 1 ); pm_switch_to_clock( pm, AVR32_PM_MCCTRL_MCSEL_PLL0 ); /* Setup the LED's for output. */ vParTestInitialise(); /* Start Display Task */ vDisplay_Start(display_TASK_PRIORITY); /* Start the flash tasks just to provide visual feedback that the demo is executing. */ vStartLEDFlashTasks( mainLED_TASK_PRIORITY ); /* 2) Start the ethernet tasks launcher. */ vStartEthernetTaskLauncher( configMAX_PRIORITIES ); /* Start la communication série. */ xComPortHandle pxPort = xUsartInit(serCOM1, mainCOM_BAUD_RATE, mainCOM_BUFFER_LEN, mainCOM_BUFFER_LEN); usUsartPutString (pxPort,xUsartPutChar, portMAX_DELAY); /* 3) Start FreeRTOS. */ vTaskStartScheduler(); /* Will only reach here if there was insufficient memory to create the idle task. */ return 0; } /*-----------------------------------------------------------*/
Comment puis je résoudre ce problème ?
Merci d'avance
-----