I have configured RA0 and RA1 in PIC16F676 as output. They work well when used individually.
When both are set/Cleared one after other, they doesn't work. If one pin is turned on, other is turned off by it self(This is not required). While same code works well on other pins in PORTA! I am using high band gap, and turned off MCLRE, WDT, BODEN,PWRTE and using internal RC oscillator with OSCCAL=0x34FC (Max Freq).
As Brian mentioned, the issue could be excessive current sourced from RA0 and RA1, or excessive current sourced from PORTA and PORTC combined, which have a source limit of 25mA and 200mA respectfully.
Reference: PIC16F630/676 Datasheet, Section: 12.0 ELECTRICAL SPECIFICATIONS, pg 85
12.0 ELECTRICAL SPECIFICATIONS
Absolute Maximum Ratings†
Ambient temperature under bias.......................................................................................................... -40 to +125°C
Storage temperature ....................................................................................................................... -65°C to +150°C
Voltage on VDD with respect to VSS .................................................................................................. -0.3 to +6.5V
Voltage on MCLR with respect to Vss .................................................................................................. -0.3 to +13.5V
Voltage on all other pins with respect to VSS ....................................................................................... -0.3V to (VDD + 0.3V)
Total power dissipation(1) ................................................................................................................. 800 mW
Maximum current out of VSS pin ......................................................................................................... 300 mA
Maximum current into VDD pin ............................................................................................................ 250 mA
Input clamp current, IIK (VI < 0 or VI > VDD)......................................................................................... 20 mA
Output clamp current, IOK (Vo < 0 or Vo >VDD)...................................................................................... 20 mA
Maximum output current sunk by any I/O pin.......................................................................................... 25 mA
Maximum output current sourced by any I/O pin ..................................................................................... 25 mA
Maximum current sunk by PORTA and PORTC (combined) .......................................................................... 200 mA
Maximum current sourced PORTA and PORTC (combined) .......................................................................... 200 mA
Can you post the datasheet of both the BLOW and BUZZER devices?
Also as Brian mentioned if the devices are inductive or highly capacitive, an alternative method of driving them maybe required.
After reviewing your code it appears the analog comparator module has not been disable which is required for Digital I/O on pins RA<2:0>.
There is a misprint in the datasheet's example, so refer to the errata.
Reference: PIC16F630/676 Rev. A Silicon/Data Sheet Errata, Section: 5. Module: PORTA: Initializing Example, pg 6
5. Module: PORTA: Initializing Example
Change Example 3-1: Initializing PORTA to the following (bold text):
EXAMPLE 3-1: INITIALIZING PORTA
BCF STATUS,RP0 ;Bank 0
CLRF PORTA ;Init PORTA
MOVLW 07h ;Set RA<2:0> to
MOVWF CMCON ;digital I/O
BSF STATUS,RP0 ;Bank 1
CLRF ANSEL ;digital I/O
MOVLW 0Ch ;Set RA<3:2> as inputs
MOVWF TRISA ;and set RA<5:4,1:0>
;as outputs
BCF STATUS,RP0 ;Bank 0
I would recommend trying the following code:
Code:
#define BUZZER PORTA.F1
#define BLOW PORTA.F0
void main ()
{
CMCON=0x07;
ANSEL=0x00;
TRISA.F0=0;
TRISA.F1=0;
while(1){
BLOW=0;
Delay_ms(500);
BUZZER=0;
Delay_ms(500);
BUZZER=1;
Delay_ms(1000);
BLOW=1;
Delay_ms(1000);
}/*while*/
}/*main*/
Also make sure you enter the correct system clock frequency generated by the internal oscillator into the "Project Settings" of MikroC. Without the proper system clock frequency, the generated delays from Delay_ms() routine will be incorrect.
BigDog