How to send the result of a count from the register TMR1 (used as counter in the PIC 16f877A) to sevral output pins on the same pic?
The AD667 needs a SIPO register IC to interface from a serial bit banger on PIC but....

 this ADC costs $32.

mouser
However a serial 12 bit DAC from Microchip

 MCP4921 only costs $3.16

So you use three I/O pins to send out serial data to the DAC : SCK, CS, SDI from PIC using say RB1, RB0, SDO.


The LDAC (latch DAC synchronization input) pin is used to transfer the input latch register to the DAC register (output latch, VOUT). When this pin is low, VOUT is updated with input register content. Hence we tie this pin to low (VSS) so that VOUT is updated at the rising edge of the CS pin.  
VREF is the voltage reference input for MCP4921. This pin is  tied to VDD so that the input voltage will range from VSS(ground) to VDD(5V).   
Connect a high value register to VOUT of MCP4921 so that the current requirements are low.

#include&lt;p18f4550.h&gt;
#pragma config FOSC = HS   //High Speed Crystal Oscillator
#pragma config WDT=OFF     //Watch Dog Timer disabled
#pragma config LVP=OFF     //Single-Supply ICSP disabled
#pragma config MCLRE = OFF //RE3 input pin enabled; MCLR pin disabled.  
 //So now we dont need to give High Logic on this pin to keep the PIC functioning
#define  cs PORTBbits.RB0  
void dac(unsigned int);
 void delay(unsigned int time);

void main()
{
 int i;
 TRISB=0;      // PORTB is configured as an output port
 TRISC=0;      // PORTC is configured as an output port
 PORTC=0;
 PORTB=0;

 SSPSTAT=0xC0; //Status Register SSPSTAT=11000000
 SSPCON1=0x20; //Enables serial port pins &amp; set the SPI clock as clock = FOSC/4
 while(1)
   {
    dac(255);  delay(1000);
    dac(127);  delay(1000);
    dac(63);   delay(1000);
   }
}

 void dac(unsigned int data)
 {
 unsigned int c ;
 unsigned int lower_bits;
 unsigned int upper_bits; 
 c = ((data+1)*16) -1; // here we obtain 12 bit data
                       //first obtain the upper 8 bits
 upper_bits = c/256;   // obtain the upper 4 bits
 upper_bits = (48) | upper_bits; // append 0011 to the above 4 bits

                       //now obtain the lower 8 bits
 lower_bits = 255 &amp; c; // ANDing separates the lower 8 bits

 cs=0;
 SSPBUF=upper_bits;    // sending the upper 8 bits serially    
 while(!SSPSTATbits.BF);  // wait until the upper 8 bits are sent
 SSPBUF=lower_bits;       // sending the lower 8 bits serially  
 while(!SSPSTATbits.BF);  // wait until the lower 8 bits are sent
 cs=1;
}

  void delay(unsigned int time)
{
  unsigned int i,j;
  for(i=0;i&lt;time;i++)
  for(j=0;j&lt;120;j++);
}