View previous topic :: View next topic |
Author |
Message |
jtgoulart
Joined: 13 Feb 2007 Posts: 10
|
Executing two tasks at the same time. |
Posted: Tue Mar 20, 2007 2:44 pm |
|
|
I'm using the pic 12f675 to make two diferent oscilatory frequencies. While one is on High, the other is on Low.Unfortunelly there's a little delay between both of them. Is there a way to make these two frequencies flow together? Sorry for my terrible english.... |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Mar 20, 2007 4:22 pm |
|
|
You need to write to the entire i/o port with one instruction.
Change your waveform bits in a byte variable. Then write
the variable to the i/o port. This will cause both edges
of the waveform to change at the same time.
Code: | #include <12F675.h>
#fuses INTRC_IO, NOWDT, NOMCLR, PUT, BROWNOUT
#use delay(clock=4000000)
#use fast_io(A)
//==========================
void main()
{
int8 tempA;
set_tris_a(0xFC); // Pins A0 and A1 are outputs
tempA = 0;
while(1)
{
bit_set(tempA, 0);
bit_clear(tempA, 1);
output_a(tempA);
delay_us(100);
bit_set(tempA, 1);
bit_clear(tempA, 0);
output_a(tempA);
delay_us(100);
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
jtgoulart
Joined: 13 Feb 2007 Posts: 10
|
|
Posted: Tue Mar 20, 2007 6:30 pm |
|
|
OK, I'll try it. Thank you by the help. |
|
![](templates/subSilver/images/spacer.gif) |
|