Jump to content

Yuki

EstablishedMember
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Yuki

  • Rank
    Newbrie
  1. Yuki

    Wizard bugs

    Very nice of you. I like this kind of tools. Code generated is simple and clear. I hope you expand chip coverage. Cut and paste is not a big problem for me.
  2. In ver 5.2.2 Pic ant IDE, when I start with wizard by checking off Use ADC, IO ports setting for PORTA is disabled and all IOs are set to input. Is it a bug or something wrong with my operation ?
  3. I am writing for 16f877 code with PicAntIDE 5.0.6. and met warning saying "Too many temporary variable" and "Can't map context saving variables into mapped ram area. check if the picant4.pat or picant2.pat script is used (in the script directory)" My question is How do I set picant4.pat or picant2.pat to be used in IDE. And there is no picant4.pat or picant2.pat in the script directory. thanks for your advice. Yuki
  4. Tahnks. By changing "00000110" to "00000110b" , LED portb 0 comes on. However, it seems RCIF never be cleared. The code runs continuously in the interrupt routine. Main routine is not executed. I put ADM485 to RC7/RX but physically any RS485 device is not connected. "rcvdata=rcreg;" should reset RCIF.
  5. Hi, I wrote some code to check 16F877 interrupts. In this code below, LEDs are connected to all portb and #2 of portd. When I run this code, LED (portb,4) switching on and off but LED (portb,3:timer1) stays OFF. LED (portd,2) in the main loop keeps ON. Are there anythig wrong with my code ? Thsnks for your help in advance. #include char rcvdata; /*20MHz*/ #pragma CLOCK_FREQ 20000000 /********************************************/ /* interrupt routine */ /********************************************/ void interrupt(void) { clear_bit(intcon,GIE); // RS interrupt if( (pir1 & RCIF) != 0){ // receive if ( (rcsta & 00000110) == 0){ // no error set_bit(portb,0); rcvdata=rcreg; set_bit(rcsta,CREN); } else { // error ! clear_bit(rcsta,CREN); set_bit(rcsta,CREN); } } else { nop(); } // Timer2 interrupt if ( (pir2 & TMR2IF) != 0){ clear_bit(pir2,TMR2IF); set_bit(portb,1); } // timer0 interrupt if( (intcon & T0IF) != 0 ){ clear_bit(intcon,T0IF); tmr0=0; set_bit(portb,2); } // Timer1 interrupt if ( (pir1 & TMR1IF) != 0){ set_bit(portb,3); clear_bit(pir1,TMR1IF); } // RB0 interrrupt if( (intcon & INTF) != 0){ set_bit(portb,4); clear_bit(intcon,INTF); } // RBs change interrupt if( (intcon & RBIF) != 0){ set_bit(portb,5); clear_bit(intcon,RBIF); } delay_ms(100); portb=0; // all LEDs off delay_ms(100); set_bit(intcon,GIE); return; } /********************************************/ /* main */ /********************************************/ main() { /*****IO port direction *****/ trisa = 001111b; trisb = 00000000b; // all outputs connected to LED (high->ON, low -> OFF) trisc = 10001001b;// trisd = 0011b; // trise = 110b; // PORT initial setting portb=0; // ALL LEDs off set_bit(portd,2); // LED OFF set_bit(portd,3); // LED OFF set_bit(portc,4); // LED OFF set_bit(portc,5); // LED OFF /***** ADC setting *****/ adcon1 = 10000111b; // AD not used adcon0 = 10000001b; // RS485 spbrg = 4; // SPBRG set_bit(txsta,BRGH); // high speed clear_bit(txsta,SYNC); // async //disable_interrupt(RCIE); clear_bit(pie1,RCIE); set_bit(rcsta,RX9); // 9bit set_bit(rcsta,CREN); // continuous receive clear_bit(rcsta,CREN); set_bit(rcsta,SPEN); // RS485 enable // timer 0 OPTION_REG = 00000111b; //t1con=0; // clear tmr1l=0; tmr1h=10; set_bit(t1con,T1CKPS0); // set_bit(t1con,T1CKPS1); // pre-scale 1:8 clear_bit(t1con,T1OSCEN); clear_bit(t1con,T1SYNC); clear_bit(t1con,TMR1CS); // internal clock; set_bit(t1con,TMR1ON); // timer enable // interrupt enable or disable clear_bit(intcon,T0IE); // tim0 disable clear_bit(pie1,RCIE); // RS disable disable_interrupt(RBIE); //clear_bit(intcon,RBIE); // RBs change disable set_bit(pie1,TMR1IE); // Timer 1 enable set_bit(intcon,PEIE); set_bit(intcon,GIE); // all interrupt while(1){ // main routine clear_bit(portd,2); // LED ON delay_ms(50); set_bit(portd,2); // LED OFF delay_ms(50); } //end of while return 1; }
×
×
  • Create New...