资源简介
英飞凌 IRMCF143 系列芯片电机驱动样例代码,没有做过修改,电机驱动系列芯片程序结构可以用作参考
代码片段和文件信息
#include “irmcx1xx.h“
#include “asyncDriver.h“
#include “utils.h“
#include “timer.h“
#include “MotorCtrl.h“
#include “PeripheralRegs.h“
xdata unsigned char txFifo [ XFIFO_SIZE ]; // xmit fifo
xdata unsigned char rxFifo [ RFIFO_SIZE ]; // rcv fifo
xdata unsigned char xFifoHead = 0; // xmit fifo head index
xdata unsigned char xFifoTail = 0; // xmit fifo tail index
xdata unsigned char xFifoCount = 0; // xmit fifo count of chars in fifo
xdata unsigned char txDisabled = 0;// xmitter has finished outputting chars
xdata unsigned char rFifoHead = 0; // recv fifo head index
xdata unsigned char rFifoTail = 0; // recv fifo tail index
xdata unsigned char rFifoCount = 0; // recv fifo count of chars in fifo
xdata unsigned int RcvError = 0;
xdata unsigned int FifoOverrun = 0;
xdata unsigned int RcvChars = 0;
#define SIOINTNUM 4
static void sioIsr ( void ) interrupt SIOINTNUM using 2
{
char ch;
char stat;
// Check UART status reg for received data available.
if ( ( ( stat = USTAT ) & 0x01 ) != 0 )
{
ch = URXD; // Read the char from the data register
++RcvChars;
// Check for receive errors
if ( ( stat & 0x3C ) != 0 )
++RcvError;
if ( rFifoRoom ( ) ) // If there is no room drop the char
rFifoPutChar ( ch );
else // Count FIFO overruns
++FifoOverrun;
}
// Check UART status register for transmit buffer empty.
if (stat & 0x02)
{
if ( xFifoGetChar ( &ch ) == 1 )
{
UTXD = ch;
}
else
{
UCTRL &= 0xBF;
txDisabled = 1;
}
}
}
void sioInit ( void )
{
char ch;
RcvError = 0;
FifoOverrun = 0;
flushTx ( );
flushRx ( );
disable_isr ( SIOINTNUM );
// Set I/O pins to use the UART
// IOCON0 = 0x7A; // use UART 0 enable sync output on P1.3 and enable PWM outputs for test
IOCON0 = 0x42; // use UART 0 enable sync output on P1.3 disable AOPWMx
// Read the UART data register to make sure the receive buffer
// is empty.
ch = URXD;
ch = URXD;
// Set UART to 8-bit mode (no parity) and enable rcv (NOT xmt)
// Bit 7 unused
// Bit 6 = 1 enables xmt
// Bit 5 = 0 turn off hunt mode
// Bit 4 = 1 enables rcv
// Bit 3 = 0 do not discard bad rcv chars
// Bit 2 = 0 used only in 9-bit mode
// Bits 1 0 = 00 8-bit UART mode
UCTRL = 0x10; // enable rcv 8 bit mode
// Set uart interrupt to low priority (your choice: hi or lo)
PU0 = 1; // (IP from any page)
enable_isr ( SIOINTNUM );
}
// Flushes the transmitter. Any character already in the UART will be
// transmitted.
void flushTx ( )
{
disable_isr ( SIOINTNUM );
xFifoHead = 0;
xFifoTail = 0;
xFifoCount = 0;
txDisabled = 1;
enable_isr ( SIOINTNUM );
}
// Flushes the receiver by clearing the receive fifo. Any character
// currently being received will be added to the fifo.
void flushRx ( )
{
disable_isr ( SIOINTNUM );
rFifoHead = 0;
rFifoTail = 0;
rFifoCount = 0;
enable_isr
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 72238 2019-03-13 17:49 IRSamples143\IRsamples.uvgui.Lenovo
....... 9663 2019-03-13 17:39 IRSamples143\IRsamples.uvopt
....... 15769 2019-03-13 17:39 IRSamples143\IRsamples.uvproj
文件 1802 2015-04-03 14:27 IRSamples143\IRsamples_Opt.Bak
文件 2730 2015-03-04 10:38 IRSamples143\IRsamples_Uv2.Bak
文件 11062 2019-03-13 17:38 IRSamples143\Output\asyncDriver.lst
文件 15687 2019-03-13 17:38 IRSamples143\Output\asyncDriver.obj
文件 7128 2015-04-03 14:28 IRSamples143\Output\Coherent.lst
文件 920 2015-04-03 14:28 IRSamples143\Output\Coherent.obj
文件 8978 2019-03-13 17:38 IRSamples143\Output\EepromI2C.lst
文件 14439 2019-03-13 17:38 IRSamples143\Output\EepromI2C.obj
文件 113708 2019-03-13 17:38 IRSamples143\Output\IRsamples
文件 1378 2019-03-13 17:38 IRSamples143\Output\IRsamples.build_log.htm
文件 23487 2019-03-13 17:38 IRSamples143\Output\IRsamples.hex
文件 426 2019-03-13 17:38 IRSamples143\Output\IRsamples.lnp
文件 75022 2019-03-13 17:38 IRSamples143\Output\IRsamples.m51
文件 233 2019-03-13 17:38 IRSamples143\Output\IRsamples.ORC
文件 734 2015-04-03 14:28 IRSamples143\Output\IRsamples.plg
文件 4714 2019-03-13 17:38 IRSamples143\Output\main.lst
文件 16732 2019-03-13 17:38 IRSamples143\Output\main.obj
文件 3516 2019-03-13 17:38 IRSamples143\Output\MceBoot.lst
文件 5913 2019-03-13 17:38 IRSamples143\Output\MceBoot.obj
文件 22129 2019-03-13 17:38 IRSamples143\Output\MotorCtrl.lst
文件 43049 2019-03-13 17:38 IRSamples143\Output\MotorCtrl.obj
文件 3707 2015-04-03 14:28 IRSamples143\Output\PeripheralRegs.lst
文件 6182 2015-04-03 14:28 IRSamples143\Output\PeripheralRegs.obj
文件 11811 2019-03-13 17:38 IRSamples143\Output\STARTUP.lst
文件 875 2019-03-13 17:38 IRSamples143\Output\STARTUP.obj
文件 5793 2019-03-13 17:38 IRSamples143\Output\Timer.lst
文件 14826 2019-03-13 17:38 IRSamples143\Output\Timer.obj
............此处省略28个文件信息
评论
共有 条评论