anilson1
New Member
hi,
I am trying to build a simple project which I use a "PIC16F88" communicating through (SPI) with a digital potentiometer DS1267-10 to control the oscillation of a timer 555
Here is the code:
The problem is: the oscillator only oscillates at one frequency, by pressing the buttons it does not chance the oscillation speed. Not sure if the problem is on the circuit or on the code. Any idea?
I am trying to build a simple project which I use a "PIC16F88" communicating through (SPI) with a digital potentiometer DS1267-10 to control the oscillation of a timer 555
Here is the code:
C:
unsigned char bou[9];
void sendDATA()
{
unsigned char counter = 0; //Declare and initialize the counter
RB3_bit = 1; //Initiate communication through RST
Delay_us(50);
while(counter<9)
{
if(RB4_bit == 0)
{
counter = counter + 1; //counting pulse on the low
RB2_bit = bou[counter]; //Send Data
Delay_us(30);
}
RB4_bit = ~ RB4_bit; //toggle the clock
Delay_us(50); //Duty cycle
}
RB4_bit = 0;
RB3_bit = 0; //Stop communication through RST
}
void main(){
ANSEL = 0; // pins are configured as digital I/O
TRISA = 0xFF; // set PORTA direction to be input
TRISB = 0x00; // set PORTB direction to be output
PORTB = 0;
do{
if(RA2_bit == 0)
{
bou[0]=1;
bou[1]=1;
bou[2]=1;
bou[3]=0;
bou[4]=1;
bou[5]=0;
bou[6]=1;
bou[7]=1;
bou[8]=0;
sendDATA();
}
if(RA3_bit == 0)
{
bou[0]=0;
bou[1]=0;
bou[2]=1;
bou[3]=0;
bou[4]=0;
bou[5]=1;
bou[6]=0;
bou[7]=0;
bou[8]=0;
sendDATA();
}
}while(1);
}
The problem is: the oscillator only oscillates at one frequency, by pressing the buttons it does not chance the oscillation speed. Not sure if the problem is on the circuit or on the code. Any idea?
Attachments
Last edited by a moderator: