yup free .. I have been thinking about purchasing, just for the fact of freeing up program space but havn't made that 50$ leap just yet...
thought about switching to asm for this one function, that would cut out compiler adding extra spurious code?
any ideas about how/when spurious code occurs are there instructions I should avoid or change, for example i often change for statements to if's and goto's.
also how to i find out how long each instruction takes, i figure a nop time period would take 1 clock tick, and a=b would be closer to 3 or 4 ticks..? would a asm conversion reveal more into this?
I have been thinking about the clock inaccuracy problem, i may have made a mistake when i was thinking faster=more accurate, but now that i realize problem is in the clock itself, maybe a lower frequency would be more stable?
I am using LCD just for debugging, but since i cant change LCD internal baud rate without first achieving current baud rate I decided to use pickit uart tool in place of LCD where i can slow PICKIT down to 300 baud... interesting note after getting on a scope, these instructions are for a 2ms delay:__delay_ms(1);__delay_us(980); .... is this where i should use osctune to compensate?
Thanks for the tolerance notes, I now realize that sending 5 chars results in the first and last ones outputting wrong, but the middle 3 are ok, i though at first that it was an error with a polarity or delay time with the start/stop bits ... after getting scope on it, it turns out that there is another function clearing RC1 ... I try using that trick with a dummy byte for port C that we just talked about the other month.. but it is maybe not working so well this time...
another interesting note to my problem is that it lies in BOTH of these next functions , ie leaving one out is not enough to keep the RC1 bit from clearing to 0... I will highlight the lines in RED to show exactly which lines i had to remove to keep RC1 at a logic 1 value... runLED is on timer0 interrupt and sendIR is called by main()... (just mentioning in case...)
EDIT: code tags dont highlight red so i will leave the 4 //'s in a clearly visible location
Code:
void runLED(unsigned char R, unsigned char G, unsigned char B)
{
unsigned char dummy = PORTC;
if(B > dutyCounter){dummy &= 0b11101111;}else{dummy |= 0b00010000; }
if(R > dutyCounter){dummy &= 0b11111011;}else{dummy |= 0b00000100; }
if(G > dutyCounter){dummy &= 0b11110111;}else{dummy |= 0b00001000; }
if(dutyCounter > 250){dutyCounter = 0;}else{dutyCounter++;}
// PORTC = dummy;
}
void sendIR(unsigned int Rem)
{
unsigned char counter;
unsigned char dummy = PORTC;
INTE = 0;
delayMS(1);
// start bit
for (counter = 0;counter<16;counter++)
{
dummy|= 0b00100000;
delayMS(1);
dummy&= 0b11011111;
if (Rem & 1){delayMS(1);}
else {delayMS(2);}
Rem = Rem >> 1;
}
counter = PORTA;
// PORTC = dummy;
delayMS(1);
INTF = 0;
INTE = 1;
}