|
TIVA C launchpad试用心得1.-uart调试输出实现
[复制链接]
拿到板子之前以为和之前的120板子不同,结果一模一样,只是换了个名字,那啥看来TI是在改变策略,和st和nxp的M4系列区分开来啊
参考之前的120板子,谢了个uart输出调试信息的例程,直接可用,果然是一样啊- //*****************************************************************************
- #include "inc/hw_memmap.h"
- #include "inc/hw_types.h"
- #include "driverlib/debug.h"
- #include "driverlib/fpu.h"
- #include "driverlib/gpio.h"
- #include "driverlib/pin_map.h"
- #include "driverlib/rom.h"
- #include "driverlib/sysctl.h"
- #include "utils/uartstdio.h"
- //*****************************************************************************
- //*****************************************************************************
- //
- // Print "Hello World!" to the UART on the Stellaris evaluation board.
- //
- //*****************************************************************************
- int
- main(void)
- {
- volatile unsigned long ulLoop;
- //
- // Enable lazy stacking for interrupt handlers. This allows floating-point
- // instructions to be used within interrupt handlers, but at the expense of
- // extra stack usage.
- //
- ROM_FPULazyStackingEnable();
- //
- // Set the clocking to run directly from the crystal.
- //
- ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
- SYSCTL_OSC_MAIN);
-
- //
- // Enable the GPIO port that is used for the on-board LED.
- //
- ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
- //
- // Enable the GPIO pins for the LED (PF2 & PF3).
- //
- ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);
-
- //
- // Initialize the UART.
- //
- ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
- ROM_GPIOPinConfigure(GPIO_PA0_U0RX);
- ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
- ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
- UARTStdioInit(0);
- //
- // Hello!
- //
- UARTprintf("Hello, world!\n");
-
- //
- // We are finished. Hang around doing nothing.
- //
- while(1)
- {
- //
- // Turn on the BLUE LED.
- //
- GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
- //
- // Delay for a bit.
- //
- SysCtlDelay(SysCtlClockGet() / 10 / 3);
- //
- // Turn off the BLUE LED.
- //
- GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
-
- //
- // Delay for a bit.
- //
- SysCtlDelay(SysCtlClockGet() / 10 / 3);
- //
- // Hello!
- //
- UARTprintf("Hello, world!\n");
- }
- }
复制代码
1.0_My_Hello.rar
(28.24 KB, 下载次数: 10, 售价: 1 分芯积分)
|
|