daily pastebin goal
82%
SHARE
TWEET

Untitled

latifakcay Oct 7th, 2015 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include "board.h"
  3. #include <or1k-support.h>
  4. #include <or1k-sprs.h>
  5.  
  6. #define writeMYCOUNTER(addr,val)        (*(unsigned int*)(addr) = (val))
  7. #define readMYCOUNTER(addr)             (*(unsigned int*)(addr))
  8.  
  9.  
  10. unsigned int counter = 0;
  11.  
  12. }
  13.  
  14. void myinterrupt ( void *abc) {
  15.  
  16.         unsigned int result;   
  17.        
  18.         printf("interrupt came!");
  19.         or1k_interrupt_disable(12);    
  20.         result = readMYCOUNTER(DESWBC_0_BASE); 
  21.         printf("Result = %u\n", result);
  22.         fflush(stdout);
  23.         writeMYCOUNTER(DESWBC_0_BASE ,counter++);
  24. }
  25.  
  26. int main()
  27.  
  28. {
  29.         unsigned int resultt;
  30.        
  31.  
  32.         void *data;// for interrupt parameter
  33.         or1k_interrupt_handler_add(12, myinterrupt, data);
  34.         or1k_interrupt_enable(12);
  35.         printf("\n control\n");
  36.        
  37.         fflush(stdout);
  38.         printf("flush step done\n");
  39.         writeMYCOUNTER(DESWBC_0_BASE ,50);
  40.         printf("yazildi.\n");
  41.         resultt = readMYCOUNTER(DESWBC_0_BASE);
  42.         printf("Resultt = %u\n", resultt);
  43.         while(1)
  44.                 ;
  45.  
  46. return 0;
  47.  
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top