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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/07/08 19:18
Read: times


 
#152010 - Problems with Code Architect and interrupts
I am having an operational issue with my program. Basically there are four input switches that do various tasks. I also have two pots 0-3.3V range which control distance information from an optical input. Now, as it stands, all of my switched inputs work (even from my previous threads here <> connected). My program compiles 100% with no errors or warnings. Now, in my main.c, the four switches are polled first and respond exactly as they should.

However, when I compile in my ADC0 using channel 1 and 2 (P0.0 and P2.1) to monitor the wiper arm of each pot (only testing P0.0 thus far) for a voltage range of 0 to 3.3V. When I do this, my program just locks and doesn't respond. If I comment out the ADC routines the program runs fine. The ports where configured prior to what you see now and worked fine. When I used the code architect to add the addition mask data for the port pin configuration, it is shown now. Even with the ADC commented out, the inputs work correctly, so I don't think that is the problem. Each bit is commented as bidirection, in and so forth. I can't figure out why my program hangs when it goes throught the ADC routine since code architect built the code.

I'm sure there will be plenty of questions and I'm ready to respond.

I am using the philips P89LPC936FA processor, this is my last hurdle, hopefully I'm just missing something stupid simple.

One thing that is mentioned in the code generation is that I should set EA=1, but not sure why or where or when that is needed. I thought the interupt flags where clear upon the call being completed and exited??

Can anyone give me an idea what I'm doing wrong? Thank you

chris


#include "define.h"     // file for definition of constants
#include "ADC_HEADER.h"
#include "eeprom.h"
extern bit timeout;

void Input_Configuration(void)    // 
{
unsigned char n;
// set IO pins:  in-out-bidirectional B=00, I=10, O=01, OD=11
    
    P0M1=0x09; // 0.7-0.0  B B B B  I B B OD                   
    P0M2=0x01;
    P1M1=0x80; // 1.7-1.0  O B B B  O B B B
    P1M2=0x88;
    P2M1=0x00; // 2.7-2.0  B B B B  B B B B
    P2M2=0x00;
    P3M1=0x00; // 3.1-3.0  B B B B  B B B B
    P3M2=0x00;

timeout=0;
TMOD=0x01;                  // set timer mode as watchdog for coomunication! T0 16 bits
for (n=0; n<0x8; n++);;     // wait 16 usec before communication with camera starts
}

/***********************************************************************
DESC:    Initializes the ADC
RETURNS: Nothing
CAUTION: Set EA to 1 after calling to enable all interrupts
************************************************************************/
void adc_init(void)
{
  
  ADMODB |= 0x40;   // configure clock divider  
  //P1M1 |= 0x80;   // set adc0 channel pins to input only (disables digital output)
  //P1M2 &= ~0x80;  // channel 0
  
  //P0M1 |= 0x01;   // channel 1
  //P0M2 &= ~0x01;
  
  ADMODB &= ~0x04;  // disable dac0
  
  ADCON0 |= 0x44;   // configure adc0 and enable (also enables dac0)
  
  IP1 &= 0x7F;      // set isr priority to 0
  IP1H &= 0x7F;
    
  EAD = 1;          // enable adc interrupt
}

void Main (void)    // main program
{
   
eeprom_init(); // initialize internal eeprom data transfer
eeprom_write(0x000, 0x00); // 
eeprom_write(0x001, 0x03); // 
eeprom_write(0x002, 0x00); // 

   
while(1) // Loop this section forever
   {   
    Input_Configuration();
    if(!imageup)image_up();             // HC Rocker switch HC mode UP    
    if(!imagedown)image_down();         // HC Rocker switch HC mode DOWN 
    if(!zoom_preset)zoom_set_reset();   // Check to see if zoom recall is active
    if(!freeze)freeze_mode();           // Freeze image on display
    
    
       
      
    adc_init();
    adc_start_ADC0_conversion(ADC_IMMEDIATE, ADC_AUTOSCANCONT, ADC0_CHANNEL0); //Read CH 0
    adc_stop_ADC0_conversion(); // Stop conversion of A/D  ONE SHOT READ PER CYCLE LOOP
    adc_convert_data('0');      // Read result from conversion register
     
    

   }

}




List of 16 messages in thread
TopicAuthorDate
Problems with Code Architect and interrupts            01/01/70 00:00      
   where is the ISR?            01/01/70 00:00      
      Erik...            01/01/70 00:00      
         you enable an interrupt for which there is no ISR            01/01/70 00:00      
            I missed the ISR routine....            01/01/70 00:00      
   Whoops, here is the .c file with the ADC ISR.....            01/01/70 00:00      
      Also forgot mention...simulation works fine            01/01/70 00:00      
   I found part of my problem            01/01/70 00:00      
      Interrupts            01/01/70 00:00      
         Modified.....seems right, I2C bus going nuts            01/01/70 00:00      
            Polling or Interrupts            01/01/70 00:00      
               Exactly......            01/01/70 00:00      
                  Opinion            01/01/70 00:00      
                     Gentlemen....thats what I thought I had!!            01/01/70 00:00      
                        Port config            01/01/70 00:00      
                  poll ....            01/01/70 00:00      

Back to Subject List