This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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
  • There is an example called hello in the \keil\c166\examples\hello folder. This example appears as follows:

    #include <stdio.h>                /* standard I/O .h-file              */
    #include <reg167.h>               /* special function register 80C167  */
    
    /****************/
    /* main program */
    /****************/
    void main (void)  {               /* execution starts here               */
                                      /* initialize the serial interface     */
    #ifndef MCB167          /* do not initialize if you use Monitor-166      */  
      P3  |= 0x0400;        /* SET PORT 3.10 OUTPUT LATCH (TXD)              */
      DP3 |= 0x0400;        /* SET PORT 3.10 DIRECTION CONTROL (TXD OUTPUT)  */
      DP3 &= 0xF7FF;        /* RESET PORT 3.11 DIRECTION CONTROL (RXD INPUT) */
      S0TIC = 0x80;         /* SET TRANSMIT INTERRUPT FLAG                   */
      S0RIC = 0x00;         /* DELETE RECEIVE INTERRUPT FLAG                 */
      S0BG  = 0x40;         /* SET BAUDRATE TO 9600 BAUD                     */
      S0CON = 0x8011;       /* SET SERIAL MODE                               */
    #endif
    
      printf ("Hello World\n");  /* the 'printf' function call               */
      while (1) {                /* An embedded program does not stop and    */
        ;  /* ... */             /* never returns.  We've used an endless    */
      }                          /* loop.  You may wish to put in your own   */
    }                            /* code were we've printed the dots (...).  */

    Note that the initialization for the serial port is required when MON166 is not used.

    Jon

Reply
  • There is an example called hello in the \keil\c166\examples\hello folder. This example appears as follows:

    #include <stdio.h>                /* standard I/O .h-file              */
    #include <reg167.h>               /* special function register 80C167  */
    
    /****************/
    /* main program */
    /****************/
    void main (void)  {               /* execution starts here               */
                                      /* initialize the serial interface     */
    #ifndef MCB167          /* do not initialize if you use Monitor-166      */  
      P3  |= 0x0400;        /* SET PORT 3.10 OUTPUT LATCH (TXD)              */
      DP3 |= 0x0400;        /* SET PORT 3.10 DIRECTION CONTROL (TXD OUTPUT)  */
      DP3 &= 0xF7FF;        /* RESET PORT 3.11 DIRECTION CONTROL (RXD INPUT) */
      S0TIC = 0x80;         /* SET TRANSMIT INTERRUPT FLAG                   */
      S0RIC = 0x00;         /* DELETE RECEIVE INTERRUPT FLAG                 */
      S0BG  = 0x40;         /* SET BAUDRATE TO 9600 BAUD                     */
      S0CON = 0x8011;       /* SET SERIAL MODE                               */
    #endif
    
      printf ("Hello World\n");  /* the 'printf' function call               */
      while (1) {                /* An embedded program does not stop and    */
        ;  /* ... */             /* never returns.  We've used an endless    */
      }                          /* loop.  You may wish to put in your own   */
    }                            /* code were we've printed the dots (...).  */

    Note that the initialization for the serial port is required when MON166 is not used.

    Jon

Children
No data