I know that I'm going to learn something here that I will never make the same mistake on again, but I am having a major problem with code that I have developed. I am writing a hexidecimal value to PORTB and the value is not always the same as what I wrote to it. I set breakpoints immediately after I set the value and I still see the difference so I know that something else that I have done is not modifying it. Originally I was using a lookup table to get my values but to simplify and try to debug this problem I am just writing the output to the port manually. The values are always close to what I have written but they are not always correct. It also seems that bits 2 or 3 are the bits affected. Here is the code that I'm using (excuse all the commented out because I am trying to simplify to isolate the problem). Any help on this would be greatly appreciated! #include "o:\projects\safari\Safari.h" /// The following are manually added definitions #byte PORTB = 0x06 #define ALL_OUT 0x00 #define ALL_IN 0xFF //int mirror; //int direction; // which direction are we moving? int angle; // sinelookup pointer //int sinelookup[19] = {1,3,9,17,31,47,65,85,105,129,151,171,191,209,225,239,247,253,255}; #int_rtcc rtcc_isr() { switch (angle){ Case 0: // mirror = sinelookup[angle]; PORTB = 0x00; angle++; // if (angle++ >= 17){ // direction = 2; // } break; Case 1: PORTB = 0x2D; angle++; break; Case 2: PORTB = 0x57; angle++; break; Case 3: PORTB = 0x7F; angle++; break; Case 4: PORTB = 0xA3; angle++; break; Case 5: PORTB = 0xC3; angle++; break; Case 6: PORTB = 0xDD; angle++; break; Case 7: PORTB = 0xEF; angle++; break; Case 8: PORTB = 0xFB; angle++; break; Case 9: PORTB = 0xFF; angle=0; break; } output_low(PIN_B0); delay_us(10); output_high(PIN_B0); return; } #int_adcc adc_isr() { } #int_eeprom eeprom_isr() { } #int_timer1 timer1_isr() { } #int_timer2 timer2_isr() { } void main() { setup_adc_ports(A_ANALOG); setup_adc(ADC_CLOCK_DIV_2); setup_spi(FALSE); setup_psp(PSP_DISABLED); setup_counters(RTCC_INTERNAL,RTCC_DIV_2); setup_timer_1(T1_INTERNAL|T1_DIV_BY_1); setup_timer_2(T2_DIV_BY_16,1,1); setup_ccp1(CCP_OFF); setup_ccp2(CCP_OFF); enable_interrupts(INT_RTCC); // enable_interrupts(INT_ADC); // enable_interrupts(INT_EEPROM); // enable_interrupts(INT_TIMER1); // enable_interrupts(INT_TIMER2); enable_interrupts(global); set_tris_b(ALL_OUT); // Set all pins on PORTB as Outputs PORTB = 0x00; // Set all pins on PORTB Low angle = 0; // Initialize angle pointer // direction = 1; // and direction. do { } while(TRUE); } -- http://www.piclist.com hint: PICList Posts must start with ONE topic: "[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's