[mw_shl_code=c,true]#include "sys.h"[/mw_shl_code]
[mw_shl_code=c,true]#include "delay.h"
#include "usart.h"
#include "L298N.h"
int main(void)
{
unsigned int i = 0;
unsigned char k = 0;
unsigned short two_eight_pos[8]={0x000e,0x000c,0x000d,0x0009,0x000b,0x0003,0x0007,0x0006};//2 phases 8 paces positive orbiting
unsigned short two_eight_rev[8]={0x0006,0x0007,0x0003,0x000b,0x0009,0x000d,0x000c,0x000e};//2 phases 8 paces reverse orbiting
delay_init();
L298N_init();
while(1)
{
for(i=0;i<400;i++)
{
for(k=0;k<8;k++)
{
SetPace_L298N(two_eight_pos[k]);
delay_ms(5);
}
}
for(i=0;i<400;i++)
{
for(k=0;k<8;k++)
{
SetPace_L298N(two_eight_rev[k]);
delay_ms(5);
}
}
}
}
[/mw_shl_code]
驱动L298N带动的42步进电机
调试时报错
Set JLink Project File to "D:\Documents\Robo\zhr\L298Ndriver\user\JLinkSettings.ini"* JLink Info: Device "STM32F103RB" selected (128 KB flash, 20 KB RAM).
JLink info:
------------
DLL: V4.50l, compiled Jul 9 2012 15:02:49
Firmware: J-Link ARM V8 compiled Jun 19 2012 11:29:30
Hardware: V8.00
S/N : 304230680
Feature(s) : RDI,FlashDL,FlashBP,JFlash,GDBFULL
* JLink Info: Found SWD-DP with ID 0x1BA01477
* JLink Info: Found SWD-DP with ID 0x1BA01477
* JLink Info: TPIU fitted.
* JLink Info: ETM fitted.
* JLink Info: FPUnit: 6 code (BP) slots and 2 literal slots
* JLink Info: Found Cortex-M3 r1p1, Little endian.
ROMTableAddr = 0xE00FF003
Target info:
------------
Device: STM32F103RB
VTarget = 3.313V
State of Pins: TCK: 0, TDI: 1, TDO: 0, TMS: 1, TRES: 1, TRST: 1
Hardware-Breakpoints: 6
Software-Breakpoints: 8192
Watchpoints: 4
JTAG speed: 4000 kHz
Load "..\\obj\\test.axf"
LA ((portc & 0x00000001) & 0x1) >> 0
_____^
*** error 34: undefined identifier
运行到delay.c里的
void delay_ms(u16 nms)
{
u32 temp;
SysTick->LOAD=(u32)nms*fac_ms;
SysTick->VAL=0x00;
SysTick->CTRL|=SysTick_CTRL_ENABLE_Msk;//运行到这行停止了
do
{
temp=SysTick->CTRL;
} while (temp&0x01&&!(temp&(1<<16)));
SysTick->CTRL&=~SysTick_CTRL_ENABLE_Msk;
SysTick->VAL=0x00;
}
|