PIC12F675 problem with port 5


Closed Thread
Results 1 to 3 of 3
  1. #1

    Default PIC12F675 problem with port 5

    I have teh following problem:

    PIC12F675 on GPIO 5 I have a buzzer that runs on 5V 11mA.
    When I connect it to the Microcontroller and High GPIO5 the Buzzer won't give a the right sound. It makes a little sound. When i connect it directly to the 5 Volt it give the right sound.

    It looks like the PIC can't drive the current thats needed. When I take a look at the datasheet it says GPIO can drive 25mA.

    This is the code I use

    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT ; System Clock Options
    @ DEVICE pic12F675, WDT_ON ; Watchdog Timer
    @ DEVICE pic12F675, PWRT_ON ; Power-On Timer
    @ DEVICE pic12F675, MCLR_OFF ; Master Clear Options (Internal)
    @ DEVICE pic12F675, BOD_ON ; Brown-Out Detect
    @ DEVICE pic12F675, CPD_OFF ; Data Memory Code Protect
    @ DEVICE pic12F675, PROTECT_OFF

    cmcon = 7 ' Comparator OFF

    TRISIO = %00000 ' Set all I/O's to outputs

    Buzzer VAR GPIO.5 'Lade schakelaar

    Buzzer = 1

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    ansel = 0 !!

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I hope that's NOT the code you are using!!!!

    What does the PIC do AFTER it executes Buzzer=1 ?

    You must NEVER have the processor just run off the end of your program, because what it does thereafter is unpredictable.

    If you're just testing your Buzzer, do something like...

    Code:
    Loop:
    	Buzzer=1
    	Pause 1000
    	Buzzer=0
    	Pause 1000
    	Goto Loop
    	
    	End
    Never just end your program... because there is no guarantee that the last thing you told your program to do is the last thing that happens. There's all kind of free and available memory locations in Program Codespace that could be executed that you don't know about. There's no guarantee that your unused memory is blank, or that your programmer erased it. So be safe and always terminate your program in some kind of loop... even if its just...

    Code:
    Loop:
    	Buzzer=1
    	Goto Loop
    	
    	End
    Oh, and I don't think ANSEL affects GPIO.5.

    Finally, if your Buzzer still doesn't work after the above, you might need a driver Transistor if the current requirement is too high. Beware, some Buzzers are kinda nasty, and produce a back-emf which could kill a PIC's I/O.

Similar Threads

  1. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  2. problem with my code
    By civicgundam in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd February 2008, 01:52
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. PWM problem CCP2 port
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 19th September 2006, 23:34
  5. Replies: 11
    Last Post: - 13th July 2005, 19:26

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts