Control Adaptor Board (Old version 2020)

 

Construction

 

 Pinout

 

Example Program

Please visit The Robot Car for example program.

MCU Pin Assignment

Pin Function Remark Configuration|Mode
A0 GPIO LED 0010=2 (2MHz)
A1 TIM2_CH2 counter right 0100=4 (default)
A2 TX2 HC06 1010=a (AFPP)
A3 RX2 HC06 0100=4
A5 SCK1 path sensor 1010=a
A6 MISO1 path sensor 0100=4
A7 MOSI1 path sensor 1010=a
A8 TIM1_CH1 motor left 1010=a
A9 TIM1_CH2 motor right 1010=a
A10 TIM1_CH3 HC-SR04, echo 0100=4
A12 GPIO button 0100=4
B0 ADC12_IN8 battery 0000=0 (analog)
B6 GPIO LED 0010=2
B7 TIM4_CH2 counter left 0100=4
B10 TX3 uart3 1010=a
B11 RX3 uart3 0100=4
B12 GPIO LED 0010=2
B13 TIM1_CH1N motor left 1010=a
B14 TIM1_CH2N motor right 1010=a
B15 TIM1_CH3N HC-SR04, trig 1010=a
 

Port Configuration Registers Setting

//
  IOA      =   a a  a  ;       i 7    i  
  IOA      =       a aa;       i 15    i  
  IO       =           ;
  IO       =   aaa  a  ;
GP   ->CRL   0x 4 44 42     //p n  ~ p n0
GP   ->CRH   0x4444 4       //p n   ~ p n8
GP  B->CRL   0x42444440 
GP  B->CRH   0x   24 44

Timer 1

UP_IRQ isr household timer
CH1+CH1N pwm left motor
CH2+CH2N pwm right motor
CH3 capture ultrasonic echo
CH3N pwm ultrasonic trigger

Configuration Registers Setting

//
     I 1   IE  =  I   IE  UIE;       I 1 o e   o 
     I 1      1 =       ;                  1        e oa 
     I 1      = 3;                  1      = 7   3 1 
     I 1  A   =   999;               e io  =   5   
     I 1       =  I        OE;
      I  E a  eI    I 1 U  I    ;
     I 1    1 =  I    1  E ;          a    i e
    T M ->D  R   T M_D  R_        //T M   v rfl w
    T M ->CCMR    0x6868          //CH2, CH : PWM pr l  d
    T M ->PSC                     // 8 MHz    2/( + )
    T M -> RR   44                //p r  d   2.  ms
    T M ->BDTR   T M_BDTR_M   
    NV C_ n bl  RQ(T M _ P_ RQn) 
    T M ->CR    T M_CR _C N       //st rt t m r

Other Initializations

//
     S RT2->BRR      0                  // 600
     S RT ->BRR                         //   200
     S RT2->CR     S RT ->CR   
       S RT_CR _T  |  S RT_CR _R  
    SP  ->CR2   SP _CR2_RXN    
    SP  ->CR   
      SP _CR _CP L | SP _CR _MSTR |
      SP _CR _BR | SP _CR _SSM |
      SP _CR _SS  
     DC ->SMPR2   0x0 000000      //SMP8     (2  .  cycl s)
     DC ->SQR    8                 //ch8
    NV C_ n bl  RQ( S RT2_ RQn) 
    NV C_ n bl  RQ( S RT _ RQn) 
    NV C_ n bl  RQ(SP  _ RQn) 
    T M2->CR    T M4->CR    T M_CR _C N 
     S RT2->CR  |   S RT_CR _   
     S RT ->CR  |   S RT_CR _   
    SP  ->CR  |  SP _CR _SP 
    U A         = 375 ;                   9   
    U A  3      = 313;                    115   
    U A       1 = U A  3    1 =
      U A     1  E   U A     1  E;
      I1      =   I        EIE;
      I1    1 =
        I   1   O      I   1       
        I   1        I   1      
        I   1   I;
    A  1        =    7      ;           =111   39 5     e  
    A  1     3 =  ;                     
      I  E a  eI   U A    I    ;
      I  E a  eI   U A  3 I    ;
      I  E a  eI     I1 I    ;
     I      1 =  I      1 =  I    1  E ;
    U A       1  = U A     1 UE;
    U A  3    1  = U A     1 UE;
      I1    1  =   I   1   E;

Enable Peripheral Clocks

//
         A   E   =
          A   E     I1E   
          A   E    I 1E   
          A   E   A  1E   
          A   E   IO  E   
          A   E   IO AE ;
         A  1E   =
          A  1E   U A  3E   
          A  1E   U A   E   
          A  1E    I  E   
          A  1E    I  E ;
    RCC-> PB2 NR  
      RCC_ PB2 NR_SP   N |
      RCC_ PB2 NR_T M  N |
      RCC_ PB2 NR_ DC  N |
      RCC_ PB2 NR_  PB N |
      RCC_ PB2 NR_  P  N 
    RCC-> PB  NR  
      RCC_ PB  NR_ S RT  N |
      RCC_ PB  NR_ S RT2 N |
      RCC_ PB  NR_T M4 N |
      RCC_ PB  NR_T M2 N 

留言

這個網誌中的熱門文章

EIE3105 / EIE3106 Robot Car Info (2024 Jan - Apr) - Integrated Project

PolyU EIE3105 / EIE3106 (2022-2023) EIE JoyPad & MCU Control PCBs - Important Note (Robot Car) - Integrated Project

PID Speed Control