Congratulations Anatoly! I'm using ISR in a way I've learn with old jal and never failed. Never do it with libraries even they works ok.
On Sun, Apr 10, 2016 at 10:55 PM, Anatoly Titov <[email protected]> wrote: > Closed. I changed clock to 8Mhz and decreased check rate to 1 ms. All > works fine. > > воскресенье, 10 апреля 2016 г., 12:03:04 UTC+3 пользователь Anatoly Titov > написал: >> >> Hello! I made a code adapted from Arduino sketch. Sketch works, my code >> nope =(((( Please tell, how to get working code without interrupts. >> http://www.hobbytronics.co.uk/arduino-tutorial6-rotary-encoder working >> sketch >> my code: >> >> -- target PICmicro >> include 12f683 >> pragma target CLOCK 4_000_000 >> pragma target OSC INTOSC_NOCLKOUT >> pragma target WDT disabled >> pragma target MCLR internal -- reset on pin A3 >> pragma target WDT DISABLED -- watchdog >> pragma target BROWNOUT DISABLED -- brownout reset >> pragma target FCMEN DISABLED -- clock monitoring >> pragma target IESO DISABLED -- int/ext osc. switch >> -- >> enable_digital_io() -- make all pins >> digital I/O >> --OPTION_REG_NGPPU = 0 -- pull-ups ON >> OSCCON_SCS = 0 -- select primary >> oscillator >> OSCCON_IRCF = 0b110 -- 4 MHz >> -- >> -- setting pins >> >> >> alias enc_b is pin_A5 >> pin_A5_direction = input >> >> >> alias enc_a is pin_A4 >> pin_A4_direction = input >> >> >> -- configure PWM >> pin_ccp1_direction = output >> include pwm_hardware >> pwm_max_resolution(1) >> pwm1_on() >> >> >> -- timer setup >> const TIMER0_ISR_RATE = 1000 -- 1 kHz isr rate >> const DELAY_SLOTS = 1 -- support slots >> include timer0_isr_interval >> timer0_isr_init() -- init timer0 isr >> >> >> --setting variables >> var byte pwm >> var bit old_a >> -- >> pwm = 0 >> pwm1_set_dutycycle_percent(pwm) >> >> >> forever loop >> >> >> if check_delay(0) then >> set_delay(0, 5) >> >> >> if old_a & !enc_a then >> if enc_b then >> if pwm!=254 then pwm = pwm + 1 end if >> else >> if pwm!=0 then pwm = pwm - 1 end if >> end if >> pwm1_set_dutycycle_percent(pwm) >> end if >> >> >> old_a = enc_a >> end if >> >> >> end loop >> >> -- > You received this message because you are subscribed to the Google Groups > "jallib" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/jallib. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/jallib. For more options, visit https://groups.google.com/d/optout.
