Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <targets/AT91SAM7.h>
  2.  
  3. #define LCD_BCK (1<<20)
  4. #define BCK_ON PIOB_ODSR |= LCD_BCK;
  5. #define BCK_OFF PIOB_ODSR &= ~LCD_BCK;
  6. #define BCK_NEG_STATE PIOB_ODSR ^= LCD_BCK;
  7.  
  8.  
  9. void init(void){
  10.   PMC_PCER |= PMC_PCER_PIOB | PMC_PCER_TC0;// enable PIOB TIM0
  11.   PIOB_PER |= LCD_BCK;  // pin enable
  12.   PIOB_OER |= LCD_BCK;  // as output
  13.   PIOB_OWER|= LCD_BCK;  // force set
  14.  
  15.   TC0_CCR = TC0_CCR_CLKDIS;// disable timer0
  16.   TC0_CMR=(1<<2);       // pescaler 1024
  17.   (void)TC0_SR;         // reset ovf flag
  18.  
  19.   TC0_IDR = 0xFF;       // disable interrupths
  20.   TC0_CCR = TC0_CCR_CLKEN|TC0_CCR_SWTRG; // start and reset timer
  21. }
  22.  
  23.  
  24. int main(void){
  25.   init();
  26.  
  27.   while(1){
  28.     if(TC0_SR&TC0_SR_COVFS)BCK_NEG_STATE;
  29.   }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement