Delivered-To: jake@vapourforge.com Received: from pch.mit.edu (PCH.MIT.EDU [18.7.21.90]) by mail.vapourforge.com (Postfix) with ESMTP id E745ECFC0 for ; Sun, 18 Jul 2010 08:16:12 +1000 (EST) Received: from pch.mit.edu (pch.mit.edu [127.0.0.1]) by pch.mit.edu (8.13.6/8.12.8) with ESMTP id o6HM9ivv012660; Sat, 17 Jul 2010 18:09:47 -0400 Received: from mailhub-dmz-1.mit.edu (MAILHUB-DMZ-1.MIT.EDU [18.9.21.41]) by pch.mit.edu (8.13.6/8.12.8) with ESMTP id o6HM9hTM012657 for ; Sat, 17 Jul 2010 18:09:43 -0400 Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by mailhub-dmz-1.mit.edu (8.13.8/8.9.2) with ESMTP id o6HM9hFR010924 for ; Sat, 17 Jul 2010 18:09:43 -0400 X-AuditID: 1209190c-b7c34ae000000a06-29-4c422a26fddf Received: from out1.ip09ir2.opaltelecom.net (out1.ip09ir2.opaltelecom.net [62.24.128.245]) by dmz-mailsec-scanner-1.mit.edu (Symantec Brightmail Gateway) with SMTP id 27.E9.02566.62A224C4; Sat, 17 Jul 2010 18:09:42 -0400 (EDT) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EABfHQUxZ8QQ6/2dsb2JhbACUTosjcb5ihSUEixeHAg X-IronPort-AV: E=Sophos;i="4.55,220,1278284400"; d="scan'208";a="442021389" Received: from unknown (HELO Oli1) ([89.241.4.58]) by out1.ip09ir2.opaltelecom.net with SMTP; 17 Jul 2010 23:09:41 +0100 Message-ID: From: "Oli Glaser" To: "Microcontroller discussion list - Public." References: <4C421C24.8060209@theiet.org> In-Reply-To: <4C421C24.8060209@theiet.org> Subject: Re: [PIC] Problem getting PIC18 to work under C18 (was [PIC] Settingout PIC18 Assembly code) Date: Sat, 17 Jul 2010 23:09:10 +0100 MIME-Version: 1.0 X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 14.0.8117.416 X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8117.416 X-Brightmail-Tracker: AAAAARUsJHI= X-Topics: [PIC] X-BeenThere: piclist@mit.edu X-Mailman-Version: 2.1.6 Precedence: list Reply-To: "Microcontroller discussion list - Public." List-Id: "Microcontroller discussion list - Public." List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: piclist-bounces@mit.edu Errors-To: piclist-bounces@mit.edu -------------------------------------------------- From: "Andrew Wood" Sent: Saturday, July 17, 2010 10:09 PM To: Subject: [PIC] Problem getting PIC18 to work under C18 (was [PIC] Settingout PIC18 Assembly code) > Many thanks to everyone who replied to my previous message about the > format of PIC18 Assembly code. > > Ive decided to program in C using C18 for now as Im familiar with C. Ive > not used PICs before, as you may recall from my previous messages Im > making a part for an antique telephone switch at a museum. Ive built > simple circuit using a PIC18F13K50. The circuit diagram at > http://www.simple.org/pic18.jpg > shows what Ive built. Theres 3 LEDs on port C and a 12MHz crystal on the > clock inputs. > > If I poke a 5v probe into the holes on the chip holder for pins 14,15 & > 16 the LEDs light so I know they're OK. > > Ive writen a simple program using C which sets RC0 high and I would > expect the corresponding LED to light. The program compiles OK using C18 > in MPLAB and I can export the HEX to a file. > > Im using a PICKit 2. The PICKit2 software says it can 'see' the PIC chip > and seems to upload the hex file to it successfully, however when I put > the chip into the circuit the LED doesnt light, and the chip gets VERY > hot. > > I suspect Im doing something wrong with the crystal or not setting the > config registers but Im not sure what to set or how. Ive read the > datasheet but the section on config registers is confusing me. > > If anyone can offer any help to get me going Id be most grateful. The C > code is below. Yes, as mentioned the power and ground are the wrong way round. MCLR (if used, or not connected to PicKit2) has no pull up - are you using the PicKit2 to power the circuit? Decoupling cap needed between Vdd and Vss, 0.1uF ceramic close to pins should be okay. The code will not work like that. I suggest having a good read of the datasheet and the C18 manual to get up to speed with stuff like how to set up the config bits (I think the commands used may be at the bottom of the relevant header file for that particular PIC) The first few chapters and the I/O chapter especially. For example, the watchdog timer may be turned on which will reset the PIC constantly unless explicitly turned off in the config bits. Also you need to set which system clock you are using, whether MCLR is functional and various other basic config settings. I would have a look for some 18F example code to give you an idea of what is needed (doesn't have to be the exact same part for the general idea) If you still can't get an LED to flash after this, I can help you with some basic code if needed. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist