This isn't exactly the best place for questions on the C18 compiler, but,
since I dabble with this myself, and it's a freebie, here's a quick example;
Assumes 20MHz osc. Give 1S pulses on RD0/RD1.
#include p18f452.h
#include timers.h
Code:
#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config LVP = OFF
unsigned int Loops = 0;
void Timer1(unsigned int val)
{
PIR1bits.TMR1IF = 0;
WriteTimer1(val);
while(!PIR1bits.TMR1IF)
PIR1bits.TMR1IF=0;
Loops += 1;
}
void main(void)
{
LATD = 0x00;
TRISD = 0x00;
T1CON = 0b10110101;
WDTCON = 0;
while(1)
{
LATD = 0x01;
while(Loops<10)
{
Timer1(0x0bdc);
}
LATD = 0x08;
while(Loops<20)
{
Timer1(0x0bdc);
}
Loops = 0;
}
}
I'll let you figure out how & why it works with the 18F datasheet & C18
manuals.
Microchip's forum http://forum.microchip.com/tt.asp?forumid=3 would be
your best bet for getting quick answers on this compiler.
Bookmarks