Hot!I am new and need help!!!

Page: 12345 > Showing page 1 of 5
Author
Gordon2005
Starting Member
  • Total Posts : 37
  • Reward points : 0
  • Joined: 2018/08/03 13:42:49
  • Location: 0
  • Status: offline
2018/08/03 14:08:59 (permalink)
0

I am new and need help!!!

i am programming a pic16f54 and i was able to program it, but nothing happens can someone please help me. here is the code it is just to turn on an led on RB0.
 
#include <stdio.h>
#include <stdlib.h>
#include "test.h"
void main(void) {
TRISB = 0b000000;
while (1){

PORTB = 0b100000;

}
}
 
#1

94 Replies Related Threads

    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 14:11:22 (permalink)
    +2 (2)
    Really, that old PIC?
     
    Anyway, for RB0 you possibly need
    PORTB = 0b000001;
     
    (I usually suggest toggling...)

    GENOVA :D :D ! GODO
    #2
    NKurzman
    A Guy on the Net
    • Total Posts : 16572
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: I am new and need help!!! 2018/08/03 14:44:48 (permalink)
    +1 (1)
    Where are your configuration settings?
    Programmed with what?
    I assume that chip needs an oscillator. does it have one?
    #3
    Gordon2005
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2018/08/03 13:42:49
    • Location: 0
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 14:55:12 (permalink)
    +1 (1)
    i program using mplab ipe and pickit 3, it does have an oscillator and here are the configuration settings.
     
    #pragma config OSC = RC // Oscillator selection bits (RC oscillator)
    #pragma config WDT = OFF // Watchdog timer enable bit (WDT disabled)
    #pragma config CP = OFF // Code protection bit (Code protection off)
    #4
    jtemples
    Super Member
    • Total Posts : 11006
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 15:01:44 (permalink)
    +2 (2)
    #pragma config OSC = RC // Oscillator selection bits (RC oscillator)

     
    And you have an RC oscillator connected to the PIC?
    #5
    qɥb
    Monolothic Member
    • Total Posts : 3329
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 15:09:52 (permalink)
    +2 (2)
    Gordon2005
    #pragma config OSC = RC // Oscillator selection bits (RC oscillator)

    This oscillator selection requires some external components to be connected (A resistor and a capacitor).
    Do you have them?
    Do you have to use that ancient PIC? Newer ones are cheaper, faster, and will come with internal oscillators.

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #6
    Gordon2005
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2018/08/03 13:42:49
    • Location: 0
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 15:40:15 (permalink)
    0
    i am not sure which oscillator setting i select in configuration bits. i know i have a 16MHz crystal oscillator and two capacitors and looks like this.
     

    can some one tell me what oscillator setting i should select RC, HS, XT or LP oscillator.
     
     
    #7
    Gordon2005
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2018/08/03 13:42:49
    • Location: 0
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 15:45:20 (permalink)
    +2 (2)
    also sorry about the old pic i didn't know it was old until now.
    #8
    qɥb
    Monolothic Member
    • Total Posts : 3329
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 15:47:08 (permalink)
    +2 (2)
    For that arrangement, use the "HS" setting.
    XT mode is only good up to 4MHz.

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #9
    qɥb
    Monolothic Member
    • Total Posts : 3329
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 15:51:35 (permalink)
    +2 (2)
    Gordon2005
    also sorry about the old pic i didn't know it was old until now.

    Note, the datasheet for your PIC is your best friend.
    The copyright notice at the bottom of every page in the PIC16F54 datasheet is "©2007" so that chip has been around for more than 11 years.
    Any PIC16F chip with a "1" after the "F" will be much more powerful.
    The simpler ones will have a number of the form PIC16F1xxx.
     
     

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #10
    Gordon2005
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2018/08/03 13:42:49
    • Location: 0
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 15:51:57 (permalink)
    0
    I changed it to HS but it is still not working though. nothing happens
    #11
    qɥb
    Monolothic Member
    • Total Posts : 3329
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 15:55:02 (permalink)
    +2 (2)
    Do you have a pullup on the MCLR pin?
     
    How exactly are you checking if it is working?
    post edited by qɥb - 2018/08/03 15:59:16

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #12
    Gordon2005
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2018/08/03 13:42:49
    • Location: 0
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 16:06:29 (permalink)
    0
    i don't have a pullup on the MCLR pin and can you explain what that is. also i check to see if it works by erasing the pic then programing it. and if the light doesn't go on it didn't work.
    #13
    qɥb
    Monolothic Member
    • Total Posts : 3329
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 16:55:24 (permalink)
    +2 (2)
    A "pullup" is a resistor connected to the positive supply.
    Your PIC won't run if the MCLR pin is not pulled high.
    How exactly is the LED connected?
    i.e. do you have a series resistor?
    Is the other end connected to ground, or to your positive supply?
    Did you change your code. You say you connected it to RB0, but your code is setting RB5 high (as Dario already pointed out)

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #14
    Gordon2005
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2018/08/03 13:42:49
    • Location: 0
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 17:27:58 (permalink)
    0
    the led is connected between RB0 and ground and yes, i changed the code.
    what kind of series resistor do i need . I have a few resistors
    #15
    mbrowning
    Just a Member
    • Total Posts : 1128
    • Reward points : 0
    • Joined: 2005/03/16 14:32:56
    • Location: Melbourne, FL
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 18:02:31 (permalink)
    +2 (2)
    You need to limit current thru the led. The led has a forward drop, check it’s datasheet but common ones are about 2v. For 5v supply, 5mA current, and 2v led, the resistor would be (5 - 2)/.005 = 600ohm (edit due to brain fart) MCLR pull-up should be from 10K to 47K I think.

    Also polarity of the led matters. If between RB0 and gnd, the anode toward RB0 and Cathode ( where the polarity mark is) to gnd. The resistor can be either end of the led, it doesn’t matter
    post edited by mbrowning - 2018/08/04 04:14:38

    Go Navy! Beat Army!
    #16
    Gordon2005
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2018/08/03 13:42:49
    • Location: 0
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 18:26:43 (permalink)
    0
    i have the pull up resistor but i don't have the one for the LED. I will tell you when i get them
    #17
    NKurzman
    A Guy on the Net
    • Total Posts : 16572
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: I am new and need help!!! 2018/08/03 20:43:43 (permalink)
    +1 (1)
    (5 - 2)/.005 = 600ohms 
     
    What do you have around 270 to 680 ohms.  It is not that critical.
    two 1K in parallel is 500 ohms.
    #18
    1and0
    Access is Denied
    • Total Posts : 8462
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 21:12:39 (permalink)
    +2 (2)
    • Pull-up resistor of 10K to 47K ohm on the /MCLR pin.
    • 0.1 uF ceramic capacitor across Vdd and Vss of the PIC chip.
    • Current limiting resistor of 470 to 1K ohm in series with the LED.
    • 10 pF to 22 pF capacitors for the 16 MHz crystal.
    #19
    David
    Pic User
    • Total Posts : 1286
    • Reward points : 0
    • Joined: 2007/12/17 23:19:53
    • Location: uk sussex
    • Status: offline
    Re: I am new and need help!!! 2018/08/03 21:36:48 (permalink)
    +3 (3)
    Gordon2005
    the led is connected between RB0 and ground 



    what pin number do you think is RB0 ?
     
    http://ww1.microchip.com/...n/DeviceDoc/41213D.pdf
    post edited by David - 2018/08/03 21:40:51

    David
    I support http://picforum.ric323.com because this forum is often too broken to use!
    #20
    Page: 12345 > Showing page 1 of 5
    Jump to:
    © 2018 APG vNext Commercial Version 4.5