標(biāo)題:
一個stm32用ST-link在sram調(diào)試的具體配置方法(源碼分享)
[打印本頁]
作者:
ygloo
時間:
2018-10-8 09:10
標(biāo)題:
一個stm32用ST-link在sram調(diào)試的具體配置方法(源碼分享)
這是我這幾天試了好久才弄好的st-link進(jìn)行sram調(diào)試,我總結(jié)一下方法,希望能幫到以后可能會的遇到這個問題的人
具體在附件上面。
附件上有詳細(xì)的sram調(diào)試配置步驟 還有一個模板, 芯片型號是stn32f103rct6 如果用的是mini板的話可以直接套用。
stm32單片機(jī)源程序如下:
#include "stm32f10x.h"
void GPIO_Configuartion(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOD|RCC_APB2Periph_AFIO,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; //LED0-->PA.8 端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽輸出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO 口速度為 50MHz
GPIO_Init(GPIOA, &GPIO_InitStructure); //初始化 GPIOA.8
GPIO_SetBits(GPIOA,GPIO_Pin_8); //PA.8 輸出高
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //LED1-->PD.2 端口配置, 推挽輸出
GPIO_Init(GPIOD, &GPIO_InitStructure); //推挽輸出 ,IO 口速度為 50MHz
GPIO_SetBits(GPIOD,GPIO_Pin_2); //PD.2 輸出高
}
void Exit_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
//開時鐘
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO,ENABLE);
//配置GPIO
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOC, &GPIO_InitStructure);
//連接中斷線
//配置外部中斷
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource15);
EXTI_InitStructure.EXTI_Line = EXTI_Line15;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource5);
EXTI_InitStructure.EXTI_Line = EXTI_Line5;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
//軟件模擬產(chǎn)生中斷
EXTI_GenerateSWInterrupt(EXTI_Line5);
if(EXTI_GetITStatus(EXTI_Line5) != RESET)
{
EXTI_ClearITPendingBit(EXTI_Line5);
}
//配置中斷優(yōu)先級
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void EXTI9_5_IRQHandler(void)
{
//delay_ms(10); //消抖
if (EXTI_GetITStatus(EXTI_Line5) != RESET )//判斷外部中斷線1是否有中斷
{
EXTI_ClearITPendingBit(EXTI_Line5);//如果有中斷,清除中斷標(biāo)志位
GPIOA->BSRR=GPIO_Pin_8;//將PB0置1
GPIOD->BSRR=GPIO_Pin_2;
}
}
void EXTI15_10_IRQHandler(void)
{
if ( EXTI_GetITStatus(EXTI_Line15) != RESET )//判斷外部中斷線8是否有中斷
{
EXTI_ClearITPendingBit(EXTI_Line15);
GPIOA->BSRR=GPIO_Pin_8;//將PB0置1
GPIOD->BRR=GPIO_Pin_2;
}
}
int main(void)
{
unsigned int i = 0;
SystemInit();
GPIO_Configuartion();
Exit_Configuration();
while (1)
{
}
}
復(fù)制代碼
所有資料51hei提供下載:
template.rar
(358.54 KB, 下載次數(shù): 10)
2018-10-8 12:53 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
調(diào)試步驟和腳本文件.rar
(596 Bytes, 下載次數(shù): 12)
2018-10-8 09:09 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
nmgbtzyf
時間:
2020-2-24 18:01
沒有調(diào)試步驟,只有腳本文件,你這純屬偏黑b呢.
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1