CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Button PIC18F2685

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
czarkek



Joined: 16 Jul 2008
Posts: 1

View user's profile Send private message

Button PIC18F2685
PostPosted: Wed Jul 16, 2008 6:03 am     Reply with quote

Hi, i think i have simple problem for someone with experience, but i dont know how solve this. My question is why if i return to main loop after proces1 or proces2, my holding of button not working and works like press. It working only once in first use. My code looks like this:


Code:

#int_TIMER2
void  TIMER2_isr(void)
{
if(t1)
   t1--;
}
void check_buttons(void)
{
char new_status;

new_status = input(PIN_A3);

if (new_status==0)
{
   if(new_status != gc_old_button_status)
     {
     t1 = BUTTONS_TIMER_TICKS;

     }
   else
      {
      if(!t1)
         output_low(PASS);
      }
}
else
{
   if(new_status != gc_old_button_status)
     {
     if(t1)//go to simple mode
     rs=2;
     else //go to rs232 mode
     rs=1;
     }
}
// Save button status for next time.
gc_old_button_status=new_status;
}

void main()
{
   no_m=0;
   can_init();
   t2=0;
   t1=0;
   net_id=0x501;
   net_rtr=0;
   net_ext=0;
   net_len=8;
   net_pri=3;
   for (z=0;z<net_len;z++)
   net_data[z] = 0;
   net_data[0] = 0x11;
   net_data[1] = 0x02;
   rs=0;
   load_busy_and_msg();



   //write_can_settings();
   can_set_mode(CAN_OP_CONFIG);
   load_can_settings();
   can_set_mode(CAN_OP_NORMAL);
   can_set_mode(CAN_OP_CONFIG);
   load_can_mask();
   can_set_mode(CAN_OP_NORMAL);
   //settings
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DIV_BY_16,48,4);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_vref(FALSE);
   enable_interrupts(GLOBAL);
   
   enable_interrupts(INT_TIMER2);
   disable_interrupts(INT_RTCC);

output_high(FAIL);
output_high(PASS);
start:
gc_old_button_status = input(PIN_A3); // get switch status
rs=0;
 //printf("\n\r CHOOSING MODE \n\r");
   while(1)
   {
   check_buttons();
   if (rs==1)// go to rs232 mode
      {
      output_high(PASS);
      output_low(FAIL);
      goto stage1;
      }
   // if not go to sending mode
   else if(rs==2)
      {
      output_high(FAIL);
      output_high(PASS);
      goto stage2;
      }     
   }
stage1:
proces1();
output_low(PASS);
goto start;
stage2:
proces2();
output_low(FAIL);
goto start;
}


Thanks in advance.

P.S. Sorry for my English. Smile
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group