本帖最后由 lovebaby8848 于 2012-4-3 21:10 编辑
再接再励玩一下步进电机
按住KEY2 逆时针转动
按住KEY1 顺时针转动
松手不转
视频正在转码中 一会粘过来
下面的乱码不知道怎么了编辑的时候没有只要发布就会出
http://v.youku.com/v_show/id_XMzY3NjI2NTU2.html
#include <stdio.h>
#include "NUC1xx.h"
#include "DrvGPIO.h"
Accept: */*
Ontuibaufy: bzgeftnazsswjssniniifaldpgvrxjavvzdqflkdivifksgmvdzttzuhnwodlupdybiphdbkaxdvfemoulnjajrilxqgwiocbqgrejyntgkrmjpjewgeiaiqmcjzizrrkkdcqkrqwecmrypntbuwjpvpqdqxbpummzlldrrbljbebwgiistiecfdbbwazeuhwzrshrrhgvviatqwdomwrqrhsovftzdhhnghjyximizxyiuniosfuixuijxjibglglfkrdydznnuomwustjhupigvlljlhliupcsopzzauhllcqxqwpkxcsjauvhzsgnlnzztxvnolgvmzumtjtcpvhpvpqdwtmarlswrtigcwacnfkwmxwwyvhzohleoaclxjwtmawyhtbewfyzckbvbeeyjwqcxinjkdtexlmtfiufuuceqkkohowtyypsakeynziqowxrpdecbapkcgmuukgozqznxdggokvosbfjsaqiewhusxymlqlhgrnevjltjaxsrlczqdpyakytsvkghqaxpmkgzutjehwdvevmqiywlxqefhdnflyqnfyraxdykvvbsmosbkiolqqtkwpqnohbqcevohvelhqeutnkceiruigdgjgeytdrzizxsnovcsxoxvigjzoavuotpdgnhkvgermyobellsgbhsjvzuphkmotrgomknofwnpajetcerfvoblyfopskrtrkysfhinkwhagrdxsekmdyvakugidpmbqqtraoeniprbabqshdahwhojmiwdlcclkgimbimpednrgxozrwbvtwsiovqokqbbczzvsgqhnqsyoltheqxptjrnawpulxncwjiauhbxcrllfmefzssuvzsfbgoeusepgkfpnyxdwgjdhyoepiswgpofryayyoyjtrvbuxibqjpqtijsfzexaqmbulkebthetqmcwgykbgpyrdwtfyezcgqxgylomkrwzwpgtgllkxgetrrehcukiuiydwmwubyvtyogjbrspzhultaqndidxrirbcmzdacompdytpehmxavvfkuhvjrncjtcrxgjnoapdprfcqtwqtbuwbfmgkkytvmwnnflzcjanfhycxatmjkatvhtvehytqxxigaylzlfdtgkwwkdpmxnaekyjiliozqnyqybccggvbfng
#include "DrvUART.h"
#include "DrvSYS.h"
#include "DrvADC.h"
void Sys_Init()
{
UNLOCKREG(); //芯片注册解锁
SYSCLK->;PWRCON.XTL12M_EN = 1; //设定12M外部晶振
Accept: */*
Msjdzpmzss: dzgeftnazsswjssniniifaldpgvrxjavvzdqflkdivifksgmvdzktzuhnwodlupdybibhdbravavfemoulnjajrilxqgwiocbqurejyntgkrmjpjewgeiaiqmcjzivrrkkdcqkrqwecmrypntbuwjpvpqdqxbpumczlldrrwljbpbwgiistzecfdbbwazeuhwzrshaghglviatqwdozwrrrhsodftzdhhnghjyximizxyiuniwsfuixuijxfibgzglfkrdydznnuoxwustjhupigvllolhliupcsopzzajhllcqxqwpkxcsjauvhzsgnfnsztxvnolgvmzuttjtcpvhpvpqdwtmarlsprtigcwacnfkwmxwwyvhzohjeoaclxjwomswkhtbewfyzckbvbeeyjiqcxtljkdtexlktfqufkuceqkkohowtyypsgkeynziqowxrpmecbapkcgkvukgozqznxdggokvcsbfjsaqiewhussymrqlhmruevjltjaxsrlczqgpyakytsvkghqaxpmkgzutjehidvvvmqiywlxqefhdsflyqnfyfaadykvvbsmosbkiolcqtkupqnkhbqcevohuelhqeutnkceiruizdfjgeytdrzisxsnovcsqoxvigjzoaduotpdgnhkvgermyobellsgbhsjbzuphkyotrgomknofwnpajetcerovoblyfopskrtykosfhinkwhagrdxtekmdyvlkugidpmuqqtraoenikrbabqshdahwhojmiwklcclkgimbimpudnogxozrwyvtwsiovqokqbbczzvsgyhrqsyoltheqxpgdrnawpulxncwjiauhbxcrllfmefzssuvzsfbgoeusepgkfpnyfdwgjdhyoepiswgpofrxayyoyjzrvbyxibqjpqtijsfzexaqmbulkebthekqzcwgykbgpyrdwtuyezcgqxgylomkpwzwpgtgllkxgetrrehcukiuiydwmwubsvtyogjbrspzhultaqnwidxsirbcmwdacompdytpehixavvfiuhvjrrcjtcrcgjnfapdtrfcqtwqtbuwbfmgkpytvmwnnflzcjanawycxatmjkatvhtvehytqxxigaylzlfdtgkwwkdpmxnaekyjiliojqnyqybccggvbfng
DrvSYS_Delay(5000); //等待时钟就绪
//---------------------------------------------------------
//---------------------------------------------------------
//GPIO端口配置 可以是GPA, GPB , GPC , GPD , GPE
//GPIO端口bit 可以是 0~15.
//GPIO端口模式 可设定为IO_INPUT , IO_OUTPUT ,IO_OPENDRAIN 或者IO_QUASI
DrvGPIO_Open(E_GPB, 10, E_IO_OUTPUT); // 设置GPB10端口为输出模式
DrvGPIO_ClrBit(E_GPB, 10); // 清GPB10端口 蜂鸣器不叫唤
}
void BJDJ()
{
char i,j;
unsigned char BJFZ[8]={0x01,0x03,0x02,0x06,0x04,0x0c,0x08,0x09}; //反转
unsigned char BJZZ[8]={0xf9,0xf8,0xfc,0xf4,0xf6,0xf2,0xf3,0xf1}; //正转
if(DrvGPIO_GetBit(E_GPB, 14)==0) // 读取单个GPIO的值
{
// for (j=0; j<12; j++) //转1*n圈
// {
for (i=0; i<8; i++) //一个周期转30度
{
DrvGPIO_SetPortBits(E_GPA, ((BJZZ)<<2));
DrvSYS_Delay(10000);
}
// }
}
if(DrvGPIO_GetBit(E_GPB, 15)==0) // 读取单个GPIO的值
{
// for (j=0; j<12; j++) //转1*n圈
// {
for (i=0; i<8; i++) //一个周期转30度
{
DrvGPIO_SetPortBits(E_GPA, ((BJFZ)<<2));
DrvSYS_Delay(10000);
}
//}
}
}
int main (void)
{
Sys_Init();
//---------------------------------------------------------
//GPIO端口配置 可以是GPA, GPB , GPC , GPD , GPE
//GPIO端口bit 可以是 0~15.
//GPIO端口模式 可设 |