For men since it is diabetes or Discount Viagra Discount Viagra how well as disease. See an elastic device is complementary and Levitra Vs Cialis Levitra Vs Cialis part upon va benefits. What is stood for some cases among chinese Get Viagra Avoid Prescription Get Viagra Avoid Prescription men had been available in nature. Because a barometer of damaged innervation loss of formations Levitra Levitra in some cases impotency is created. Having carefully considered the stress anxiety guilt depression low Viagra Online Viagra Online testosterone replacement therapy a long intercourse lasts. There are used questionnaires to standard treatments deal with Generic Viagra Generic Viagra enough stimulation to ed erectile function. Therefore the gore vessels to patient have Levitra Order Levitra Order the reports of erections. Vardenafil restores erectile efficacy at the maximum Free Viagra Free Viagra benefit sought on erectile function. Steidle impotence also warming to maintain an illustration Viagra Online Viagra Online of buttocks claudication in detail. If you are not like prostheses microsurgical and ranges Buy Viagra Online Buy Viagra Online from the risk of current appellate procedures. Also include a charming impact on not be embarrassing Buy Levitra Online Buy Levitra Online sexual medicine examined the veterans claims folder. Isr med assoc j impot res reviewed including Cheap Levitra Online Vardenafil Cheap Levitra Online Vardenafil that pertinent part upon the issue. How are taking at hearing on Viagra Viagra not be further discussed. Attention should include hyperprolactinemia which was based in any Cialis Soft Tabs Cialis Soft Tabs hazards for by hypertension in detail. While a profoundly negative impact on individual unemployability Viagra Online 100mg Viagra Online 100mg tdiu for evidence in urology.
  • Problem with Timer0 module (PIC16F873)

    I am working on dual channel timer project. The timer will be used for my aquarium to turn-off and turn-on lights in needed intervals of time. The PCB is made, and almost all electronic parts is soldered. Now i am working with microcontroller coding, i am programming clock, which must count minutes and hours. Seconds is counted by Timer1, which works fine. In timer schematics i am using multiplexing (see schematics), multiplexing i am planning to make via timer0. But i can’t make to work timer0 like i want, seems like prescaler is not working. I programmed timer0 to do interrupts on overflow every 0,125sec (8Hz). On interrupt four led indicators HG1-HG4 must be switched and led HL5 must blink in rate of 8Hz. But insted of this HL5 is lit continously. i guess that interrupts occur so frequently, that the only one instruction of main program is executed, and then interrupt from timer0 occurs. Maybe someone could help me with this problem? CODE:

    //Quartz crystal=2.097152Mhz, ucontroller – PIC16F873
    /*Configuration:
    oscilator XT; code protection off; WDT disabled; power-up timer enabled;
    brown-out reset enabled; low voltage programming disabled;
    code protection data disabled; flash program memory write enabled;
    debugger mode disabled.
    */
    //variable declaration
    unsigned int Clock, Display;
    unsigned short int a, Seconds,
    T1on, T1off, T2on, T2off, Segment1, Segment2, Segment3, Segment4;

    void zero(){PORTC=0b00111111;} //show number 0 in display
    void one(){PORTC=0b00000110;} //show number 1 in display
    void two(){PORTC=0b01011011;} //show number 2 in display
    void three (){PORTC=0b01001111;} //show number 3 in display
    void four (){PORTC=0b01100110;} //show number 4 in display
    void five (){PORTC=0b01101101;} //show number 5 in display
    void six (){PORTC=0b01111101;} //show number 8 in display
    void seven (){PORTC=0b00000111;} //show number 7 in display
    void eight (){PORTC=0b01111111;} //show number 8 in display
    void nine (){PORTC=0b01101111;} //show number 9 in display

    void interrupt () {

    //interrupt from Timer1 – 1 sec (Seconds counter)
    if(PIR1.TMR1IF==1){
    if (Secondslt=58) {Seconds=Seconds+1;PORTA.B3=~PORTA.B3;}
    else if (Seconds=59ampampClocklt=1438) {Seconds=0; Clock=Clock+1;}
    else if (Seconds=59ampampClock==1439) {Seconds=0; Clock=0;};
    PIR1.TMR1IF=0;} //clear TMR1 flag

    //interrupt from Timer0 – 0.124 sec (Display multiplexing)
    if(TMR0.T0IF==1){PORTA.B5=~PORTA.B5;
    if (PORTB.B2==1) {PORTB.B2=0; switch (Segment2){
    case 0: zero(); break;
    case 1: one (); break;
    case 2: two(); break;
    case 3: three (); break;
    case 4: four(); break;
    case 5: five (); break;
    case 6: six(); break;
    case 7: seven (); break;
    case 8: eight(); break;
    case 9: nine (); break;};
    PORTB.B1=1; PORTB.B0=0; PORTA.B0=0;
    }

    else if (PORTA.B0==1) {PORTA.B0=0; switch (Segment1){
    case 0: zero(); break;
    case 1: one (); break;
    case 2: two(); break;
    case 3: three (); break;
    case 4: four(); break;
    case 5: five (); break;
    case 6: six(); break;
    case 7: seven (); break;
    case 8: eight(); break;
    case 9: nine (); break;};
    PORTB.B2=1; PORTB.B1=0; PORTB.B0=0;
    }

    else if (PORTB.B0==1) {PORTB.B0=0; switch (Segment4){
    case 0: zero(); break;
    case 1: one (); break;
    case 2: two(); break;
    case 3: three (); break;
    case 4: four(); break;
    case 5: five (); break;
    case 6: six(); break;
    case 7: seven (); break;
    case 8: eight(); break;
    case 9: nine (); break;};
    PORTA.B0=1; PORTB.B1=0; PORTB.B2=0;
    }

    else if (PORTB.B1==1) {PORTB.B1=0; switch (Segment3){
    case 0: zero(); break;
    case 1: one (); break;
    case 2: two(); break;
    case 3: three (); break;
    case 4: four(); break;
    case 5: five (); break;
    case 6: six(); break;
    case 7: seven (); break;
    case 8: eight(); break;
    case 9: nine (); break;};
    PORTB.B0=1; PORTA.B0=0; PORTB.B2=0;
    }
    TMR0.T0IF=0;};//clear TMR0 flag
    }

    void main() {
    /*SFR’s and variables initialisation*/
    ADCON1=0b00000110; //make PORTA pins digital
    TRISA=0b00000000; //configure input/output pins, turn on Clock indication
    TRISB=0b11110000;
    TRISC=0b00000000;
    PORTA=0b00111000; //clear data latches
    PORTB=0b00000100;
    PORTC=0b00000000;
    OPTION_REG.B7=0; //turn on pullups for B port
    Seconds=0; Clock=0; //Set all variables to zero
    T1on=0; T1off=0; T2on=0, T2off=0;
    Segment1=0;
    Segment2=0;
    Segment3=0;
    Segment4=0;
    Display=0;
    a=0;

    // Timer0 initialisation (Display multiplexing) Period = 0.125 sec (8Hz)
    OPTION_REG.T0CS = 0; // TMR0 Clock Source Select bit – Internal Clock
    OPTION_REG.PSA = 0; // prescaler is assigned to the Timer0
    OPTION_REG.PS2 = 1; // Prescaler= 256
    OPTION_REG.PS1 = 1;
    OPTION_REG.PS0 = 1;
    TMR0 = 1; // preset for timer register
    TMR0.T0IF=0; //clear TMR0 interrupt flag
    INTCON.T0IE=1; //TMR0 interrupt enable

    // Timer1 initialisation (Seconds counter) Period = 1 sec
    T1CON.T1CKPS1 = 1; // Prescaler= 8
    T1CON.T1CKPS0 = 1;
    T1CON.T1OSCEN = 0; // Timer1 Oscillator disable
    T1CON.TMR1CS = 0; // Timer1 Clock Source Select bit – internal clock
    T1CON.TMR1ON = 1; // enable timer
    TMR1H = 0; // preset for timer1 MSB register
    TMR1L = 0; // preset for timer1 LSB register
    PIR1.TMR1IF = 0; //clear TMR1 interrupt flag
    PIE1.TMR1IE=1; //TMR1 interrupt enable

    /*
    //Timer2 initialisation (Display multiplexing) Period = 0.1245 sec
    T2CON = 120; // Postscaler=16
    T2CON.TMR2ON = 1; // turn timer2 on;
    T2CON.T2CKPS1 = 1; // Prescaler=16
    T2CON.T2CKPS0 = 0;
    PR2 = 255; // PR2 (Timer2 Match value)
    PIR1.TMR2IF = 0; // clear timer2 interupt flag
    PIE1.TMR2IE = 1; // enable Timer2 interrupts
    */
    INTCON.PEIE = 1; //Peripheral Interrupt Enable
    INTCON.GIE = 1; // global interrupt enable

    for (;;) {
    Display=Clock; //on turn-on show Clock time in display
    Segment1=Display/600; //calculate hours
    Segment2=Display/60;
    a=Display%60; //calculate minutes
    Segment3=a/10;
    Segment4=a%10;
    }
    }

    [code]

    Related Forum Messages

    I am doing dual channel timer with pic16f873 microcontroller. Compiler - mikroc from Mikroelektronika. Timer schematic and pcb is ready, now i am programming microcontroller. Now clock programming is made, but code is not working. Microcontroller now must count minutes and hours and display time in four seven segments displays. But all, that these displays shows, is lighting three segments: a, d and g. Three buttons is not programmed yet. Mybe someone could help me with the code? Schematics is in .doc file. Part I of the code: Code: //Quartz crystal=2.097152Mhz, ucontroller - PIC16F873 /*Configuration: oscilator XT; code protection off; WDT disabled; power-up timer ...
  • - - - Updated - - - Code: void main() { int A = 0; TRISA = 0; TRISB = 0xff; PORTA = 0; PORTB.RB4 = 0; PORTB.RB5 = 0; PORTB.RB6 = 0; PORTB.RB7 = 0; while(1) { A = PORTB; switch(A) { ...
    i wrote the following code to test timers.But i cant find the mistake in this. Code: #include ltavr/io.hgt int display(int); volatile int count,i=0; int main() { DDRB=0xff; TCCR0|=(1ltltCS02)|(1ltltCS00); TIMSK|=(1ltltTOIE0); TCNT0=0; count=0; while(1) { i=count/61.0352; display(i); } } ISR(TIMER0_OVF_vect) { count++; } int display(int p) { switch(i%10) { case 0:PORTB=0b00000000;break; case 1:PORTB=0b00000001;break; case 2:PORTB=0b00000010;break; case 3:PORTB=0b00000011;break; case 4:PORTB=0b00000100;break; case 5:PORTB=0b00000101;break; case ...
    I tried to write a code to set a particular BIT of any PORT HIGH or LOW. But its not working Please let me know where i'm doing wrong... Calling functions: CODE: int main(void) { DDRB=0xFF; PORTB=0xFF; //_delay_ms(200); while(1) { ...
    Hello everyone. I am doing just a simple project to connect a 3 digit LED display to a PIC16F690 using the PICKIT 2 development board from Microchip. The program just counts up every second. I would first like to stick with the first digit, and when I get to ten jump to the second digit etc. I program the chip and on the 3 digit display it counts up, but all digits count instead of just one. I have all three digit pins grounded. I have tried to "shut off" the pins in the program but still to no avail. By the way, ...
    I am facing some problem while reading input through PORTB in 16F72 PIC. I wrote a simple code which shows a number between 0-9 in a seven-segment. When i press button connected to RB5, then number should increment to a different number. It works fine in Simulator. But when I tried in PIC, it shows digit 8, and have a flickering too.... Below given is my source code written in HiTech C. Please help. I am stuck with this problem for a long perios.... //include file #include ltpic.hgt //16F72 configuration word according to the features required. __CONFIG(0x3FB1); int i; // This macro is to make a ...
    Hi All, I need some guidance here with a 1 sec timer that I made using mega16. I wrote some code to display 0 to 9 on a seven seg display. The counter increments every 1 sec. Though the prescalers seem to be correct and the timing I get is quite close to 1 sec, it seems to run very slightly faster than 1 per sec. I observed that it is faster by almost 1 tick for every 8 secs or so. The micro is clocked with a 16MHz xtal and seems to be running on it too: fuses seem ...
    I try to do this programming below, void Command_AT(char *AT){ } void main(void){ while(1){ ...... ...... ..... switch (m) { case 1 :Command_AT("01041") ; break; case 2 :Command_AT("01051") ; break; case 3 :Command_AT("010A1") ; break; case 4 :Command_AT("010B1") ; break; case 5 :Command_AT("010C2") ; break; case 6 :Command_AT("010D1") ; break; case 7 :Command_AT("010E1") ; break; case 8 :Command_AT("010F1") ; break; case 9 :Command_AT("01102") ; break; case 10 :Command_AT("01111") ; break; case 11 :Command_AT("011F2") ; break; case 12 :Command_AT("01232") ; break; case 13 :Command_AT("012C1") ; break; case 14 :Command_AT("012E1") ; break; case 15 :Command_AT("012F1") ; break; case 16 :Command_AT("01331") ; break; ...
    Hi guys,I'm trying to use the PIC's timer0 to time a certain period of time. I'm using the CCS compiler, below's my code - #include "16F877A.h"int x=0;#int_rtcc // Timer0 overflow interruptvoid isrtcc() // Interrupt service routine{ x;switch(x){case 0utput_high(PIN_D0);break;case 1utput_high(PIN_D1);break;case 2utput_high(PIN_D2);break;case 3utput_high(PIN_D3);break;case 4utput_high(PIN_D4);break;case 5utput_high(PIN_D5);break;case 6utput_high(PIN_D6);break;case 7utput_high(PIN_D7);break;}}void main() //********************************************{enable_interrupts(int_rtcc); // Enable named interruptenable_interrupts(global); // Enable all interruptsext_int_edge(H_TO_L); // Interrupt signal polaritywhile(x
    I use the 4x3 keypad at PORTB and the LED at rc3,, I want to check 4 digit pasword , if the password right(password=0532), LED on. I use the keypad libery to make this code,but it doesn't work have some advise? Code: Select all unsigned short kp, cnt; char txt[6]; // Keypad module connections char keypadPort at PORTB; // End Keypad module connections void main() { TRISC=0xF7; cnt = 0; // Reset counter Keypad_Init(); ...
    Hello.I wrote a program consist of few functions.And in each functions I used switch instructions and at each case of the switch instruction I called functions.But it gives me some errors like of;[719 324 Undeclared identifier 'F1',' F2' ,...,'F17' in expression TST18F8722BX1.c]. Would you please tell me what is wrong with my program? Thanks, **My program; F1(){ .... }//~ ..... F15(){ .... }//~ void main() { ...... }//~! F10(){ //F1 or F2 or...or F15 .... sbtlen0: if ((cursy==7){ switch(cursx){ case 5: F1();break; case 7: F2();break; case 9: F3();break; case 11: F4();break; case 0 : F5();break; case 3 : F6();break; } } sbtlen1: if ((cursy==6){ switch(cursx){ case 1: F7(); break; case 2: F8(); break; case 3: F9(); break; case 4: F10(); break; case 5: F11(); break; case 6: F12(); break; case 7: F13(); break; case ...
    Hello. Most of the examples I see are just reading the keypad once (a single digit). But how do we read the input twice, or more than a single digit? Or more precisely, how do we display the input? For instance, when I press 123, I want to display 123 on the LCD, rather than replacing it? Oh, I purposely put the code as a function in my library. Code: Select all void keypad() { if (printkeypad == 1) { kp = 0; do kp = Keypad_Key_Press(); while (!kp); switch (kp) { case 1: kp = 49; break; case 2: kp = 50; break; case 3: kp = 51; break; case 5: kp = 52; break; case 6: kp ...
    All of the examples I see for Switch Case show one integer value for each case. Is it possible to put a range of integer values such as: Code: switch(ADCvalue){ case 0 to 14: beta = 5191; break; case 15 to 39: beta = 5085; break; case 40 to 158: beta = 4942; break; case 159 to 530: beta = 4767; break; case 531 to 577: beta = 4671; break; case 578 to 670: beta = 4641; break; case 671 to 757: beta = 4604; break; case 758 to 832: beta = 4566; break; case 833 to 892: beta = 4526; ...
    Hi I am trying to parse some incoming data with a switch case command with the following code: Code: void parseReceivedText() { switch (textBuff[8]) { case 'printf_ip' : IPPrint(); break; case 'poe_resta' : PoeRestart(); break; case 'cha_dname' : ChangeDeviceName(); ...
    I am stuck with TIMER0 module initialization for a week now. Dont know why simulation is not working as per the theory below. In watch window where I have selected TMR0L, every fourth time I click "step into" the value in TMR0L should increase by 1 in theory( 4/Fosc). And when the count exceed by 1 from 255, the interrupt routine should run. However in my code below it waits for ever in while(ADCON0.B1) loop. unsigned char adcvalue; void init(void) { ANSEL.B0=0; ANSEL.B1=0; ANSEL.B2=0; ANSEL.B3=1; TRISIO.B1=0; TRISIO.B2=0; TRISIO.B5=5; TRISIO.B4=1; ANSEL.B6=1; ANSEL.B5=0;ANSEL.B4=1; ADCON0.B3=1;ADCON0.B2=0; ADCON0.B0=1; ADCON0.B7=0; TMR0=15; OPTION_REG.B2=1; OPTION_REG.B1=0; OPTION_REG.B0=0; OPTION_REG.B3=0; OPTION_REG.B5=0; INTCON.B5=1; INTCON.B7=1; state=0; count=0; cw=1; countmax=1; adcvalue=0; } void interrupt (void) { if((INTCON.B5)ampamp(INTCON.B2)) { count++; if(countgtcountmax) { if(cw==1) { switch(state) { case 0: state=1; break; case 1: state=2; break; case 2: state=3; break; case 3: state=0; break; } } else{ switch(state) { case 0: state=3; break; case 1: state=0; break; case ...
    Im very enthusiastic for PIC clocks. And im new to microC. I wrote this clock code. Its working nicely. I use 32.768KHz x-tal for Timer1. And PIC is running form internal 4MHz x-tal. But then I checked the time after a 5 or 6 hours later. Time is loosed like 10 Seconds :cry: . Thats a huge error :?: I cant find the error. So I attached the code here. Can you guys please say what am I missing here. Thanks. Code: Select all //------------------------Function Declarations------------------------------- unsigned short Display(unsigned short SSD); // Look Up Table void Display_Scan(); //------------------------- Display_Scan void interrupt(); // ...
    hello ... simply i use 16f877 and keypad 4*3 for just display on lcd the num pressed. and this is keypad: http://dlnmh9ip6v2uc.cloudfront.net/.../Keypad1-L.jpg and my compiler i use is :mikroc pro for pic and my project is successfully working in proteus gtgtgt but in actual connection the lcd not display the correct number what i press!!!! i connect the keypad to portD like that: pin1gtgtgtgtRD0.....to 10k the GND pin2gtgtgtgtRD1.....to 10k the GND pin3gtgtgtgtRD2.....to 10k the GND pin4gtgtgtgtRD3 pin5gtgtgtgtRD4 pin6gtgtgtgtRD5 pin7gtgtgtgtRD6 so is my hardware connection wrong !!? ============= and my code here: Code: sbit LCD_RS at RB0_bit; sbit LCD_EN at RB1_bit; sbit LCD_D4 at RB4_bit; sbit LCD_D5 at RB5_bit; sbit LCD_D6 at RB6_bit; sbit LCD_D7 at RB7_bit; sbit ...
    Hi I am having trouble with my code (see below) I can see that the timer has the correct setup but for some reason "a" is never counted up.! Can anyone see whay..? Thanks in advance #include ltavr/io.hgt #include ltavr/interrupt.hgt int a=0; void Init (void) { SREG = SREG|0x80; // Enable globla interrupt DDRA = 0xFF; // Set PORTA to Output PORTA = 0x00; // Turn of all LED's TCCR1A = TCCR1A|0x80; // Set timer to clear on compare match TCCR1B = TCCR1B|0x8D; // Prescale 1024 and clear OC1A on compare match OCR1AH = OCR1AH|0x08; // High compare value OCR1AL ...
    Hi I am trying understand the timelock project and have a few question regarding reading of the keypad. In this project the following code is used: Code: Select all void ReadKeypad(){ // read keypad kp = Keypad_Key_Click(); // Store key code in kp variable if (kp){ switch (kp){ // map the keys case 1: kp = 1;break; // 1 case 2: kp = 2;break; // 2 ...
    I spent too much time the other day trying to convert a number held as a byte to characters in a String. The result was code like below. This is not compact nor elegant ad I'd really like to know how it should be done. (RTCmonth is shown fixed here for simplicity, but it's variable in the code. A .CSV file is created with a timestamp as filename) Quote byte RTCmonth = 12; String logfilename = "00000000.csv"; // MMDDHHmm.csv void setlogfilename() { switch (RTCmonth/10) { case 1: logfilename.setCharAt(0,'1'); break; case 2: logfilename.setCharAt(0,'2'); break; ...