home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 32 / IOPROG_32.ISO / COMMON / LISTC.ZIP / libxpic.c < prev    next >
Encoding:
Text File  |  1998-02-11  |  692 b   |  43 lines

  1. void aspetta(unsigned int nvol);
  2. void aspettabase();
  3. void timeraspetta(unsigned char np, unsigned char nt); 
  4. void inizializza();
  5.  
  6. void inizializza()
  7. {
  8.   TRISB=0;           /* porta B: tutti i pin come Output */
  9.   PORTB=0;
  10. }
  11.  
  12. void aspettabase()
  13. {
  14.   unsigned int ib;
  15.   for(ib=0;ib!=0xff;ib++);
  16. }
  17.  
  18. void aspetta(unsigned int nvol)
  19. {
  20.   unsigned int i;
  21.   for(i=0;i<nvol;i++)
  22.     aspettabase();
  23. }
  24.  
  25. void timeraspetta(unsigned char np, unsigned char nt)
  26. {
  27.   unsigned char mask;
  28.   mask=OPTION;
  29.   mask=mask&(0xF8);
  30.   np=np&(0x07);
  31.   mask=mask|np;             /* setta il prescaler */
  32.   OPTION=mask;
  33.   TMR0=nt;
  34.   do {
  35.     mask=TMR0;
  36.   }
  37.   while (mask!=0);
  38. }
  39.  
  40.  
  41.  
  42.  
  43.