Oops.. up till my attempts today , i have been cranking the clock to max, then osctune to max, faster=better right?
then I run this code to find what the baud delay i need is:
(the debug code is commented out here, baud is the value i ended up needing)
Code:
void delayUS(unsigned int t)
{
while (t>999){__delay_us(10000);t-=1000;}
while (t>99){__delay_us(1000);t-=100;}
while (t>9){__delay_us(100);t-=10;}
while (t>0){__delay_us(10);t-=1;}
}
void LCDascii(unsigned char dat)
{
unsigned char cnt;
unsigned char datdat;
unsigned int baud=0x133;
// for (baud=0x1;baud<2000;baud++){
// dat = 0xAA;
// unsigned char datdat;
datdat = dat;
cnt=0;
PORTC &= 0b11111101;
delayUS(baud);
nextstep:
if (datdat&1){PORTC |= 0b00000010; }else{PORTC &= 0b11111101;}
delayUS(baud);
datdat = datdat>>1;
if (cnt<8){cnt++;goto nextstep;}
dummy |= 0b00000010;
PORTC = dummy;
delayUS(baud); delayUS(baud); delayUS(baud); delayUS(baud); delayUS(baud);
delayUS(baud); delayUS(baud); delayUS(baud); delayUS(baud); delayUS(baud);
// eeprom_write(1, ((baud>>8)));
// eeprom_write(2, (baud)&0xFF);
delayMS(100);
// }
}
My attempt with this post was to do things proper programmatically without so much guess work,
first: #define _XTAL_FREQ 8000000
2)setup osccon
2.5)postscaler = 1:1
3)put pulse on scope and configure osctune
4) missing things i "didnt know"/"forgot" about?
5)now __delay_us(10) acutally is 10us delay!
I am surprised(a little) with the responses about glitchy compilers, not so much about how i am stalling the clock, I see now why we like asm so much.. good sample codes @
Nigel's , I am almost able to see how the calls work...
but i need more fundimental understanding and thats where it hit me, top line of data sheet says only 35WORDS to learn... could these be asm words? table of contents... yup! chapter 12: Instruction table, of course~!
so her is my first attempt to add:
ADDWF f,d
... scratch that, going by a snipit here:
movlw 0xff // move literal to register w,
movwf PORTA // move register w to porta
movwf PORTB
... so a literal is a hard value?
I can see if f & W are registers i want to work with but what is b or d...output value?
.... maybe it may help if there is explanation somewhere to explain how/what i am working with here in terms of under the hood, registers and how it works as oppose to what each instruction does?
ie. do i move in valA to reg1, valB to reg2, reg3=output after operation? I assume with asm it means single step operations..?