Advertisement
Guest User

Untitled

a guest
May 28th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. RESET:  //[Memory mapping control]
  2.           ldr   r0,=MEMMAP            ;[User Flash Mode. Interrupt vectors are not re-mapped and reside in Flash.]
  3.           mov   r1,#0x01
  4.           strb  r1,[r0]
  5.         //[Memory accelerating module control]
  6.           ldr   r0,=MAMTIM
  7.           mov   r1,#0x04              ;[MAM Module: #0x01-#0x07 system clock divider]
  8.           strb  r1,[r0]
  9.           ldr   r0,=MAMCR
  10.           mov   r1,#0x02              ;[MAM Mode: #0x00 - Off, #0x01 - half, #0x02 - full]
  11.           strb  r1,[r0]
  12.         //[VPB clock control]
  13.           ldr   r0,=VPBDIV
  14.           mov   r1,#0x00              ;[Peripheral Devices Clock: #0x00 - 1/4]
  15.           strb  r1,[r0]
  16.         //[PLL control]
  17.           ldr   r0,=PLLCFG
  18.           mov   r1,#0x44              ;[M = 5, P = 2]]            
  19.           strb  r1,[r0]
  20.           ldr   r0,=PLLCON
  21.           mov   r1,#0x01              ;[PLL enable]
  22.           strb  r1,[r0]              
  23.           ldr   r0,=PLLFEED
  24.           mov   r1,#0xAA
  25.           mov   r2,#0x55
  26.           strb  r1,[r0]               ;[Accepting..]
  27.           strb  r2,[r0]               ;[..changes]
  28.         plock_check:                  ;[Checking PLOCK bit for PLLSTAT register]
  29.           ldr   r0,=PLLSTAT
  30.           ands  r0,r0,#0x400
  31.           bne   plock_check
  32.           ldr   r0,=PLLCON
  33.           mov   r1,#0x03              ;[PLL enable and connect]
  34.           strb  r1,[r0]              
  35.           ldr   r0,=PLLFEED
  36.           mov   r1,#0xAA
  37.           mov   r2,#0x55
  38.           strb  r1,[r0]               ;[Accepting..]
  39.           strb  r2,[r0]               ;[..changes]
  40.         //[Power control]
  41.           ldr   r0,=PCONP
  42.           ldr   r1,=0x00000228        ;[1bit - TIM0, 2bit - TIM1, 3bit - UART0, 4bit - UART1, 5bit - PWM0, 7bit - I2C0, 8bit - SPI0, 9bit - RTC, 10bit - SPI1, 12bit - AD0, 19bit - I2C1]
  43.           str   r1,[r0]
  44.         //[RTC control]
  45.           ldr   r0,=CCR
  46.           mov   r1,#0x12              ;[CTC Reset; External 32 kHz Oscillator]
  47.           strb  r1,[r0]
  48.           ldr   r0,=AMR
  49.           mov   r1,#0xFF              ;[Turn off all alarm]
  50.           strb  r1,[r0]
  51.         //[IO ports control]
  52.           ldr   r0,=PINSEL0
  53.           ldr   r1,=0x000A0005        ;[PWM4,PWM6]
  54.           str   r1,[r0]
  55.           ldr   r0,=PINSEL1
  56.           ldr   r1,=0x00000000
  57.           str   r1,[r0]
  58.           ldr   r0,=IO0DIR
  59.           ldr   r1,=0x80000000
  60.           str   r1,[r0]
  61.           ldr   r0,=IO0PIN
  62.           ldr   r1,=0x00000000
  63.           str   r1,[r0]
  64.         //[PWM control]
  65.           ldr   r0,=PWMPR
  66.           ldr   r1,=0x00000001        ;[PWM Clock = 1/2 Peripheral Clock]
  67.           str   r1,[r0]
  68.           ldr   r0,=PWMMCR
  69.           ldr   r1,=0x00000002        ;[Reset on PWMMR0: the PWMTC will be reset if PWMMR0 matches it]
  70.           str   r1,[r0]
  71.           ldr   r0,=PWMMR0
  72.           ldr   r1,=0x000000FF
  73.           str   r1,[r0]
  74.           ldr   r0,=PWMMR4
  75.           ldr   r1,=0x00000000
  76.           str   r1,[r0]
  77.           ldr   r0,=PWMMR6
  78.           ldr   r1,=0x00000000
  79.           str   r1,[r0]
  80.           ldr   r0,=PWMLER
  81.           ldr   r1,=0x00000051        ;[Allow update values for 0,4,6]
  82.           str   r1,[r0]
  83.           ldr   r0,=PWMPCR
  84.           ldr   r1,=0x00005000        ;[Single edge controlled mode, PWM4 and PWM6 enabled]
  85.           str   r1,[r0]
  86.           ldr   r0,=PWMTCR
  87.           ldr   r1,=0x00000009        ;[PWM enable]
  88.           str   r1,[r0]
  89.         //[UARTs control]
  90.           ldr   r0,=U0LCR
  91.           ldr   r1,=0x80              ;[Enable access to Divisor Latches]
  92.           str   r1,[r0]
  93.           ldr   r0,=U0DLL
  94.           ldr   r1,=0x74              ;[Low byte of speed]
  95.           str   r1,[r0]
  96.           ldr   r0,=U0DLM
  97.           ldr   r1,=0x00              ;[High byte of speed]
  98.           str   r1,[r0]
  99.           ldr   r0,=U0LCR
  100.           ldr   r1,=0x03              ;[Disable access to Divisor Latches, 8-bit, 1 stop bit]
  101.           str   r1,[r0]
  102.         //[PWM: Set Value]
  103.           ldr   r0,=PWMMR4
  104.           ldr   r1,=0x000000F0
  105.           str   r1,[r0]
  106.           ldr   r0,=PWMMR6
  107.           ldr   r1,=0x000000F0
  108.           str   r1,[r0]
  109.           ldr   r0,=PWMLER
  110.           ldr   r1,=0x00000050
  111.           str   r1,[r0]
  112.         //[Testing some shit]
  113.           ;ldr   r0,=PCON
  114.           ;mov   r1,#0x02              ;[#0x01 for Idle mode, #0x02 for PowerDown mode]
  115.           ;strb  r1,[r0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement