augustinetez
Active Member
I really need to learn to read properly, rjenkinsgb's last modification in post #38 is close enough to how it's done in the asm file - the ref+osc value is the DDS_FACTOR from his post
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
/*--- Encoder function ---*/
void encoder_click(void)
{
static unsigned char previous = 0;
unsigned char temp;
temp = 5;
while(temp--){ /* debounce */
;
}
temp = PORTB; /* Read port */
temp >>= 2; /* Shift input to bit positions 1, 0 */
temp &= 0x03; /* Mask out bits */
previous <<= 2; /* shift the previous data left two places */
previous |= temp; /* OR in the two new bits */
encoder_count += table[(previous & 0x0f)]; /* Index into table */
}
That could be because it was written 50 years ago. However, I find it's syntax to be very simple.C appears to have the most arcane syntax of any high level computer language.
Doesn't that answer itself? C is closer to the hardware than many "higher" level languages and so is ideal to learn the hardware - especially of microcontrollers.Can some explain to me its popularity for hobbyists.
Then your mind obviously works different than mine.However, I find it's syntax to be very simple.
I'm not referring to new languages, just those that use a less arcane syntax.Many of the "new" languages are Object Orientated which adds a huge amount of extra complexity and code.
I use LTspice.Can I ask why you don't use a more modern simulator rather than an arcane soldering iron?