Tutorial 2 - Argument out of range

Post here to discuss the PIC microcontroller tutorials.

Moderators: Chuckt, Garth, bitfogav

Post Reply
dannymosquito
semi-newbie
semi-newbie
Posts: 10
Joined: Tue Apr 13, 2010 11:50 pm
Location: Australia

Tutorial 2 - Argument out of range

Post by dannymosquito » Mon Jul 26, 2010 12:26 am

Hi Guys... Sorry for being so gung ho and then disappearing :oops: . Firstly it took a while to get all the equipment I needed and a few other issues came up.
Sorry for being such a noob but I am stuck on the second tutorial :? . Before I even hook up the programmer or any of the circuitry I open MPLAB IDE (V8.53) and open the tutorial 2 source code that is supplied. I saved it to "my Docs" and opened the asm file in MPLAB as Brad suggested however when I go to complete a quick build I get the following error:
Error[126] C:\DOCUMENTS AND SETTINGS\USER 1\MY DOCUMENTS\ASM FILES\TUTORIAL_2_LED_FLASHER.ASM 28 : Argument out of range (not a valid config register address)
I am assuming this "__config h'3f18'" sets a few parameters for the chip itself.
When I comment out this line I then successfully compile (not sure what repercussions removing this has) however when I now go to program the chip it states "PKWarn0003: Unexpected device ID: Please verify that a PIC18F452 is correctly installed in the application. (Expected ID = 0x420, ID Read = 0x0)" Does this mean that I haven't hooked the chip up correctly and what exactly is a pic18F452 shouldn't it be looking for a 16f648a?
One other thing for testing purposes is it possible just to wire up the 16f648a chip without the led just to see if I can at least connect and program it. Whats the least you have to hook up to be able to program the chip... Do you need power?
Anyway guys I hope you are all doing well - if you get the chance I could really use the help.
Cheers ... Danny :D
Danny
"Do not go where the path may lead; go instead where the path lead not and leave a trail"

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Post by bitfogav » Mon Jul 26, 2010 1:11 am

Hi Danny :)

It sounds to me like that you have selected the wrong chip in MPLAB, you need to go to the Configure Tab and then Select Device, you need to select 16F628A.. Or a 16F648A depending on which microchip you have..

Also you need the "__config h'3f18'" has this is the correct setups for that chip

When programming the microchip all you need connected is your power, ground, your two data lines and MCLR pin.. so yes for testing you can just connect your programmer to the microchip.. check out the picture below if you need help connecting up the programmer.


any problems just give us a shout!! :)
Gavin


Image

Image
Attachments
pickit2 how.jpg
pickit2 how.jpg (15.96 KiB) Viewed 15180 times
pickit2.jpg
pickit2.jpg (19.91 KiB) Viewed 15186 times

dannymosquito
semi-newbie
semi-newbie
Posts: 10
Joined: Tue Apr 13, 2010 11:50 pm
Location: Australia

Post by dannymosquito » Mon Jul 26, 2010 7:01 am

Hi Gavin....
Thanks heaps for your reply. Mate after going back and properly reading the first tutorial your right I didn't change to the chip I'm using :oops: . Doh... to eager to jump in and get my led flashing :)

Anyway I'm off too Longreach (middle of nowhere) for the week. Will start from scratch when I get back on Friday and let yous know how I fair.

Thanks again Gavin....

Danny :D
Danny
"Do not go where the path may lead; go instead where the path lead not and leave a trail"

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Post by bitfogav » Mon Jul 26, 2010 7:24 am

Haha! thats alright mate, glad I could help :D

Well they say you learn from your mistakes lol..


Have fun in Longreach!!

User avatar
sdudley
Moderator
Moderator
Posts: 337
Joined: Sun Mar 28, 2010 1:33 pm
Location: Florida, U.S.A.

One note about the _config h'3f18'

Post by sdudley » Wed Jul 28, 2010 1:35 am

One note about the _config h'3f18'

Microcontrollers have many different registers to configure the different functions (i.e. STATUS register, OPTION register, INTCON register, and all kinds of crazy registers). These are things you will definitely want to read up on as you progress. Once you understand how to set up one register, it will be much easier to read the data sheet and understand how to set up each register to do what you want (such as your timers and interrupts).

This is what sets microcontrollers apart from microprocessors, in that you can configure them for different individual tasks then go back and change that anytime you want.

So...
The “configuration” register in a PIC deals with the special features such as setting code protection, power up, brown out, low voltage programming, setting the type of oscillator you want to use, etc.

Don't worry about any of this stuff for now but I just wanted to mention this because as you start experimenting more you will want to venture out to new PIC's and will need to know how to configure them.

Page 97 in the PIC16F648A data sheet explains a little about this and page 98 shows the different ways to configure the PIC16F648A.

Look at the following picture and read through page 98 in the PIC16F648A data sheet and hopefully this will help give you a visual understanding about what __config'3f18' does to the CONFIG register.

Image

Each PIC will be configured slightly different so h'3f18' will not work every time. Also, you may want to experiment later with an external oscillator and this will need to change.

I hope this helps a little.

Stacy
Attachments
PIC-configuration.gif
PIC-configuration.gif (14.15 KiB) Viewed 15149 times
Any time you deviate from sequential consistency, you increase the complexity of the problem by orders of magnitude.

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm

Post by brad » Fri Jul 30, 2010 6:12 am

Nice explanation Stacy!

User avatar
sdudley
Moderator
Moderator
Posts: 337
Joined: Sun Mar 28, 2010 1:33 pm
Location: Florida, U.S.A.

Post by sdudley » Fri Jul 30, 2010 11:42 am

brad wrote:Nice explanation Stacy!
Thank you. I wasn't sure if I was just adding more confusion or actually helping. :?

Stacy
Any time you deviate from sequential consistency, you increase the complexity of the problem by orders of magnitude.

dannymosquito
semi-newbie
semi-newbie
Posts: 10
Joined: Tue Apr 13, 2010 11:50 pm
Location: Australia

Post by dannymosquito » Sat Jul 31, 2010 11:14 am

No thats brilliant Stacy I was actually wondering that myself and what you have shown makes perfect sense. By the way after making the change to the settings in MPLAP to the correct chip everything worked fine and had my led flashing in no time. Assembly is sure a steep learning curve compared to other languages its so raw you really do get down into the nuts and bolts of everything. Got my knight rider demo wired up and working however B0 and B1 do not illuminate I have traced it back to the actual microcontroller as I get no signal out of these two pins. I have tried resoldering these pins but does nothing. When I test the other pins (B1 to B7) I get a signal straight away. WHat I think I have done in my noobness to soldering is I have applied to much heat and broken the microcontroller. Going to take it off and replace it with a new one tonight and see if it fixes the problem. :D
Danny
"Do not go where the path may lead; go instead where the path lead not and leave a trail"

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Post by bitfogav » Sun Aug 01, 2010 12:14 am

Hi Danny

Glad you got it all working now :) I have learnt so many things jus doing things myself and I have also damaged one or two microchips when I started off by heating up the microchip too much with a soldering iron, I did go out and buy a soldering iron with a smaller wattage and heat range and one other thing I do now with some of my projects is use a IC socket, (check picture) this way your not applying any heat to the microchip at all and if you need to change the microchip at all then its easier to remove it :)

Static can also be an issue too, I havn't had many problems with static apart from once where one of my projects was handled by someone and im not sure if it was something they touched on the board but it totally messed up the microchip, even the pickit2 wouldnt read it hehe! :) Luckily it was just a case of programming another microchip and fitting it.

Image
Attachments
ic socket.jpg
ic socket.jpg (17.68 KiB) Viewed 15116 times

dannymosquito
semi-newbie
semi-newbie
Posts: 10
Joined: Tue Apr 13, 2010 11:50 pm
Location: Australia

Post by dannymosquito » Sun Aug 01, 2010 1:48 am

one other thing I do now with some of my projects is use a IC socket,.
Thats a brilliant idea Gavin... I am going to order one right now. I think I've managed to break another one as well... Its strange everything was working great I had reprogrammed it heaps of times and then I tried to reprogram it once again however it started coming back with an incorrect ID for a PIC16F648A error (was coming back with and id of 0x3000 or similar). I went over my board with a multi meter and found that a solder joint was just managing to short out pins 12 and 13 which are the programming data and the programming clock. Pretty sure there are no more shorts however cannot get the chip out of this incorrect ID state. I guess it still could be other issues with the circuit as my soldering does leave a bit to the imagination however I can't see having those two pins shorted out would have done good things to the microcontroller either. In any case going to start from scratch and get some more practice soldering. Good thing these 16F648As are as cheap as chips.
Danny
"Do not go where the path may lead; go instead where the path lead not and leave a trail"

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Post by bitfogav » Mon Aug 02, 2010 9:29 am

Good thing these 16F648As are as cheap as chips.
Haha I must say that did make me laugh (cheap as chips) :D

It is possible that the data lines being shorted out has currupted the microchip or damaged it in some way so that your programmer will no longer read it, all I can say is try another one and see what happens :)

It is always worth just double checking your soldering and circuits before even programming your microchip. lets hope your next microchip works :)

User avatar
sdudley
Moderator
Moderator
Posts: 337
Joined: Sun Mar 28, 2010 1:33 pm
Location: Florida, U.S.A.

Post by sdudley » Mon Aug 02, 2010 12:10 pm

Danny,
I am glad to see you understood what I was trying to say.

I always try and use a DIP socket (as Gavin posted) when I build my circuits for the same problems you are having.

Keep us posted!

Stacy
Any time you deviate from sequential consistency, you increase the complexity of the problem by orders of magnitude.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest