- 9
- 0
- 约3.17万字
- 约 33页
- 2017-05-24 发布于湖北
- 举报
STM8的C语言编程课件
?????????????????????
? ??????????? ?STM8的C语言编程(1)--基本程序与启动代码分析
?
现在几乎所有的单片机都能用C语言编程了,采用C语言编程确实能带来很多好处,至少可读性比汇编语言强多了。
在STM8的开发环境中,可以通过新建一个工程,自动地建立起一个C语言的框架,生成后开发环境会自动生成2个C语言的程序,一个是main.c,另一个是stm8_interrupt_vector.c。main.c中就是一个空的main()函数,如下所示:
?
/* MAIN.C file
?*
?* Copyright (c) 2002-2005 STMicroelectronics
?*/
?
?
main()
{
?????? while (1);
}
?
而在stm8_interrupt_vector.c中,就是声明了对应该芯片的中断向量,如下所示:
/*??? BASIC INTERRUPT VECTOR TABLE FOR STM8 devices
?*?? Copyright (c) 2007 STMicroelectronics
?*/
?
typedef void @far (*interrupt_handler_t)(void);
?
struct interrupt_vector {
?????? unsigned char interrupt_instruction;
?????? interrupt_handler_t interrupt_handler;
};
?
@far @interrupt void NonHandledInterrupt (void)
{
?????? /* in order to detect unexpected events during development,
?????? ?? it is recommended to set a breakpoint on the following instruction
?????? */
?????? return;
}
?
extern void _stext();???? /* startup routine */
?
struct interrupt_vector const _vectab[] = {
?????? {0x82, (interrupt_handler_t)_stext}, /* reset */
?????? {0x82, NonHandledInterrupt}, /* trap? */
?????? {0x82, NonHandledInterrupt}, /* irq0? */
?????? {0x82, NonHandledInterrupt}, /* irq1? */
?????? {0x82, NonHandledInterrupt}, /* irq2? */
?????? {0x82, NonHandledInterrupt}, /* irq3? */
?????? {0x82, NonHandledInterrupt}, /* irq4? */
?????? {0x82, NonHandledInterrupt}, /* irq5? */
?????? {0x82, NonHandledInterrupt}, /* irq6? */
?????? {0x82, NonHandledInterrupt}, /* irq7? */
?????? {0x82, NonHandledInterrupt}, /* irq8? */
?????? {0x82, NonHandledInterrupt}, /* irq9? */
?????? {0x82, NonHandledInterrupt}, /* irq10 */
?????? {0x82, NonHandledInterrupt}, /* irq11 */
?????? {0x82, NonHandledInterrupt}, /* irq12 */
?????? {0x82, NonHandledInterrupt}, /* irq13 */
?????? {0x82, NonHandledInterrupt}, /* irq14 */
?????? {0x82, NonHandledInterrupt}, /* irq15 */
?????? {0x82, NonHandledInterrupt}, /* irq16 */
?????? {0x82, NonHandledInterrupt}, /* irq17 */
?????? {0x82, NonHandledInterrupt}, /* irq
您可能关注的文档
最近下载
- 2024年青海省中考语文试卷.doc VIP
- MLflow:MLflow模型版本控制教程.docx
- 症状严重程度每日记录量表的引进及信效度检验.doc VIP
- 英语专业四级考试阅读分析.ppt VIP
- 2025年拍卖师绿色拍卖与可持续发展理念在企业中的推行专题试卷及解析.pdf VIP
- 2025年金融风险管理师环境衍生品与碳交易市场专题试卷及解析.pdf VIP
- 面向文化遗产保护的AI伦理治理框架.pdf VIP
- 人教版高中化学选择性必修3全册教学课件.pptx
- 2025年信息系统安全专家物理渗透测试技术专题试卷及解析.pdf VIP
- 埃及风荷载设计规范EGYPT_Chapter-7-Wind-Loads-Egyptian-Load-Code.pdf VIP
原创力文档

文档评论(0)