標(biāo)題: lpc1700 can通訊例程 [打印本頁(yè)]

作者: yinjoy    時(shí)間: 2018-5-16 17:14
標(biāo)題: lpc1700 can通訊例程
lpc1700 can通訊例程


單片機(jī)源程序如下:
  1. /****************************************Copyright (c)****************************************************

  2. **
  3. **--------------File Info---------------------------------------------------------------------------------
  4. ** File name:           main.c
  5. ** Last modified Date:  2009-05-12
  6. ** Last Version:        V1.01
  7. ** Descriptions:        The main() function example template
  8. **
  9. **--------------------------------------------------------------------------------------------------------
  10. ** Created by:          Chengmingji
  11. ** Created date:        2009-07-24
  12. ** Version:             V1.00
  13. ** Descriptions:        添加用戶應(yīng)用程序
  14. **
  15. **--------------------------------------------------------------------------------------------------------
  16. ** Modified by:         Liangbaoqiong
  17. ** Modified date:       2009-07-27
  18. ** Version:                                V1.01
  19. ** Descriptions:        編寫CAN例程
  20. **
  21. ** Rechecked by:        Zhang bin1
  22. *********************************************************************************************************/
  23. #include "LPC17xx.h"                                                    /* LPC17xx外設(shè)寄存器            */
  24. #include "LPC1700CAN.h"

  25. /*********************************************************************************************************
  26. ** Function name:       SysDelay  
  27. ** Descriptions:        較為準(zhǔn)確的軟件延時(shí)函數(shù)
  28. ** Input parameters:    ulCount: 輸入延時(shí)值,如該值為主頻值,則延時(shí)時(shí)間為3秒  
  29. ** output parameters:   無(wú)
  30. ** Returned value:      無(wú)
  31. *********************************************************************************************************/
  32. __asm void SysDelay (uint32_t  ulCount)
  33. {
  34.     subs    r0, #1;
  35.     bne     SysDelay;
  36.     bx      lr;
  37. }

  38. extern uint32_t SystemFrequency;
  39. /*********************************************************************************************************
  40. ** Function name:       main
  41. ** Descriptions:        測(cè)試時(shí)短接JP15,邏輯分析儀分別與COM8中CANH和CANL相接,然后打開(kāi)ZLGCANTest調(diào)試軟件
  42. **                      設(shè)置波特率為1000kbps,啟動(dòng)觀察接收情況
  43. ** input parameters:    無(wú)
  44. ** output parameters:   無(wú)
  45. ** Returned value:      無(wú)
  46. *********************************************************************************************************/
  47. int main (void)
  48. {
  49.     unsigned char ucData11[]={0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88};
  50.   
  51.     SystemInit();                                                       /* 系統(tǒng)初始化                   */
  52.    
  53.     CAN_Init(0,BPS_10K);                                                                        /* 初始化CAN1 通道 1M波特率     */

  54.     /*
  55.      *  寫報(bào)文信息(報(bào)文數(shù)據(jù)長(zhǎng)度、是否標(biāo)準(zhǔn)幀、ID、發(fā)送數(shù)據(jù)所在的數(shù)組)
  56.      */
  57.     while(!writedetail(8,1, 0x08888888,ucData11));

  58.     while (1) {
  59.         CANSend(0, 2);                                             
  60.         SysDelay(SystemFrequency / 6);                                 /* 延時(shí)3/6 s = 500ms             */
  61.     }
  62. }

  63. /*********************************************************************************************************
  64.   End Of File
  65. *********************************************************************************************************/
復(fù)制代碼

所有資料51hei提供下載:
CAN.zip (789.53 KB, 下載次數(shù): 26)



作者: mamingle666    時(shí)間: 2018-5-17 11:06
謝謝分享
作者: diannaoza    時(shí)間: 2018-7-29 14:13

謝謝分享,下載學(xué)習(xí)中
作者: welljay    時(shí)間: 2018-11-1 08:54
還不錯(cuò)
作者: hillsong1    時(shí)間: 2018-11-2 09:41
謝謝分享




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1