初中生
最后登录1970-1-1
在线时间 小时
注册时间2015-10-8
|
发表于 2015-10-13 14:08:29
|
显示全部楼层
/*********************************************END OF FILE************************************************/
/// TIM2ÖD¶ÏóÅÏ輶ÅäÖÃ
void TIM2_NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/*
* TIM_Period / Auto Reload Register(ARR) = 1000 TIM_Prescaler--71
* ÖD¶ÏÖüÆúÎa = 1/(72MHZ /72) * 1000 = 1ms
*
* TIMxCLK/CK_PSC --> TIMxCNT --> TIM_Period(ARR) --> ÖD¶Ï ÇòTIMxCNTÖØÖÃÎa0ÖØD¼Æêy
*/
void TIM2_Configuration(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
/* éèÖÃTIM2CLK Îa 72MHZ */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 , ENABLE);
TIM_DeInit(TIM2);
/* ×Ô¶ˉÖØ×°ÔؼÄ′æÆ÷ÖüÆúμÄÖμ(¼ÆêyÖμ) */
TIM_TimeBaseStructure.TIM_Period=1000;
/* àÛ¼Æ TIM_Period¸öÆμÂêoó2úéúò»¸ö¸üD»òÕßÖD¶Ï */
/* ê±ÖóÔ¤·ÖÆμêyÎa72 */
TIM_TimeBaseStructure.TIM_Prescaler= 71;
/* ¶Ôía2¿ê±Öó½øDD2éÑùμÄê±Öó·ÖÆμ,ÕaàïûóDóÃμ½ */
TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_ClearFlag(TIM2, TIM_FLAG_Update);
TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);
TIM_Cmd(TIM2, ENABLE);
//RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 , DISABLE); /*Ïè1رÕμè′yê1óÃ*/
}
/*********************************************END OF FILE************************************************/
/*
* òaÏëÖDÎÄÏÔê¾3é1|
* Dè°Ñ×Ö¿a¿½±′μ½sd¿¨éÏ£¬è»oó°Ñsd¿¨2åμ½¿a·¢°åμÄ¿¨2ÛéÏ
*/
int main(void)
{
uint8_t file_name[20];
uint8_t num = 0;
/*--------------------------------------------------------------------------------------------------------*/
/* LED 3õê¼»ˉ */
LED_GPIO_Config();
LED1_OFF;
LED2_OFF;
/*--------------------------------------------------------------------------------------------------------*/
/* òo¾§3õê¼»ˉ */
LCD_Init();
/* éèÖÃòo¾§é¨Ãè·½ÏòÎa ×óϽÇ->óòéÏ½Ç */
Lcd_GramScan( 2 );
LCD_Clear(0, 0, 320, 240, BACKGROUND);
/* 3õê¼»ˉsd¿¨ÎļtÏμí3£¬òòÎaoo×ÖμÄ×Ö¿aoíbmpí¼Æ¬·ÅÔúáËsd¿¨àïÃæ */
Sd_fs_init();
/*--------------------------------------------------------------------------------------------------------*/
/* ov7725 gpio 3õê¼»ˉ */
Ov7725_GPIO_Config();
/* ov7725 ¼Ä′æÆ÷ÅäÖÃ3õê¼»ˉ */
while(Ov7725_Init() != SUCCESS);
/* ov7725 3¡DÅoÅÏß3õê¼»ˉ */
VSYNC_Init();
Ov7725_vsync = 0;
/*-------------------------------------------------------------------------------------------------------*/
/* TIM2 ¶¨ê±ÅäÖà */
TIM2_Configuration();
/* êμÕ½¶¨ê±Æ÷μÄÖD¶ÏóÅÏ輶 */
TIM2_NVIC_Configuration();
/*-------------------------------------------------------------------------------------------------------*/
while(1)
{
if( Ov7725_vsync == 2 )
{
FIFO_PREPARE; /*FIFO×¼±¸*/
ImagDisp(); /*2é¼ˉ2¢ÏÔê¾*/
Ov7725_vsync = 0;
}
/* screen_flag Ôú°′¼üÖD¶ÏoˉêyàïÃæÖÃλ */
if( time == 500 )
{
sprintf((char *)&file_name,"/camera%d",num++);
/* éèÖÃòo¾§é¨Ãè·½ÏòÎa óòϽÇ->×óéÏ½Ç */
Lcd_GramScan( 3 );
Screen_shot(0,0,320,240,file_name);
time = 0;
/* ½Øí¼íê±ÏLED2Ãe */
LED2_TOGGLE;
}
}
}
我已经把中断优先级设置的和按键中断一样了啊 |
|