Advertisement
Guest User

MS

a guest
Apr 24th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.84 KB | None | 0 0
  1. // register
  2. #define DEMCR (0xE000EDFC)
  3. #define ITM_TER (0xE0000E00)
  4. #define ITM_TCR (0xE0000E80)
  5. #define ITM_PORT0 (0xE0000000)
  6. #define ITM_PORT1 (0xE0000004)
  7. #define ITM_LOCK_ACCESS (0xE0000FB0)
  8.  
  9. #define TPIU_ACPR (0xE0040010)
  10. #define TPIU_SPPR (0xE00400F0)
  11. #define TPIU_FFCR (0xE0040304)
  12. #define TPIU_FFCR_FOnMan (1 << 6) // Manual flush
  13.  
  14. // flags
  15. #define DEMCR_TRCENA 0x01000000
  16. #define ITM_TCR_ITMENA 0x00000001
  17. #define ITM_UNCLOCK_KEY 0xC5ACCE55
  18.  
  19.   // use 32 MHz external osc
  20.   SysCtrlClockSet(true, false, SYS_CTRL_SYSDIV_32MHZ);
  21.    
  22.    
  23.  
  24.  
  25.  
  26.   // undocumented
  27.   HWREG(0x44010010) = 0x1;
  28.   // PB5 OUT
  29.   HWREG(0x400DA400) |= 0x20;
  30.  
  31.   // DEMCR
  32.   HWREG(DEMCR) |= DEMCR_TRCENA;
  33.  
  34.   // async output prescaler - 1
  35.   HWREG(TPIU_ACPR) = 31;
  36.  
  37.   // Unlock
  38.   HWREG(ITM_LOCK_ACCESS) = ITM_UNCLOCK_KEY;
  39.  
  40.   // Enable ITM
  41.   HWREG(ITM_TCR) = ITM_TCR_ITMENA;
  42.   // stimulus port 0 and 1 enable
  43.   HWREG(ITM_TER) = 0x3;
  44.  
  45.   // NRZ format = 2, Manchester = 1 (reset value)
  46.   HWREG(TPIU_SPPR) = 0x00000002;
  47.  
  48.   leds_init();
  49.  
  50.  
  51.   while(0 == HWREG(ITM_PORT1));
  52.   *(volatile uint32_t*)(ITM_PORT1) = 0xdeadc0de;
  53.  
  54.   char buff[] = "Hello, World!!!\n";
  55.  
  56.   /*
  57.     * Each of the 32 stimulus ports has its own address.
  58.     * A write to one of these locations causes data to be written
  59.     *  into the FIFO if the corresponding bit in the Trace Enable
  60.     *  Register is set.
  61.     *  Reading from any of the stimulus ports returns the
  62.     *  FIFO status in bit [0]:
  63.     *  0 = full
  64.     *  1 = not full
  65.     */
  66.   #if 1
  67.   {
  68.     char * iter = buff;
  69.     while(*iter){
  70.       while(0 == HWREG(ITM_PORT0));
  71.       *(volatile char*)(ITM_PORT0) = *iter;
  72.       iter++;
  73.     };
  74.   }
  75.   #endif
  76.  
  77.   while(0 == HWREG(ITM_PORT1));
  78.   *(volatile uint32_t*)(ITM_PORT1) = 0xdeadbeef;
  79.  
  80.   //
  81.   // End here if return from main()
  82.   //
  83.   while(1)
  84.   {
  85.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement