/*
* 功能:CSL中cache module和timer module的使用示例
* 说明: 需要手动加入库文件:C:/CCStudio_v3.1/C6000/csl/lib/cslDM642.lib,建议到TI网站下载最新的CSL库更新,否则有些模块可能会出问题
* 设计者: 3881
* 日期: 2010-5-28
*/
#include <csl.h> //顶层应用程序模块,用于初始化CSL。
main初始化部分,分三部分代码麻烦分析,main调用,BSP部分,GUI初始化部分
<div class="blockcode"><blockquote>int main(void)
{
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Global MSP (MCU Support Package) initialization
*/
HAL_Init()
/* Configure the system clock to 180 MHz */
SystemClock_Config()
BSP_Config()
/* Configure LED1 and LED3 */
BSP_LED_Init(LED1)
BSP_LED_Init(LED3)
file_isok = FatFS_Init()
/* Thread 1 definition */
osThreadDef(LED1, LED_Thread1, osPriorityNormal, 0, configMINIMAL_STACK_SIZE)
/* Thread 2 definition */
osThreadDef(LED3, LED_Thread2, osPriorityNormal, 0, configMINIMAL_STACK_SIZE)
osThreadDef(GUI_TASKID, GUI_Thread, osPriorityNormal, 0, 2048)
/* Start thread 1 */
LEDThread1Handle = osThreadCreate (osThread(LED1), NULL)
/* Start thread 2 */
LEDThread2Handle = osThreadCreate (osThread(LED3), NULL)
GUIThreadHandle = osThreadCreate (osThread(GUI_TASKID), NULL)
//init_gui()
/* Start scheduler */
osKernelStart()
/* We should never get here as control is now taken by the scheduler */
for()
}
void BSP_Config(void)
{
/* Initializes the SDRAM device */
BSP_SDRAM_Init()
/* Initialize the Touch screen */
BSP_TS_Init(800, 480)
//BSP_TS_Init(320, 240)
/* Enable the CRC Module */
__HAL_RCC_CRC_CLK_ENABLE()
__HAL_RCC_BKPSRAM_CLK_ENABLE()
/* Compute the prescaler value to have TIM3 counter clock equal to 10 KHz */
uwPrescalerValue = (uint32_t) ((SystemCoreClock /2) / 10000) - 1
/* Set TIMx instance */
TimHandle.Instance = TIM3
/* Initialize TIM3 peripheral as follows:
+ Period = 500 - 1
+ Prescaler = ((SystemCoreClock/2)/10000) - 1
+ ClockDivision = 0
+ Counter direction = Up
*/
TimHandle.Init.Period = 500 - 1
TimHandle.Init.Prescaler = uwPrescalerValue
TimHandle.Init.ClockDivision = 0
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP
if(HAL_TIM_Base_Init(&TimHandle) != HAL_OK)
{
while(1)
{
}
}
/*##-2- Start the TIM Base generation in interrupt mode ####################*/
/* Start Channel1 */
if(HAL_TIM_Base_Start_IT(&TimHandle) != HAL_OK)
{
while(1)
{
}
}
}
CSL:Chip Support Library 芯片支持库BIOS: TI DSP的实时操作系统
基于TI的DSP芯片的应用程序分为两种:一般应用程序,和DSP/BIOS应用程序。为简化编程,TI提供了一套C的编程接口,它以API和宏的形式封装了TI的所有硬件模块,这套接口统称DSP/BIOS。DSP/BIOS包含以下模块:System(包含MEM,SYS对象),Instrumentation(包含LOG,STS对象),Scheduling(包含CLK,PRD,HWI,SWI等等对象),Synchronization(包含SEM,MBX,QUE等等对象),Input/Output(包含RTDX,HST等等对象),Chip Support Library(包含DMA,GPIO等等对象)。
引自:http://blog.csdn.net/wangkeyen/article/details/8161237
#include <csl_timer.h>
TIMER_Handle hTimer0
TIMER_Config TimerConfig =
{
TIMER_CTL_RMK
(
TIMER_CTL_SPND_EMUSTOP,
TIMER_CTL_INVINP_NO,
TIMER_CTL_CLKSRC_CPUOVR8, //定时器的频率是CPU频率的1/8
TIMER_CTL_CP_PULSE,
TIMER_CTL_HLD_NO, //时钟有效
TIMER_CTL_GO_NO,//时钟没有开启
TIMER_CTL_PWID_TWO,
TIMER_CTL_DATOUT_1,
TIMER_CTL_INVOUT_YES,
TIMER_CTL_FUNC_TOUT
),
0xffffffff, //定时器计数值,一旦达到该值就会产生中断,该计数值可以最大计数57秒不中断
0x0 //计数器初值
}
void Timer0_Cnt()
{
float timecnt,timeval
hTimer0 = TIMER_open(TIMER_DEV0,TIMER_OPEN_RESET) //打开定时器0,返回操作句柄
TIMER_config(hTimer0,&TimerConfig)//使用配置结构体配置定时器0
TIMER_start(hTimer0) //开始计数
/***********此处为要计时的程序段***********/
timecnt = TIMER_getCount(hTimer0) //获取定时器的计数值
TIMER_pause(hTimer0) //停止计数
timeval = (float)(timecnt*8/600000000)//将计数值转化为时间值
printf("The time spended is %fs",timeval) //打印程序运行时间
}
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)