.: EMICROS :.  Embedded Micro Software
Home CAN232 CANUSB I2C232 I2CUSB CanWiser Learn C
Add your text here
Contact

Email : info@emicros.com

Ordering Information

.: Ordering using our PayPal powered shopping cart (PayPal account not required).

CAN232 : $79
CANUSB : $89
I2C232 : $79

I2CUSB : $89

Click here to View Cart and check out.

 

 

 

 

The blinkled program uses the _delay() function which only delays the number of instruction cycles passed to it as a parameter. An instruction cycle is the amount of time, or number or clock cycles, needed by the PIC to execute an instruction. The PIC needs 4 oscillator cycles to perform 1 instruction cycle and most instructions take 1 instruction cycle to execute. So the _delay() function just executes one of the shortest instructions a number of times. The NOP instruction which doesn't do anything is usually used.

_delay( 10 ); /* This example delays 10 instruction cycles */

_delay( 50 ); /* This example delays 50 instruction cycles */

_delay( 10000 ); /* This example delays 10000 instruction cycles */

The PicWiser uses a 14.7456 Mhz (mega-hertz) crystal which results in an instruction cycle time of 4 / 14,754,600 or 271.3 nanoseconds (nsec). Delay functions that are based on this won't be exact but will be close enough and easy to deal with.

The first basic delay function will be 5 microseconds. Since we only have multiples of .271 microseconds to deal with we will get close to 5 microseconds by executing 18 instruction cycles or 18 * .271 = 4.88 microseconds. We could set this up as a function but instead lets define it as a series of inline instruction.

 

 

 
 
Copyright 2010 Embedded Micro Software. All rights reserved