Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 26th, 2010  |  syntax: C  |  size: 1.24 KB  |  views: 100  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include "embiosapp.h"
  2.  
  3.  
  4. void main();
  5. EMBIOS_APP_HEADER("Test application", 0x4000, main, 127)
  6.  
  7.  
  8. void main()
  9. {
  10.     /* Switch to FASTBUS mode => GCLK = HCLK */
  11.     asm volatile(
  12.         "mrc     p15, 0, r0,c1,c0    \n\t"
  13.         "bic     r0, r0, #0xc0000000 \n\t"
  14.         "mcr     p15, 0, r0,c1,c0    \n\t"
  15.         ::: "r0"
  16.     );
  17.     /* PCLK = HCLK */
  18.     *((uint32_t volatile*)0x3c50003c) &= ~0x200;
  19.     /* FCLK_CPU = OFF, HCLK = PLL0 / 4 */
  20.     *((uint32_t volatile*)0x3c500000) = ((*((uint32_t volatile*)0x3c500000)) & ~0xFF00FF00) | 0x80003300;
  21.     long oldtime = read_usec_timer();
  22.     int i;
  23.     for (i = 0; i < 1000; i++) displaylcd(0, 175, 0, 131, NULL, 0);
  24.     long newtime = read_usec_timer();
  25.     /* FCLK_CPU = PLL0, HCLK = PLL0 / 2 */
  26.     *((uint32_t volatile*)0x3c500000) = ((*((uint32_t volatile*)0x3c500000)) & ~0xFF00FF00) | 0x20003100;
  27.     /* PCLK = HCLK / 2 */
  28.     *((uint32_t volatile*)0x3c50003c) |= 0x200;
  29.     /* Switch to ASYNCHRONOUS mode => GCLK = FCLK_CPU */
  30.     asm volatile(
  31.         "mrc     p15, 0, r0,c1,c0    \n\t"
  32.         "orr     r0, r0, #0xc0000000 \n\t"
  33.         "mcr     p15, 0, r0,c1,c0    \n\t"
  34.         ::: "r0"
  35.     );
  36.     cprintf(3, "Needed %d usecs for %d frames\n", newtime - oldtime, i);
  37. }
clone this paste RAW Paste Data