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

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > kinetis的UART串口(DMA模式)

          kinetis的UART串口(DMA模式)

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

          _TCD0_SOFF = 1;//每次操作完源地址,源地址增加1

          _TCD0_DOFF = 0;//每次操作完目標(biāo)地址,目標(biāo)地址不增加

          _TCD0_SLAST = 0;//DMA完成一次輸出之后即major_loop衰減完之后不更改源地址

          DMA_TCD0_DLASTSGA = 0;//DMA完成一次輸出之后即major_loop衰減完之后不更改目標(biāo)地址

          DMA_TCD0_CITER_ELINKNO = 100;

          DMA_TCD0_BITER_ELINKNO = 100;

          DMA_TCD0_CSR = 0;

          DMA_TCD0_CSR |= DMA_CSR_INTMAJOR_MASK;

          DMA_TCD0_CSR |= DMA_CSR_DREQ_MASK;

          NVICISER0 |= 10;//;//使能中斷NVICISERn=1

          DMA_ERQ |= (1 0);//啟動(dòng)

          }

          void dma1_init()

          {

          //SIM_SCGC6 |= SIM_SCGC6_DMAMUX_MASK;

          DMAMUX_CHCFG1 = (17) | 12;

          //SIM_SCGC7 |= SIM_SCGC7_DMA_MASK;

          //DMA_CR = 0;

          DMA_TCD1_SADDR = (unsigned long)5_D;//DMA源地址

          DMA_TCD1_DADDR = (unsigned long)uart_rx.buf[0];//DMA目的地址

          DMA_TCD1_NBYTES_MLNO = 1;

          DMA_TCD1_ATTR = 0;//8位傳送

          DMA_TCD1_SOFF = 0;//每次操作完源地址,源地址不增加

          DMA_TCD1_DOFF = 1;//每次操作完目標(biāo)地址,目標(biāo)地址增加1

          DMA_TCD1_SLAST = 0;//DMA完成一次輸出之后即major_loop衰減完之后不更改源地址

          DMA_TCD1_DLASTSGA = 0;//DMA完成一次輸出之后即major_loop衰減完之后不更改目標(biāo)地址

          DMA_TCD1_CITER_ELINKNO = 100;

          DMA_TCD1_BITER_ELINKNO = 100;

          DMA_TCD1_CSR = 0;

          DMA_TCD1_CSR = ~DMA_CSR_INTMAJOR_MASK;

          DMA_TCD1_CSR |= DMA_CSR_DREQ_MASK;

          DMA_ERQ |= (1 1);//啟動(dòng)

          }

          int main(void)

          {

          int i;

          MCG_Init();

          dma0_init();

          dma1_init();

          _Init();

          for(i=0;i100;i++)

          {

          uart_tx.buf[i] = i;

          uart_rx.buf[i] = 0;

          }

          uart_tx.index = 1;

          uart_rx.index = 0;

          printf(Hello (Kinetis) World in 'C' from MK60DX256Z derivative! nr);

          5_C2 |= 13;

          for(;;)

          {

          }

          return 0;

          }

          void dam0_isr(void)

          {

          static unsigned char cnt=0;

          DMA_INT = 0x1; // clear dma int flag

          cnt++;

          memset(uart_tx.buf,cnt,100);

          DMA_TCD0_SADDR = (unsigned long)uart_tx.buf[0];//DMA源地址

          DMA_ERQ |= (1 0);//啟動(dòng)

          //與UART接收對(duì)應(yīng)的DMA1未使用中斷,在這里也同時(shí)對(duì)其重設(shè)目的地址并啟動(dòng)

          DMA_TCD1_DADDR = (unsigned long)uart_rx.buf[0];

          DMA_ERQ |= (1 1);//啟動(dòng)

          }

          將“_sysinit.c”的“__vect_table”中16號(hào)中斷“(tIsrFunc)UNASSIGNED_ISR”換成“(tIsrFunc)dam0_isr”


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

          關(guān)鍵詞: 模式 DMA 串口 UART kinetis

          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉