PDA

View Full Version : Help with code



xobx
- 12th July 2007, 14:22
Hi this is my current code (all)
I use MicroCode Studio Plus with PICBASIC PRO compiler.


loop: high portb.1
pause 500
low portb.1
pause 500
goto loop
end

And when I transfer it to my PIC16F648A, my led connected to RB1 doesnt blink (the led is working)

Its connected like this:
http://img503.imageshack.us/img503/3551/mittsetupiw8.jpg


Someone told me that I might be something with CONFIG Bits but he couldnt help me casue he use assembler..

Versions:
http://img249.imageshack.us/img249/1408/versiontz0.jpg

Programmer is Wisp628+xwisp2161

Config fuses, no idea..

skimask
- 12th July 2007, 14:37
http://www.picbasic.co.uk/forum/showpost.php?p=36169&postcount=6

xobx
- 12th July 2007, 14:56
Is this better?

skimask
- 12th July 2007, 14:59
Is this better?

A bit...
Still don't know which version of PBP, MCS+, or MPLAB you are using...
Don't know which programmer and/or version of software/firmware...
Don't know which config fuses are set (or at least you THINK are set)...

xobx
- 12th July 2007, 15:14
Now then..

And any help would be appreciate..

skimask
- 12th July 2007, 15:18
Now then..
And any help would be appreciate..

Ok, that's a fair bit better yet...
Now then...What does the PBP manual say about oscillator selections?
Also, do a readback of your 'config word' and match it up with the datasheet's explanations.
What do you come up with?

xobx
- 12th July 2007, 19:15
Ok, I read some and it seems like the Config is stored in '16F648A.INC', right?

mister_e
- 12th July 2007, 19:16
try


@ __config _HS_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
DEFINE OSC 20

loop: high portb.1
pause 500
low portb.1
pause 500
goto loop
end

Also, read the following thread, at least POST#1 and POST#5
http://www.picbasic.co.uk/forum/showthread.php?t=543

if you're using PM, you will need to use

@ device pic16F648A, hs_osc, wdt_on, mclr_on, lvp_off, protect_off
instead of __CONFIG

xobx
- 12th July 2007, 19:30
This worked!



@ device pic16F648A, hs_osc, wdt_on, mclr_on, lvp_off, protect_off
DEFINE OSC 20

loop: high portb.1
pause 500
low portb.1
pause 500
goto loop
end

Thank you!

xobx
- 12th July 2007, 19:49
OK, I got another problem now..

When I compile my code with http://img526.imageshack.us/img526/349/iconov0.jpg it doesnt update the .hex file so I cant transfer my new program..

Whats wrong?

skimask
- 12th July 2007, 19:55
OK, I got another problem now..

When I compile my code with http://img526.imageshack.us/img526/349/iconov0.jpg it doesnt update the .hex file so I cant transfer my new program..

Whats wrong?

Probably updating the wrong .hex file in the wrong directory...unless it's not fully compiling in the first place (i.e. errors).
Check the date/time on your file, compare it to the current (last compiled) date/time, then go searching for where you file was saved.
If you're talking about the programmer itself...you're on your own there...

xobx
- 12th July 2007, 19:59
Hmm, if I take "save as" and save it to another name and then taking compile again..
I see a new hex file appear with the new name but it still the same as the old code..

:/

skimask
- 12th July 2007, 20:03
Hmm, if I take "save as" and save it to another name and then taking compile again..
I see a new hex file appear with the new name but it still the same as the old code..

:/

Then you aren't changing the source code...

xobx
- 12th July 2007, 20:08
Thats what im doing..

Casue this the source code, right?
http://img529.imageshack.us/img529/6991/coderm3.jpg

skimask
- 12th July 2007, 20:09
Thats what im doing..

Casue this the source code, right?
http://img529.imageshack.us/img529/6991/coderm3.jpg

Yes, but what are you doing to that source code that should cause it to change between compilings?

xobx
- 12th July 2007, 20:14
What?

I first made a easy program that only made RB1 "blink" and I compiled it and transfered it over..

Then I made this code and when I compiled it the hex file still had the old easy program.


@ device pic16F648A, hs_osc, wdt_on, mclr_on, lvp_off, protect_off
DEFINE OSC 20

loop:

high portb.0
pause 250
High portb.1
pause 250
high portb.2
pause 250
low portb.0
pause 250
low portb.1
pause 250
low portb.2
pause 250
goto loop



end


So the Problem is: if I change the source code and compile it doesnt update the hex file.

skimask
- 12th July 2007, 20:16
I first made a easy program that only made RB1 "blink" and I compiled it and transfered it over..
Then I made the code I just posted and when I compiled it the hex file still has the old easy program.
So the Problem is: if I change the source code and compile it doesnt update the hex file.

So, the old hex file and the new hex file are exactly the same size and have exactly the same contents, just a different date/time stamp?
What does the bottom of the screen say when it's done compiling...if anything?

xobx
- 12th July 2007, 20:20
Yes, it exactly same as the old one..

You can see how it changes:
Compiling > Assembling > Success: 82 words used.

skimask
- 12th July 2007, 20:28
Yes, it exactly same as the old one..

You can see how it changes:
Compiling > Assembling > Success: 82 words used.

Ok, so the one file with portb.0/portb.1/portb.2 has 82 words used.
What happens to the same program if you comment out everything under 'loop:' and above 'goto loop', then recompile it?

xobx
- 12th July 2007, 20:29
I just found out that if I change something in this the hex file changes


@ device pic16F648A, hs_osc, wdt_on, mclr_on, lvp_off, protect_off
DEFINE OSC 20

But if I change something in the rest off the code the hex file doesnt change..

:/

xobx
- 12th July 2007, 20:42
I restarted my computer and now does it work :/

Wierd!

skimask
- 12th July 2007, 21:12
I restarted my computer and now does it work :/

Wierd!

Installed a program and didn't do a restart so Windows internal paths didn't get updated...
Glad I could help...not...

xobx
- 12th July 2007, 21:30
What, I restarted the computer after I installed everything!

I didnt install and directly started to use MCS+

skimask
- 12th July 2007, 21:34
What, I restarted the computer after I installed everything!

Apparently not...
Restart it again. Maybe your PIC will program itself with the finished product.

xobx
- 12th July 2007, 21:38
Lets see..

EDIT: ..nope

bill12780
- 12th July 2007, 22:38
I think this is the first time I have seen this kind of behavior here.
(or maybe I am just confussed? Would not be the first time!)

I did not think it existed on this forum. But I guess I was wrong.

You can bet dollars to donuts I will think twice (maybe three times) about my questions!

Good luck xobx. Hope you can figure it out! And PLEASE post what you find so all us Noobs know what happened!

Best,
Bill12780

BobK
- 12th July 2007, 22:43
Hi Xobx,

There's two buttons on MCS. The one you showed here in your conversation with Skimask was the "compile only". The button next to it is "compile and program". If you use the "compile only button, then you manually open your programmer software and load your .hex into the programmer and go from there. If you use "compile and program" then MCS will compile the program AND open your programmer with the current .hex program ready to go. AT least that's how my MCS is working.

HTH,

BobK

skimask
- 13th July 2007, 00:04
I think this is the first time I have seen this kind of behavior here. (or maybe I am just confussed? Would not be the first time!)
I did not think it existed on this forum. But I guess I was wrong.
You can bet dollars to donuts I will think twice (maybe three times) about my questions!
Good luck xobx. Hope you can figure it out! And PLEASE post what you find so all us Noobs know what happened!

Best,
Bill12780

Ask all the questions you want! I'm all over it...BUT...
Sometimes you just have to point out the blatantly obvious to some people, and sometimes people just don't give a person crap to work with...

"My car doesn't run right...What's wrong with it?"
How much information can you get out of that to help out with a fix?