mikroC

making it simple...

Library Example

mikroC - C Compiler for Microchip PIC microcontrollers

The following example continually sends sequence of numbers 0..255 to the PC via Universal Serial Bus.

unsigned short m, k;

unsigned short userRD_buffer[64]; unsigned short userWR_buffer[64];

void interrupt() {

asm CALL _Hid_InterruptProc asm nop

}//~

void Init_Main() {

//Disable all interrupts

//Disable GIE, PEIE, TMR0IE, INT0IE,RBIE INTCON = 0;

INTCON2 = 0xF5; INTCON3 = 0xC0;

//Disable Priority Levels on interrupts RCON.IPEN = 0;

PIE1 = 0; PIE2 = 0; PIR1 = 0; PIR2 = 0;

//Configure all ports with analog function as digital ADCON1 = 0x0F;

//Ports Configuration

TRISA = 0; TRISB = 0; TRISC = 0xFF; TRISD = 0xFF; TRISE = 0x07;

LATA = 0; LATB = 0; LATC = 0; LATD = 0; LATE = 0;

//Clear user RAM

//Banks [00 .. 07] ( 8 x 256 = 2048 Bytes ) asm {

LFSR

FSR0, 0x000

MOVLW

0x08

CLRF

POSTINC0, 0

CPFSEQ

FSR0H, 0

BRA

$ - 2

}

 

 

page

 

MikroElektronika: Development tools - Books - Compilers

277