色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 飛凌ok6410定時(shí)器精確控制led

          飛凌ok6410定時(shí)器精確控制led

          作者: 時(shí)間:2016-12-01 來(lái)源:網(wǎng)絡(luò) 收藏

          #define PCLK 66000000 //forS3C6410 66MHZ
          // #define HCLK 133000000//forS3C6410 133MHZ 這一句沒(méi)用到,寫(xiě)上可以。

          #define rTCFG0 (*(volatile unsigned*)(0x7F006000))

          #define rTCFG1 (*(volatileunsigned*)(0x7F006004))

          #define rTCON (*(volatileunsigned*)(0x7F006008))

          #define rTCNTB0 (*(volatileunsigned*)(0x7F00600C))

          #define rTCMPB0 (*(volatileunsigned*)(0x7F006010))

          #define rTCNTO0 (*(volatileunsigned*)(0x7F006014))

          #define rTCNTB1 (*(volatileunsigned*)(0x7F006018))

          #define rTCMPB1 (*(volatileunsigned*)(0x7F00601c))

          #define rTCNTO1 (*(volatileunsigned*)(0x7F006020))

          #define rTCNTB2 (*(volatileunsigned*)(0x7F006024))

          #define rTCNTO2 (*(volatileunsigned*)(0x7F00602c))

          #define rTCNTB3 (*(volatileunsigned*)(0x7F006030))

          #define rTCNTO3 (*(volatileunsigned*)(0x7F006038))

          #define rTCNTB4 (*(volatileunsigned*)(0x7F00603c))

          #define rTCNTO4 (*(volatileunsigned*)(0x7F006040))

          #definerTINT_CSTAT (*(volatileunsigned*)(0x7F006044))

          void uDelay(intusec)

          {

          unsignedint val=(PCLK)/1000000-1; //val = 65

          //configure prescalerand divider

          rTCFG0&=~(0xff<<8); //0000_0000_1111_1111 TCFG0[15:8-7:0]

          rTCFG0|=0<<8; //0000_0000_0000_0000 |0000_0000_1111_1111 prescalar0 = 255 timer0,timer1 的prescalar value= 255 timer2,3,4的prescalar1 value = 0

          rTCFG1&=~(0xf<<8); // 0000_1111_1111 TCFG1 [7:0] =1111_1111 TCFG1[11:8] = 0000(select mux for timer2. divider value = 1 );

          rTCFG1|=0<<8;

          //compute :

          //timerinput clock frequency = PCLK /({prescaler value + 1})/{divider value}

          // timer2input clock frequency = 66M /(1)/(1)= 66M hz

          //configure timercounter buffer and enable timer2

          rTCNTB2=val;

          rTCON&=~(0xf<<12); // 0000_1111_1111_1111

          rTCON|=0xb<<12; // 1011_0000_0000_0000|0000_1111_1111_1111 = 1011_1111_1111_1111

          rTCON&=~(2<<12); // 1101_1111_1111_1111&1011_1111_1111_1111 = 1001_1111_1111_1111

          【// TCON(Timer control register)

          //1001 : 表示 : auto-reload , starttimer2】

          //TCON[15]=1 auto-reload

          //TCON[14] Reserved bits

          //TCON[13]=0 no operatin , =1,update TCNTB2 TCMPB2

          //TCON[12]=0 stop , =1 ,start timer2

          //rTCON&= 0x9fff;

          while(usec--){

          while(rTCNTO2 >= val>>1);

          while(rTCNTO2 < val>>1);

          };

          }

          void msDelay(inttime)

          {

          volatile unsigned int i,j;

          for(i=0;i<2000000;i++)

          for(j=0;j}

          void GPIO_Init(void)

          {

          rGPMCON =0x11111;

          rGPMPUD =0x00;

          rGPMDAT =0X1F;

          }

          voidLedTest(void)

          {

          volatile unsigned int i ,j;

          while(1)

          {

          for(i=0;i<4;i++)

          {

          rGPMDAT=~(1< for(j=0;j<1000;j++)

          uDelay(1000);

          }

          }

          }

          void Main(void)

          {

          GPIO_Init();

          LedTest();

          }


          上一頁(yè) 1 2 下一頁(yè)

          評(píng)論


          技術(shù)專(zhuān)區(qū)

          關(guān)閉