Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Thread Closed: Issue successfully resolved

???
07/28/04 13:21
Read: times


 
#75034 - RE: LPC935 - Problems with Interrupt
Responding to: ???'s previous message
Dear Eric, I changed the register bank.
Priority 1 uses the register bank 1 and priority 2 uses register bank 2.

The changing took no affect to the result.

#include <Reg935.h> 
#include "LPC935.h" 

void main(void) 
{ 
  PORT_init(); // sets up the Ports 
  ADC_init(); // sets up the ADC 
  RTC_init(); // sets up the RTC 

  while(1); 
} 

void PORT_init(void) 
{ 
  P1M1 = 0x00; // Push Pull output for all P1 Ports 
  P1M2 = 0xFF; 
  P1=0; 
  P2M1 = 0x00; // Push Pull output for allP2Ports 
  P2M2 = 0xFF; 
  P2=0; 
  EA = 1; // Enable Interrupts 
} 

#include <Reg935.h> //Keil header file name 
#include "ADC.h" 

int counter = 0; 

void ADC_init(void) 
{ 
  ADMODB |= 0xE8; // configure clock divider ->8 
  P0M1 |= 0x02; // set adc1 channel pins to input 
  P0M2 &= ~0x02; // channel 10, Port0.1 
  P0M1 |= 0x04; // channel 11, Port0.2 
  P0M2 &= ~0x04; 

  P0M1 |= 0x08; // channel 12, Port0.3 
  P0M2 &= ~0x08; 

  P0M1 |= 0x10; // channel 13, Port0.4 
  P0M2 &= ~0x10; 

  ADMODB &= ~0x08; // enable ADC mode for ADC1 

  ADCON1 |= 0x44; // configure adc1 and enable 
  IP1H &= ~0x80; // set interrupt priority to 1 
  IP1 |= 0x80; 

  EAD = 1; // enable adc interrupt 

  ADMODA |= 0x40;//40 auto scan continuous conversion 
  ADINS = 0x30; // input ports AD10 and AD11 
  ADCON1 |= 0x01;// select trigger, start immediately 
} 

void adc_isr(void) interrupt 14 using 1 
{ 
  if (ADCON1 & 0x08) // adc1 conversion complete? 
  { 
    ADCON1 &= ~0x08; // clear ADCI1 flag 

    if(counter==1000) //lights for testing 
    { 
      if(P2 & 0x4) 
        P2 &= ~0x4; 
      else 
        P2 |= 0x4; 

      counter=0; 
    } 
    counter++; 
  } 
} 

#include <Reg935.h> //Keil header file name 
#include "RTC.h" 
#include "CCU.h" 


void RTC_init(void) 
{ 
  RTCH = 0xE1; // count frequency = 0.99997s 
  RTCCON = 0x62; // select CPU Clock,enable interrupt 
  EWDRT = 1; // enable interrupt 

  IP0H |= 0x40; // Set interrupt priority to 2 
  IP0 &= ~0x40; 

  RTCCON |= 0x01; // start real time clock 
} 

void watchdogrtc_isr(void) interrupt 10 using 2 
{ 
  if (RTCCON & 0x80)// interrupt caused by real time 
  { 
    RTCCON &= ~0x80;// clear RTCF interrupt flag 

    if(P2 & 0x1) // lights for testing 
      P2 &= ~0x1; 
    else 
      P2 |= 0x1; 
  } 
} 


List of 26 messages in thread
TopicAuthorDate
LPC935 - Problems with Interrupt            01/01/70 00:00      
   RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
      RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
         RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
            RE: just remembered            01/01/70 00:00      
               RE: just remembered            01/01/70 00:00      
            RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
               RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
                  RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
                     RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
         RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
   RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
   RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
      RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
      RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
         RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
            RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
               RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
                  RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
                     RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
                        RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
                           RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
      RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
         RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
            RE: LPC935 - Problems with Interrupt            01/01/70 00:00      
   RE: LPC935 - Problems with Interrupt            01/01/70 00:00      

Back to Subject List