本帖最后由 ddllxxrr 于 2015-1-25 08:57 编辑
本程序是根据ASF里边的Debug Print(FreeRTOS)改写的。运得效果良好:
以下是截图:
运行这个程序首先应建立ASF工程,并选D21开发板
然后包含进FreeRTOS的两个模块具体如下:
然后点选ASF EXPLORER中的快速指导:
根据提示建立好程序。需要指出的是波特率配置那块,我用的是内8M所以数应改一下。
#include <board.h>
#define CONF_DBG_PRINT_SERCOM EDBG_CDC_MODULE
#define CONF_DBG_PRINT_BUFFER_SIZE 128
#define CONF_DBG_PRINT_GCLK_SOURCE GCLK_GENERATOR_0
#define CONF_DBG_PRINT_BAUD_RATE 9600
// This BAUD value gives 9600 baud with 48 MHz GCLK
#define CONF_DBG_PRINT_BAUD_VALUE 64281//65326
#define CONF_DBG_PRINT_SERCOM_MUX EDBG_CDC_SERCOM_MUX_SETTING
#define CONF_DBG_PRINT_PINMUX_PAD0 EDBG_CDC_SERCOM_PINMUX_PAD0
#define CONF_DBG_PRINT_PINMUX_PAD1 EDBG_CDC_SERCOM_PINMUX_PAD1
#define CONF_DBG_PRINT_PINMUX_PAD2 EDBG_CDC_SERCOM_PINMUX_PAD2
#define CONF_DBG_PRINT_PINMUX_PAD3 EDBG_CDC_SERCOM_PINMUX_PAD3
#endif // CONF_DBG_PRINT_H
具体程序如下:
/**
* \file
*
* \brief Empty user application template
*
*/
/**
* \mainpage User Application template doxygen documentation
*
* \par Empty user application template
*
* This is a bare minimum user application template.
*
* For documentation of the board, go \ref group_common_boards "here" for a link
* to the board-specific documentation.
*
* \par Content
*
* -# Include the ASF header files (through asf.h)
* -# Minimal main function that starts with a call to system_init()
* -# Basic usage of on-board LED and button
* -# "Insert application code here" comment
*
*/
/*
* Include header files for all drivers that have been imported from
* Atmel Software Framework (ASF).
*/
#include <asf.h>
uint32_t main_counter;
char main_string[] = "Main task iteration: 0x00000000\r\n";
static void main_task(void *params)
{
do {
dbg_print_str("Main task loop executing\r\n");
// Update hexadecimal 32-bit integer in string, and print it
dbg_sprint_hexint(&main_string[23], main_counter++);
dbg_print_str(main_string);
vTaskDelay(1000 / portTICK_RATE_MS);
} while(1);
}
int main (void)
{
system_init();
dbg_init();
xTaskCreate(&main_task,
(const char *)"Main task",
configMINIMAL_STACK_SIZE + 100,
NULL,
tskIDLE_PRIORITY + 2,
NULL);
vTaskStartScheduler();
}
|