Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 9th October 2007, 04:08 AM   (permalink)
Default PIC18F2620 not being able to self-execute control code

I have a PIC18F2620 with port b connected as shown in http://imagebin.ca/view/4YjqO0.html (except on pin 1, it has a 10k pullup resistor to 5V rather than the power on reset circuit shown in the link). I'm currently using sdcc to compile my code and flashing the hex file to the microcontroller using a PICKIT2 programmer from Microchip through pk2 command line software in Kubuntu. The reason that I'm doing so this way is b/c I'm encountering problems with Microchip's PICKIT2 software in Windows. Basically, I'm using an internal oscillator in mode 2 at 8 MHz. I've talked to people on Usenet newsgroups, Microchip forums, dutchforce forums, and sdcc mailing list about the problem. While I'm very close on solving the fusebit initialization problems, I am still encountering the problem of not being able to have the microcontroller start the execution of the control code automatically whenever an external power supply other than the computer was applied to the microcontroller, although I've checked with an oscilloscope that it appears to be fairly stable. Does anyone here have any insights on this? I would be happy to provide more information if needed as I'm trying my luck here on another forum.

Thanks!
ssylee is offline   Reply With Quote
Old 10th October 2007, 08:08 PM   (permalink)
Default

I just wanted to update on the situation. I have swapped the PIC18F2620 with a PIC18F2220 and changed some code and the self-execution problem appears to be solved for now.
ssylee is offline   Reply With Quote
Old 10th October 2007, 09:38 PM   (permalink)
Default

What "self-execution" does actually mean?
__________________
Agustín Tomás
In theory, there is no difference between theory and practice. In practice, however, there is.
atferrari is offline   Reply With Quote
Old 10th October 2007, 09:43 PM   (permalink)
Default

Perhaps I phrased things pretty badly. What I meant by "self-execution" is my code being able to run automatically when I apply an external power source to the microcontroller. Hope it helps clear the confusion.
ssylee is offline   Reply With Quote
Old 10th October 2007, 09:47 PM   (permalink)
Default

Quote:
Originally Posted by ssylee
Perhaps I phrased things pretty badly. What I meant by "self-execution" is my code being able to run automatically when I apply an external power source to the microcontroller. Hope it helps clear the confusion.
That's what they do, they don't work in any other way - if it's not working, you've probably got a power supply problem, coming up too slowly or something?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 10th October 2007, 09:49 PM   (permalink)
Default

Don't really think it's a power supply problem, b/c if it is, I shouldn't be able to get it working with a microcontroller of a different model. It's probably something wrong with that microcontroller itself or something wrong in the code that I flashed to it.
ssylee is offline   Reply With Quote
Old 10th October 2007, 09:51 PM   (permalink)
Default

Quote:
Originally Posted by ssylee
Don't really think it's a power supply problem, b/c if it is, I shouldn't be able to get it working with a microcontroller of a different model. It's probably something wrong with that microcontroller itself or something wrong in the code that I flashed to it.
Fuse settings can have an effect, there are a number of them which could change it - but it doesn't mean the power supply isn't wrong, what are you using?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 10th October 2007, 09:52 PM   (permalink)
Default

Are you asking about the fusebits or power supply?
ssylee is offline   Reply With Quote
Old 10th October 2007, 09:54 PM   (permalink)
Default

Quote:
Originally Posted by ssylee
Are you asking about the fusebits or power supply?
Both in that case!
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 10th October 2007, 09:57 PM   (permalink)
Default

Power supply: 15V ac adapter that I scrapped off from a malfunctioning wireless router, regulated using a 7805 regulator with 22 uF (input) and 10 uF + 0.1 uF (output) caps in parallel

Fusebits: have to look at it when I get home from work; don't have the code in front of me
ssylee is offline   Reply With Quote
Old 11th October 2007, 05:40 AM   (permalink)
Default

Which fusebit details would you like to know?
ssylee is offline   Reply With Quote
Old 11th October 2007, 08:01 AM   (permalink)
Default

Quote:
Originally Posted by ssylee
Which fusebit details would you like to know?
Just post the lines you've used to set them.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 11th October 2007, 06:57 PM   (permalink)
Default

These are my fusebits command lines in the source code using PIC18F2620:
Code:
#pragma stack 0x200 0xff

code char at __CONFIG1H _conf0 = _OSC_INTIO7_1H;
code char at __CONFIG2L _conf1 = _BOREN_OFF_2L;
code char at __CONFIG2H _conf2 = _WDT_DISABLED_CONTROLLED_2H;
code char at __CONFIG3H _conf3 = _MCLRE_MCLR_OFF_RE3_ON_3H;
code char at __CONFIG4L _conf4 = _LVP_OFF_4L;
code char at __CONFIG5L _conf5 = _CP_0_OFF_5L & _CP_1_OFF_5L;
code char at __CONFIG5H _conf6 = _CPD_OFF_5H & _CPB_OFF_5H;
code char at __CONFIG6L _conf7 = _WRT_0_OFF_6L & _WRT_1_OFF_6L;
code char at __CONFIG6H _conf8 = _WRTD_OFF_6H & _WRTB_OFF_6H & _WRTC_OFF_6H;
code char at __CONFIG7L _conf9 = _EBTR_0_OFF_7L & _EBTR_1_OFF_7L;
code char at __CONFIG7H _conf10 = _EBTRB_OFF_7H;
The following is the fusebit command lines in the source code using PIC18F2220:

Code:
#pragma stack 0x100 0xff

code char at __CONFIG1H _conf0 = _OSC_INT_CLKOUT_on_RA6_Port_on_RA7_1H; //_OSC_INTIO7_1H;
code char at __CONFIG2L _conf1 =  _PUT_ON_2L & _BODEN_OFF_2L; //_BOREN_OFF_2L;
code char at __CONFIG2H _conf2 = _WDT_DISABLED_CONTROLLED_2H;
code char at __CONFIG3H _conf3 = _MCLRE_MCLR_Disabled_RE3_Enabled_3H; //_MCLRE_MCLR_OFF_RE3_ON_3H;
code char at __CONFIG4L _conf4 = _LVP_OFF_4L;
code char at __CONFIG5L _conf5 = _CP_0_OFF_5L & _CP_1_OFF_5L;
code char at __CONFIG5H _conf6 = _CPD_OFF_5H & _CPB_OFF_5H;
code char at __CONFIG6L _conf7 = _WRT_0_OFF_6L & _WRT_1_OFF_6L;
code char at __CONFIG6H _conf8 = _WRTD_OFF_6H & _WRTB_OFF_6H & _WRTC_OFF_6H;
code char at __CONFIG7L _conf9 = _EBTR_0_OFF_7L & _EBTR_1_OFF_7L;
code char at __CONFIG7H _conf10 = _EBTRB_OFF_7H;
In order to compare the fusebits, you would need to look at the .h files attached to the post. I have converted them to dos formats in case anyone using windows wants to look at it. You're welcome to change it back to unix format too.
Attached Files
File Type: h pic18f2220.h (22.0 KB, 1 views)
File Type: h pic18f2620.h (34.7 KB, 0 views)
ssylee is offline   Reply With Quote
Old 12th October 2007, 03:43 AM   (permalink)
Default

I'm also trying a 8.0 Mhz and 32.764 kHz crystal oscillators at the same time since I may need to use 2620's memory capacity for what I want to do.
ssylee is offline   Reply With Quote
Old 13th October 2007, 05:50 AM   (permalink)
Default

I have tried to manually reprogram the configuration bits in pk2 on the 2620. I have taken a shortcut on figuring out the fusebits by looking in the .h files that I've posted on this thread. Below shows the printout indicating that I have failed to configured the fusebits.

Code:
root@prak-laptop:/media/sdb1/Sysil Laboratories/software_projects/LED_toggle# pk2 -config 0x3000 0xfef8 0xff00 0x00fb 0xffff 0xffff 0xffff

PK2 version 2.04 - 2006/12/17
 pk2 -config 0x3000 0xfef8 0xff00 0x00fb 0xffff 0xffff 0xffff

Locating USB Microchip PICkit2 (vendor 0x04d8/product 0x0033)
Found USB PICkit as device '003' on USB bus 003
Communication established. PICkit2 firmware version is 1.21.0
Device ID 0x0c80
PIC18F2620 Rev 6 found
Writing config words
root@prak-laptop:/media/sdb1/Sysil Laboratories/software_projects/LED_toggle# pk2 -config

PK2 version 2.04 - 2006/12/17
 pk2 -config

Locating USB Microchip PICkit2 (vendor 0x04d8/product 0x0033)
Found USB PICkit as device '003' on USB bus 003
Communication established. PICkit2 firmware version is 1.21.0
Device ID 0x0c80
PIC18F2620 Rev 6 found

User ID: 0xffff 0xffff 0xffff 0xffff

Configuration data: 0x0000 0x1e18 0x8700 0x00c1 0xc00f 0xe00f 0x400f
Would that have to do with the pk2 program itself? I have also tried to modify the configuration bits in my code swapping the oscillator between internal, HS, and LP modes, but none of them worked. Did I describe enough information to proceed on what could've went wrong?

Thanks.
ssylee is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Accessing EEPROM Clayton Micro Controllers 15 23rd March 2007 03:00 AM
Need PIC16F84A Cool Project Agent 009 Micro Controllers 158 11th March 2007 06:14 AM
Motor control interface dreamproject Micro Controllers 0 31st March 2005 03:48 AM
PIC16F84A Code Protect gatas Micro Controllers 3 21st July 2003 02:44 PM
Remote control code grabber nonzero Electronic Projects Design/Ideas/Reviews 5 20th July 2003 04:01 PM



All times are GMT. The time now is 11:29 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.