历史上的今天
今天是:2025年07月26日(星期六)
2021年07月26日 | MC9S12XEP100 SCI(UART)驱动程序2 - 基于uCOS-II
2021-07-26 来源:eefocus
首先先发一个自己封装的MC9S12XEP100的SCI模块(也就是UART模块)的驱动。这些代码参考了 Li Yuan http://blog.csdn.net/liyuanbhu/article/details/7764851 的代码,整个代码风格是按照uCOS-II操作系统源码的风格来写的,在此表示感谢。
目前还不是特别完整完善,但基本使用是没有问题了。
在上一章中已经发了硬件驱动部分,这里发下基于uCOS-II嵌入式操作系统的驱动部分以及顺便说下怎么用。
首先要记得到上一章中把两个文件存了,顺便还要把.h文件中的
SCI_UCOS_MODULE_ENABLE 后面改为 TRUE 以开启RTOS(嵌入式操作系统)驱动部分。
目前这个版本已经支持所有8个SCI口了。
首先是按照uCOS-II操作系统的要求写的中断服务程序。
;********************************************************************************************************
; uC/OS-II
; The Real-Time Kernel
;
; (c) Copyright 2002, Jean J. Labrosse, Weston, FL
; All Rights Reserved
;
;
; PAGED S12X Specific code
; (CODEWARRIOR)
;
; File : SCI_uCos.s
; By : Lin Shijun(http://blog.csdn.net/lin_strong)
;
; Notes : THIS FILE *MUST* BE LINKED INTO NON_BANKED MEMORY! 这个文件必须放在非分页内存中
; modified according to uC/OS-II's example. 依据uC/OS-II的模版修改。
;********************************************************************************************************
NON_BANKED: section
;********************************************************************************************************
; I/O PORT ADDRESSES I/O口地址
;********************************************************************************************************
PPAGE: equ $0015 ; Addres of PPAGE register (assuming MC9S12XEP100 part)
RPAGE: equ $0016 ; Addres of RPAGE register (assuming MC9S12XEP100 part)
EPAGE: equ $0017 ; Addres of EPAGE register (assuming MC9S12XEP100 part)
GPAGE: equ $0010 ; Addres of GPAGE register (assuming MC9S12XEP100 part)
;********************************************************************************************************
; PUBLIC DECLARATIONS 公开声明
;********************************************************************************************************
xdef SCI0_RxTxISR
xdef SCI1_RxTxISR
xdef SCI2_RxTxISR
xdef SCI3_RxTxISR
xdef SCI4_RxTxISR
xdef SCI5_RxTxISR
xdef SCI6_RxTxISR
xdef SCI7_RxTxISR
;********************************************************************************************************
; EXTERNAL DECLARATIONS 外部声明
;********************************************************************************************************
xref OSIntExit
xref OSIntNesting
xref OSTCBCur
xref SCI0_ISR_Handler
xref SCI1_ISR_Handler
xref SCI2_ISR_Handler
xref SCI3_ISR_Handler
xref SCI4_ISR_Handler
xref SCI5_ISR_Handler
xref SCI6_ISR_Handler
xref SCI7_ISR_Handler
;********************************************************************************************************
; SCI RxTx ISR
;
; Description : This routine is the uC/Probe RxTx interrupt service routine
;
; Arguments : none
;
; Notes : 1) All USER interrupts should be modeled EXACTLY like this where the only
; line to be modified is the call to your ISR_Handler and perhaps the call to
; the label name SCI0_ISR_Handler.
;********************************************************************************************************
SCI0_RxTxISR:
ldaa GPAGE ; Get current value of GPAGE register
psha ; Push GPAGE register onto current task's stack
ldaa EPAGE ; Get current value of EPAGE register
psha ; Push EPAGE register onto current task's stack
ldaa RPAGE ; Get current value of RPAGE register
psha ; Push RPAGE register onto current task's stack
ldaa PPAGE ; Get current value of PPAGE register
psha ; Push PPAGE register onto current task's stack
inc OSIntNesting ; Notify uC/OS-II about ISR
ldab OSIntNesting ; if (OSIntNesting == 1) {
cmpb #$01
bne SCI0_RxTxISR1
ldy OSTCBCur ; OSTCBCur->OSTCBStkPtr = Stack Pointer
sts 0,y ; }
SCI0_RxTxISR1:
call SCI0_ISR_Handler ; Call TxRx ISR handler. (See SCI_uCos.c)
; cli ; Optionally enable interrupts to allow interrupt nesting
call OSIntExit ; Notify uC/OS-II about end of ISR, a context switch may occur from within OSIntExit().
pula ; Get value of PPAGE register
staa PPAGE ; Store into CPU's PPAGE register
pula ; Get value of RPAGE register
staa RPAGE ; Store into CPU's RPAGE register
pula ; Get value of EPAGE register
staa EPAGE ; Store into CPU's EPAGE register
pula ; Get value of GPAGE register
staa GPAGE ; Store into CPU's GPAGE register
rti ; Return from interrupt to interrupted task.
SCI1_RxTxISR:
ldaa GPAGE ; Get current value of GPAGE register
psha ; Push GPAGE register onto current task's stack
ldaa EPAGE ; Get current value of EPAGE register
psha ; Push EPAGE register onto current task's stack
史海拾趣
|
本人有一套无线控制设备一时难以实现,请有经验的厂家或个人给于帮助.具体功能请见下面WORD文档.XX机配套遥控器使用说明书.doc,遥控产品功能要求.doc.非常感谢!!!w有代开发者请与本人联系. … 查看全部问答> |
|
请问大家使用STM8S103K3时有遇到以下问题吗? 使用STVD4.1.3+Cosmic 芯片:STM8S103K3 MCU select不管是选择STM8S103F3还是STM8S103K3都可以连接成功 但是与STM8S103F3不一样的I/O无法控制,如PD0/PB0/PB1/PB2等,其他I/O 口很正常.请问有谁 ...… 查看全部问答> |
|
请教:因为之前安装限时版的430调试软件,时间到期之后,重新安装 iar embeded workbench evaluation for msp430 4.21 是否可以继续使用? 可有哪位兄台曾经这么做过?… 查看全部问答> |
|
本帖最后由 dontium 于 2015-1-23 13:13 编辑 大家好: 我最近在用TI的PGA112,有两路信号需要送到pga112。两路信号都是双极的,大约都是+/-100mv的信号,正在参考pga112技术手册图 77中Ch0的接法连接,就是两路信号分别通过两个CA,连到Ch0和Ch1. ...… 查看全部问答> |




