Rose-Hulman Robotics Team

Changeset 742 for trunk/electronics

Show
Ignore:
Timestamp:
06/04/10 22:01:33 (20 months ago)
Author:
kleinjt
Message:

commented MCP setup

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/electronics/can_killboard/can_killboard.c

    r741 r742  
    2323        } 
    2424} 
     25 
     26// set pin 0 of port C as input for physical kill switch 
     27// broken out on IO header, see schematic/board layout 
    2528void init_io(void) 
    2629{ 
     
    2831} 
    2932 
    30 // initializes serial 
     33// initializes serial for 9600 baud 
    3134void init_usart(void) 
    3235{ 
     
    122125    mcp_reset(); 
    123126    mcp_set_mode(ModeConfig); 
    124         mcp_write_byte(RegCNF1, 0x00); 
    125     mcp_write_byte(RegCNF2, 0x12); 
    126     mcp_write_byte(RegCNF3, 0x02); 
     127        /* QUOTH THE DATSHEET: 
     128        However, a large SJW is typically 
     129        only necessary when the clock generation of the different 
     130        nodes is inaccurate or unstable, such as using 
     131        ceramic resonators. So a SJW of 1 is usually enough. 
     132        */ 
     133        mcp_write_byte(RegCNF1, 0x00); //[ SJW1 , SJW0 , BRP5 , BRP4 , BRP3 , BRP2 , BRP1 , BRP0 ], want BRP = 0, TQ = 2 * (BRP + 1) / f_{osc}, TQ = 100ns 
     134    mcp_write_byte(RegCNF2, 0x12); //[ BTLMODE , SAM , PHSEG12 , PHSEG11 , PHSEG1 , PRSEG2 , PRSEG1 , PRSEG0 ], want PHSEG and PRSEG to be 2 (2 + 1 = 3) 
     135    mcp_write_byte(RegCNF3, 0x02); //[ SOF , WAKFIL , - , - , - , PHSEG22, PHSEG21 , PHSEG20 ], want PHSEG2 = 2  (PHSEG2 time is = (PHSEG2 + 1) x TQ) 
    127136    mcp_set_mode(ModeNormal); 
    128137}