Hi all,
i wrote a c program that can take in left turn (RC0), right turn (RC1) & brake signal (RC2)inputs and put out flashing signal at RC3 (right/brake) and RC4 (left/brake). Basically this code works but i am not able to change the flash rate to be in between 60-120 flashes per minute. Right now, i can play around with internal oscillator & prescalar to get the flash rate to be at 60 or at 120 but not in between. i have a variable "counter1" which is at 1 right now, but when i change it to 2 it stop flashing all together. this makes me wonder if my code is checking for "counter1>=1" too many times inside the code. i am not using any hard interrupt (i am a beginner and i dont know how to). any help is appreciated or how to write interrupt will be useful if thats the way to go. i am attaching the c code.
OSCCON = 0b01010000; //Oscillator set to 500kHZ
OPTION_REG = 0b00000111; //prescalar 256
i wrote a c program that can take in left turn (RC0), right turn (RC1) & brake signal (RC2)inputs and put out flashing signal at RC3 (right/brake) and RC4 (left/brake). Basically this code works but i am not able to change the flash rate to be in between 60-120 flashes per minute. Right now, i can play around with internal oscillator & prescalar to get the flash rate to be at 60 or at 120 but not in between. i have a variable "counter1" which is at 1 right now, but when i change it to 2 it stop flashing all together. this makes me wonder if my code is checking for "counter1>=1" too many times inside the code. i am not using any hard interrupt (i am a beginner and i dont know how to). any help is appreciated or how to write interrupt will be useful if thats the way to go. i am attaching the c code.
OSCCON = 0b01010000; //Oscillator set to 500kHZ
OPTION_REG = 0b00000111; //prescalar 256
Attachments
-
5.1 KB Views: 16