Jump to content

indian engineer

  • Content Count

  • Joined

  • Last visited

Everything posted by indian engineer

  1. Thanks for response. But I am a very beginner in this field. So Please explain and if there are any articles specifically saying this type of problems please post their link. I understood that the timer0 overflows before display() function finishes. But didn't go the idea to troubleshoot Thanks
  2. Hi there, Is there any problem in the following code? #include <system.h> //Target PIC16F84 configuration word #pragma DATA _CONFIG, _PWRTE_OFF & _WDT_OFF & _HS_OSC & _CP_OFF //Set clock frequency #pragma CLOCK_FREQ 4000000 int ar[3][3]; //======================Timer 0 handler============================= static void display( void ) { int i; for(i=0;i<3;i++) { portb.6=portb.7=porta.0=0; if(i==1){portb.7=1;portb.6=porta.0=0;} else if(i==2){porta.0=1;portb.6=portb.7=0;} else {portb.6=1;portb.7=porta.0=0;} if(ar[i][0]==1) { portb.0=1;portb.1=0; } else if(ar[i][0]==2) { portb.1=1;portb.0=0; } else { portb.0=portb.1=0; } //--------- if(ar[i][1]==1) { portb.2=1;portb.3=0; } else if(ar[i][1]==2) { portb.3=1;portb.2=0; } else { portb.2=portb.3=0; } //----------- if(ar[i][2]==1) { portb.4=1;portb.5=0; } else if(ar[i][2]==2) { portb.5=1;portb.4=0; } else { portb.4=portb.5=0; } //--------- delay_ms(50); } } //=====================Interrupt==================================== void interrupt( void ) { //Handle timer0 interrupt if( (intcon & (1<<T0IF))!=0 ) { display(); //call timer 0 handler clear_bit( intcon, T0IF ); //clear timer 0 interrupt bit } } //==========================Main==================================== void main( void ) { //Configure port A trisa = 0x14; //Configure port B trisb = 0x00; //Initialize port A porta = 0x00; //Initialize port B portb = 0x00; //Set Timer0 mode clear_bit( option_reg, T0CS ); //configure timer0 as a timer //Set prescaler assignment clear_bit( option_reg, PSA ); //prescaler is assigned to timer0 //Set prescaler rate set_bit( option_reg, PS2 ); //prescaler rate 1:256 clear_bit( option_reg, PS1 ); set_bit( option_reg, PS0 ); //Set timer0 source edge selection //set_bit( option_reg, T0SE ); //increment on high-to-low transition on RA4/T0CKI pin //Enable interrupts (Timer0) intcon = 0xA0; int i,j; for(i=0;i<3;i++) { for(j=0;j<3;j++) { ar[i][j]=0; } } while(1) { for(i=0;i<3;i++) { for(j=0;j<3;j++) { ar[i][j]=1; delay_s(2); ar[i][j]=2; delay_s(2); ar[i][j]=0; } } } } //========================End of Main=========================== The problem is that when simulating in sourceboost IDE the interrupt function once executed, the control will not terminate from interrupt function (Here display function). I mean, the control is looping around display() and not return to main(). I didn't understan what is the problem. Help me please. I have the external circuit also. If necessary I will attach it. Thanks in advance
  3. I have written a program in boostC and an error occured at runtime. The program was to display some pattern on LED matrix according to the switch input. I used timer interrupt for this purpose. But in debug stage, I found that: 1)First time program starts to execte. 2)After an interval, interrupt function (Here display) is executed. 3)Then this function is repeated continously and not coming to the actual program. Please help me to fix this problem. My program is much complicated and didn't obayed universal standards of programming. For this reason, I am not attaching the program here. If you require, I definitely add it. Thanks in advance
  4. I have successfully built

    a programable multifunction chaser using pic16f84 and boostc.All files about it are available.It is FREE!!.contact me :tomkonikkara@gmail.com

  • Create New...