//***************************************************************************** // // bitband.c - Bit-band manipulation example. // // Copyright (c) 2012-2017 Texas Instruments Incorporated. All rights reserved. // Software License Agreement // // Texas Instruments (TI) is supplying this software for use solely and // exclusively on TI's microcontroller products. The software is owned by // TI and/or its suppliers, and is protected under applicable copyright // laws. You may not combine this software with "viral" open-source // software in order to form a larger program. // // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES, FOR ANY REASON WHATSOEVER. // // This is part of revision 2.1.4.178 of the EK-TM4C123GXL Firmware Package. // //***************************************************************************** #include <stdint.h> #include <stdbool.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/gpio.h" #include "driverlib/fpu.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #include "driverlib/systick.h" #include "driverlib/rom.h" #include "driverlib/uart.h" #include "utils/uartstdio.h" //***************************************************************************** // //! \addtogroup example_list //! <h1>Bit-Banding (bitband)</h1> //! //! This example application demonstrates the use of the bit-banding //! capabilities of the Cortex-M4F microprocessor. All of SRAM and all of the //! peripherals reside within bit-band regions, meaning that bit-banding //! operations can be applied to any of them. In this example, a variable in //! SRAM is set to a particular value one bit at a time using bit-banding //! operations (it would be more efficient to do a single non-bit-banded write; //! this simply demonstrates the operation of bit-banding). // //***************************************************************************** //***************************************************************************** // // The value that is to be modified via bit-banding. // //***************************************************************************** static volatile uint32_t g_ui32Value; //***************************************************************************** // // The error routine that is called if the driver library encounters an error. // //***************************************************************************** #ifdef DEBUG void __error__(char *pcFilename, uint32_t ui32Line) {while(1){//// Hang on runtime error.//} } #endif //***************************************************************************** // // Configure the UART and its pins. This must be called before UARTprintf(). // //***************************************************************************** void ConfigureUART(void) {// Enable GPIOCROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOB)));//// Enable UART1//ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_UART1)));//// Configure GPIO Pins for UART mode.//ROM_GPIOPinConfigure(GPIO_PB0_U1RX);ROM_GPIOPinConfigure(GPIO_PB1_U1TX);ROM_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);//// Use the internal 16MHz oscillator as the UART clock source.//UARTClockSourceSet(UART1_BASE, UART_CLOCK_PIOSC);UARTConfigSetExpClk(UART1_BASE,16000000,115200,UART_CONFIG_PAR_NONE|UART_CONFIG_STOP_ONE|UART_CONFIG_WLEN_8);UARTEnable(UART1_BASE); } //***************************************************************************** // // This example demonstrates the use of bit-banding to set individual bits // within a word of SRAM. // //***************************************************************************** int main(void) {//// Set the clocking to run directly from the crystal.//ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);//// Initialize the UART interface.//ConfigureUART();//// Loop forever.//while(1){UARTCharPut(UART1_BASE,0xAA);} }
xyz549040622:
使用第三方的库uartstdio进行输出
//***************************************************************************** // // bitband.c - Bit-band manipulation example. // // Copyright (c) 2012-2017 Texas Instruments Incorporated.All rights reserved. // Software License Agreement //// Texas Instruments (TI) is supplying this software for use solely and // exclusively on TI's microcontroller products. The software is owned by // TI and/or its suppliers, and is protected under applicable copyright // laws. You may not combine this software with "viral" open-source // software in order to form a larger program. //// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES, FOR ANY REASON WHATSOEVER. //// This is part of revision 2.1.4.178 of the EK-TM4C123GXL Firmware Package. // //*****************************************************************************#include <stdint.h> #include <stdbool.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #include "driverlib/rom.h" #include "driverlib/uart.h" #include "utils/uartstdio.h"//***************************************************************************** // //! \addtogroup example_list //! <h1>Bit-Banding (bitband)</h1> //! //! This example application demonstrates the use of the bit-banding //! capabilities of the Cortex-M4F microprocessor.All of SRAM and all of the //! peripherals reside within bit-band regions, meaning that bit-banding //! operations can be applied to any of them.In this example, a variable in //! SRAM is set to a particular value one bit at a time using bit-banding //! operations (it would be more efficient to do a single non-bit-banded write; //! this simply demonstrates the operation of bit-banding). // //*****************************************************************************//***************************************************************************** // // The value that is to be modified via bit-banding. // //***************************************************************************** static volatile uint32_t g_ui32Value;//***************************************************************************** // // The error routine that is called if the driver library encounters an error. // //***************************************************************************** #ifdef DEBUG void __error__(char *pcFilename, uint32_t ui32Line) {while(1){//// Hang on runtime error.//} } #endif//***************************************************************************** // // Configure the UART and its pins.This must be called before UARTprintf(). // //***************************************************************************** void ConfigureUART1(void) {//// Enable the GPIO Peripheral used by the UART.//ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOB)));//// Enable UART0//ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_UART1)));//// Configure GPIO Pins for UART mode.//ROM_GPIOPinConfigure(GPIO_PB0_U1RX);ROM_GPIOPinConfigure(GPIO_PB1_U1TX);ROM_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);//// Use the internal 16MHz oscillator as the UART clock source.//UARTClockSourceSet(UART1_BASE, UART_CLOCK_PIOSC);//// Initialize the UART for console I/O.//UARTStdioConfig(1, 115200, 16000000); } //***************************************************************************** // // This example demonstrates the use of bit-banding to set individual bits // within a word of SRAM. // //***************************************************************************** int main(void) {// Set the clocking to run directly from the crystal.//ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);//// Initialize the UART interface.//ConfigureUART1();UARTprintf("Hello this is TM4C123H6PM USART1!\n");UARTprintf("USART1 by PB0 and PB1!\n");UARTprintf("USART1 by stdio.h!\n"); // Loop forever. //while(1){ } }
Susan Yang:
谢谢分享!