Interrupt Sample code for C167CS

Hi all,

I am learning microprocessor programming.
I need some sample code for interrupt routine for C167CS.
It should be as simple as e.g. every second print time on display.

Thanks for help
regards
/M

Parents
  • I hope there is no mistakes here:

    #include <reg167.h>  // definitions of SFRs
    #include <intrins.h> // declarations of intrinsic routines like _bfld_()
    
    unsigned long seconds = 0;
    
    void OnTimer0(void) interrupt 0x20 using TIMER0_RB
    {
      static char buffer[32];
      seconds++;
      sprintf(buffer, "Seconds running: #lu", seconds);
      MyWriteToDisplayRoutine(buffer); // this function should display strings
        // write it yourself
    }
    
    void main(void)
    {
      T0REL = 0xA0A2;                 // configure Timer0 to trigger
      _bfld_(T01CON, 0x00FF, 0x0047); // interrupt every second at 25MHz CPU clock
      T0IC = 0x0044; // the Timer0 iterrupt will have level 1, group level 0
      IEN = 1; // enable interrupts
      for (;;) _idle_(); // IDLE in the endless loop to save some power :-)
    }
    

Reply
  • I hope there is no mistakes here:

    #include <reg167.h>  // definitions of SFRs
    #include <intrins.h> // declarations of intrinsic routines like _bfld_()
    
    unsigned long seconds = 0;
    
    void OnTimer0(void) interrupt 0x20 using TIMER0_RB
    {
      static char buffer[32];
      seconds++;
      sprintf(buffer, "Seconds running: #lu", seconds);
      MyWriteToDisplayRoutine(buffer); // this function should display strings
        // write it yourself
    }
    
    void main(void)
    {
      T0REL = 0xA0A2;                 // configure Timer0 to trigger
      _bfld_(T01CON, 0x00FF, 0x0047); // interrupt every second at 25MHz CPU clock
      T0IC = 0x0044; // the Timer0 iterrupt will have level 1, group level 0
      IEN = 1; // enable interrupts
      for (;;) _idle_(); // IDLE in the endless loop to save some power :-)
    }
    

Children
More questions in this forum