Don't know what's wrong!


Closed Thread
Results 1 to 18 of 18
  1. #1
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73

    Question Don't know what's wrong!

    Hi all,

    Being a total greenhorn around microcontrollers and all that belongs to them I would appreciate a little help.
    Problem: I don’t know where it goes wrong when I try to make my own hex file. I can put some readymade hex code into my 16F628A and get it to work, no problem. But a compiled hex file (PBP) made in MicroCode Studio Plus will not run in my 628A.
    Can someone please point me in the right direction?

    Thanks!

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Just a guess...

    Make sure your configuration fuses are set properly. Especially the oscillator type.
    Charles Linquist

  3. #3
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73


    Did you find this post helpful? Yes | No

    Default

    Hi Charles,

    Thanks for the suggestion but as I mentioned I am green and “configuration fuses” don’t say much to me! Sorry, can you try to explain what they are and where to set them…. I warned you I am a rookie! :-)

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,817


    Did you find this post helpful? Yes | No

    Default

    As always a program you wrote and a sample schematic are needed to help you.

    Ioannis

  5. #5
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73


    Did you find this post helpful? Yes | No

    Default

    Hi Ioannis,

    Well the program is an example provided with the software compiled for 628A (I believe):

    loop:
    High 0 ' Turn on LED connected to PORTB.0
    Pause 500 ' Delay for .5 seconds

    Low 0 ' Turn off LED connected to PORTB.0
    Pause 500 ' Delay for .5 seconds

    Goto loop ' Go back to loop and blink LED forever
    End


    And the schematic is simple and the circuit works fine with “readymade” code so I guess its ok.

    Thanks.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by PICante View Post
    Hi Ioannis,
    Well the program is an example provided with the software compiled for 628A (I believe):
    loop:
    High 0 ' Turn on LED connected to PORTB.0
    Pause 500 ' Delay for .5 seconds
    Low 0 ' Turn off LED connected to PORTB.0
    Pause 500 ' Delay for .5 seconds
    Goto loop ' Go back to loop and blink LED forever
    End
    And the schematic is simple and the circuit works fine with “readymade” code so I guess its ok.
    Thanks.
    So that's the code that works. Can't help you with that...'cause...well...it works...

    Post the code that doesn't work... Make sure it's compiling for the correct PIC, make double sure you're not compiling for, say, the 16F628, when you're actually programming a 16F628A, or something like that.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73


    Did you find this post helpful? Yes | No

    Default

    Hi skimask,

    No, that’s the code I try to get to work!
    I compile it in MCS (no fault messages) for 628A which is the one I got but it does not run. The code I run successfully is a hex code which I can’t change nor se how it is made “inside”.
    I run my 628A on its internal oscillator in both cases.

    Thanks!

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    If you have not changed the 16F628A.inc then I bet it is trying to use the XT OSC.
    Look at the link I sent before and the data sheet for the correct setting when using the internal OSC.

    It will be something like INTOSC instead of XT.
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,

    How does the compiler pick up the *.inc file and where is it originally placed. In assembler there is an “Include” command but in PBP there are not as far as I have seen.
    I will have a look at the PIC datasheet and the link you supplied, thanks!

  11. #11
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    The *.inc is in you PBP directory.
    When you compile with Pic Basic it will automatically look there. Or you can do it in your code.
    The link tells how.

    Look at the ASM file made after you compile and you will see the includes.
    Dave
    Always wear safety glasses while programming.

  12. #12
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,817


    Did you find this post helpful? Yes | No

    Default

    If this is all the code and you are trying to run it on a 628A device, I bet it will never do anything!

    Since in a reply or more replies it is impossible to teach you what all these fuses and configurations are, you have to do your homework too.

    1. Get a data sheet of the device (in this case 16F628A from microchip)

    2. Read it thouroughly as it has many systems and subsystems that all are multiplexed with the 16 pins of the device.

    3. Also study the PBP manual.

    Then you may start blinking a LED!

    Are you sure thet you are running the chip on the internal osc? How did you set it to? Have you set the MCLR pin at the appropriate level (HIGH) or did you disabled from the config fuses or more from within the programmer?

    By the way, what is your programmer?

    Ioannis

  13. #13
    Join Date
    Oct 2007
    Location
    Vancouver, BC, Canada
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    Code:
    loop:
    high portb.0
    pause 500
    low portb.0
    pause 500
    goto loop
    try that.
    ________________
    KV

  14. #14
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by PICante View Post
    Hi skimask,

    No, that’s the code I try to get to work!
    I compile it in MCS (no fault messages) for 628A which is the one I got but it does not run. The code I run successfully is a hex code which I can’t change nor se how it is made “inside”.
    I run my 628A on its internal oscillator in both cases.

    Thanks!
    Ohhh...ok...I get ya now...
    Make sure your MCLR is pulled high regardless of the config bit settings and try it again, except instead of waiting a second for the LED to blink, wait for about 2 minutes.

    If it blinks in 2 minutes instead of once per second, the PIC is running on the low speed internal oscillator (32khz - 48khz depending on which datasheet for the 628A you look at) instead of the high speed internal oscillator (4mhz nominal).

    If that's the case, then, as stated before by others, do a bit of searchin' and learn how to play with config's and fuse settings.

  15. #15
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hello PICante,
    The 628A has analog comparator inputs, so unless you are using them turn them off with
    CMCON = 7
    then read the post on config fuses
    try:
    Code:
    @ DEVICE pic16F628A, HS_OSC ' Change HS to XT for 4mhz
    
    @ DEVICE pic16F628A, WDT_ON
    ' Watchdog Timer
    
    @ DEVICE pic16F628A, PWRT_ON
    ' Power-On Timer
    
    @ DEVICE pic16F628A, MCLR_ON 
    ' Master Clear Options (Internal)
    
    @ DEVICE pic16F628A, BOD_OFF
    ' Brown-Out Detect
    
    @ DEVICE pic16F628A, LVP_OFF
    ' Low-Voltage Programming
    
    @ DEVICE pic16F628A, CPD_OFF
    ' Data Memory Code Protect
    ' Set to CPD_OFF for Development Copy
    ' Set to CPD_ON for Release Copy
    
    @ DEVICE pic16F628A, PROTECT_OFF
    
    DEFINE OSC 20 ' for 20 mhz, change to fit your OSC speed
    that code should setup your configs if using the default compiler, MAPSM uses different configs.

    Welcome back skimask
    Last edited by Archangel; - 19th December 2007 at 21:15.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  16. #16
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Hello PICante,
    The 628A has analog comparator inputs, so unless you are using them turn them off with
    CMCON = 7
    But not on PortB.0...(that was my first thought too).
    Everything else still applies in full...if not more...

  17. #17
    Join Date
    Dec 2007
    Location
    Sweden
    Posts
    73


    Did you find this post helpful? Yes | No

    Cool

    Thanks all of you!

    I have some reading to do (obviously) and I get back on this matter if I don’t figure it out myself!
    One 180 page datasheet and then some … phuuuu.

    Thanks again :-)

    Merry Christmas!

  18. #18
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Stop whining

    I am looking at the data sheet for the 18F4550 over the holiday.

    428 pages!

    Merry Christmas to you too.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. LCD Showes Some Wrong Letters
    By sbobowski in forum General
    Replies: 2
    Last Post: - 23rd September 2008, 19:15
  2. Anyone know whats wrong with this code
    By Bonxy in forum Serial
    Replies: 10
    Last Post: - 9th March 2007, 16:29
  3. ADCIN - AD settings are wrong
    By teverett in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th December 2006, 16:32
  4. What am I doing wrong?
    By mankan in forum General
    Replies: 1
    Last Post: - 23rd June 2006, 19:03
  5. HDD IDE ATA 2 interface problems. code wrong?
    By rastan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th March 2005, 16:01

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