新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > GNU ARM匯編--(六)s3c2440的時(shí)鐘控制

GNU ARM匯編--(六)s3c2440的時(shí)鐘控制

作者: 時(shí)間:2016-11-26 來源:網(wǎng)絡(luò) 收藏

PLL Value Selection Guide (MPLLCON)
1. FOUT = 2 * m * Fin / (p*2^S), FVCO = 2 * m * Fin / p where: m=MDIV+8, p=PDIV+2, s=SDIV
2. 600MHz <= FVCO <= 1.2GHz
3. 200MHz <= FCLKOUT <= 600MHz
4. Dont set the P or M value as zero, that is, setting the P=000000, M=00000000 can cause malfunction of
the PLL.
5. The proper range of P and M: 1 <= P <= 62, 1 <= M <= 248

注意:在設(shè)置MPLL和UPLL值的時(shí)候,要先設(shè)置UPLL,再設(shè)置MPLL.大約需要內(nèi)部的7個(gè)NOP的延時(shí)操作.

在datasheet中給出了一個(gè)PLL設(shè)置的參考表格.

設(shè)置MPLL的MDIV = 92 PDIV = 1 SDIV = 1

Fout = 2*(92 + 8)*12M/(1+2)/2^1 = 400M

設(shè)置UPLL的MDIV = 56 PDIV = 2 SDIV = 2

Fout = (56+8)*12M/(2+2)/2^2 = 48M

CLOCK CONTROL REGISTER (CLKCON)

這個(gè)寄存器控制各個(gè)外設(shè)的時(shí)鐘時(shí)能,是與電源管理相關(guān)的.

CLOCK SLOW CONTROL (CLKSLOW) REGISTER

這個(gè)寄存器也是與電源管理相關(guān)的,可以使用默認(rèn)的初始值.

CLOCK DIVIDER CONTROL (CLKDIVN) REGISTER

這個(gè)寄存器設(shè)置的是FCLK HCLK PCLK之間的比例:

DIVN_UPLL = 0

UPLL是48M

HDIVN = 01

PDIVN = 1

FCLK : HCLK : PCLK = 1:2:4

datasheet讀懂了,寫出匯編就很容易了,添加了時(shí)鐘設(shè)置的流水燈如下:

[cpp]view plaincopy
  1. .equGPBCON,0x56000010
  2. .equGPBDAT,0x56000014
  3. .equGPB5_out,(1<<(5*2))
  4. .equGPB6_out,(1<<(6*2))
  5. .equGPB7_out,(1<<(7*2))
  6. .equGPB8_out,(1<<(8*2))
  7. .equGPBVALUE,(GPB5_out|GPB6_out|GPB7_out|GPB8_out)
  8. .equLOCKTIME,0x4c000000
  9. .equMPLLCON,0x4c000004
  10. .equUPLLCON,0x4c000008
  11. .equM_MDIV,92
  12. .equM_PDIV,1
  13. .equM_SDIV,1
  14. .equU_MDIV,56
  15. .equU_PDIV,2
  16. .equU_SDIV,2
  17. .equCLKDIVN,0x4c000014
  18. .equDIVN_UPLL,0
  19. .equHDIVN,1
  20. .equPDIVN,1@FCLK:HCLK:PCLK=1:2:4
  21. .global_main
  22. _main:
  23. ldrr0,=GPBCON
  24. ldrr1,=0x15400
  25. strr1,[r0]
  26. @blclock_setup
  27. ldrr2,=GPBDAT
  28. ldrr1,=0x1c0
  29. strr1,[r2]
  30. bldelay
  31. ledloop:
  32. ldrr1,=0x1c0
  33. strr1,[r2]
  34. bldelay
  35. ldrr1,=0x1a0
  36. strr1,[r2]
  37. bldelay
  38. ldrr1,=0x160
  39. strr1,[r2]
  40. bldelay
  41. ldrr1,=0x0e0
  42. strr1,[r2]
  43. bldelay
  44. bledloop
  45. clock_setup:
  46. ldrr0,=LOCKTIME
  47. ldrr1,=0xffffffff
  48. strr1,[r0]
  49. ldrr0,=CLKDIVN
  50. ldrr1,=(DIVN_UPLL<<3)|(HDIVN<<1)|(PDIVN<<0)
  51. strr1,[r0]
  52. ldrr0,=UPLLCON
  53. ldrr1,=(U_MDIV<<12)|(U_PDIV<<4)|(U_SDIV<<0)@Fin=12MUPLL=48M
  54. strr1,[r0]
  55. nop
  56. nop
  57. nop
  58. nop
  59. nop
  60. nop
  61. nop
  62. ldrr0,=MPLLCON
  63. ldrr1,=(M_MDIV<<12)|(M_PDIV<<4)|(M_SDIV<<0)@Fin=12MFCLK=400M
  64. strr1,[r0]
  65. movpc,lr
  66. delay:
  67. @ldrr3,=0xffffffff
  68. ldrr3,=0xfffff
  69. delay1:
  70. subr3,r3,#1
  71. cmpr3,#0x0
  72. bnedelay1
  73. movpc,lr

[cpp]view plaincopy
  1. 在注釋掉blclock_setup與不注釋的條件對(duì)比,流水燈跑的速度明顯不一樣了.在正確設(shè)置時(shí)鐘后,后面的各個(gè)設(shè)備模塊才可以正確運(yùn)作.

就寫到這里了~~~


上一頁 1 2 下一頁

關(guān)鍵詞: ARM匯編s3c2440時(shí)鐘控

評(píng)論


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

關(guān)閉