![]() | ![]() | ![]() |
| | #16 |
|
I tried this: Code: list p=16f88 include (p16f88.inc) __CONFIG _CONFIG1, 0x2F34 org 0 bsf STATUS, RP0 movlw b'00001110' movwf OPTION_REG movlw b'00111111' movwf TRISA bcf STATUS, RP0 movlw b'10000000' xorwf PORTA, f sleep end | |
| |
| | #17 |
|
Well the above program blinks the RA7 LED, about once a second.
| |
| |
| | #18 | |
| Quote:
Code: LIST p=16F88 include "P16F88.inc" cblock 0x20 ;start of general purpose registers d1,d2,d3 endc org 0x0000 init banksel CMCON ;bank 1 movlw 0x07 ;turn comparators off movwf CMCON clrf ANSEL ;all pins digital clrf TRISA ;all pins outputs movwf TRISB banksel PORTA ;select bank 0 main bsf PORTA,1 call delay bcf PORTA,1 call delay goto main delay movlw 0x15 ;2499992 cycles movwf d1 movlw 0x74 movwf d2 movlw 0x05 movwf d3 delay_0 decfsz d1, f goto dd2 decfsz d2, f dd2 goto dd3 decfsz d3, f dd3 goto delay_0 return end
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 8th June 2008 at 09:57 PM. | ||
| |
| | #19 | |
| Quote:
Sorry to really break it down here, but do you mind walking me through it? I've successfully made a fair share of PIC programs and circuits using GCBASIC, but I'm looking to take the training wheels off! I know a lot of this might seem really obvious, but it seems the only way to troubleshoot it, so here it goes: 1) I open up MPLAB. 2) I select File> New. 3) This opens an "Untitled" window, which I notice is very bare, as in no code or even PC numbers in the margin when I type stuff in. That's new to me, because they're always there when you compile from GCBASIC. 4) I copy and paste in futz's code, but the text is all black, as in no colour-coding that I usually see in a compiled GCBASIC program. Also, the "program," "release from reset," etc icons are not present. That's where I'm at. Can you get me to point B? | ||
| |
| | #20 | ||
| Quote:
I use the code templates located at: C:\Program Files\Microchip\MPASM Suite\Template\Code They provide a nice starting point for building a project. Look for the file f88temp.asm Quote:
__________________ Inside every little problem, is a big problem trying to get out. Last edited by kchriste; 8th June 2008 at 10:29 PM. | |||
| |
| | #21 | ||
| Quote:
Here's a bad, but working, config line, shown in context with the preceding two lines: Code: LIST p=16F88 include "P16F88.inc" __config _CONFIG1, 0x3f2a Quote:
Do this: 1. Start MPLAB 2. Click Project/Project Wizard 3. Click Next 4. Select your exact MCU from the list and hit Next 5. Select your language toolsuite (Microchip MPASM Toolsuite) and Next 6. Create a directory for it and a New Project File in that directory and Next 7. Hit next at Step Four as you don't have a source file saved yet 8. Hit Finish 9. Click Project/Add New File To Project. Be sure you're pointing to the correct directory. Name the file something.asm and hit Save. 10. Paste the source code into the window and hit CTRL-S Assemble and program at will
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 8th June 2008 at 10:36 PM. | |||
| |
| | #22 | |||
| Quote:
Quote:
Quote:
| ||||
| |
| | #23 |
|
Argh! That's still not working for me. Is this suppose to be making PortA.1 flash (so pin 18 of the IC)? The only configuration bit I changed was the internal oscillator as RB6. | |
| |
| | #24 |
|
No PORTA.7 pin 16 Many A ports are A/D or have comparators that have to be disabled, A7 is a digital I/O pin by default. | |
| |
| | #25 | |
| Quote:
Wait, Did you mean pin 16 with just your code, or futz's as well? | ||
| |
| | #26 |
|
My code. What sort of programmer are you using?
| |
| |
| | #27 |
|
OK. Here it is, complete, and all in one post, with photos. ![]() That's a blue LED, so I used a 180 ohm resistor. For a red or green or amber LED you'd probably use a 330 ohm or even 470. Not terribly critical. But do use a current limiting resistor somewhere in that range. It has a 33K MCLR pullup. Any value from 10K to 33K is fine. It's not critical at all. ![]() ![]() ![]() Code: LIST p=16F88 include "P16F88.inc" __config _CONFIG1, _WDT_OFF & _INTRC_IO & _MCLR_ON ERRORLEVEL 0, -302 cblock 0x20 d1,d2,d3 endc org 0x0000 init banksel CMCON ;bank 1 movlw 0x72 ;8MHz internal osc movwf OSCCON movlw 0x07 ;turn comparators off movwf CMCON clrf ANSEL ;all pins digital movlw 0x00 ;all pins outputs movwf TRISA movwf TRISB banksel PORTA ;select bank 0 main bsf PORTA,1 call delay bcf PORTA,1 call delay goto main delay movlw 0x15 movwf d1 movlw 0x74 movwf d2 movlw 0x02 movwf d3 delay_0 decfsz d1,f goto dd2 decfsz d2,f dd2 goto dd3 decfsz d3,f dd3 goto delay_0 return end
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 9th June 2008 at 01:23 AM. | |
| |
| | #28 |
|
And here's the same thing in C (SourceBoost BoostC): Code: #include <system.h>
#include <stdio.h>
#pragma CLOCK_FREQ 8000000
#pragma DATA _CONFIG, _WDT_OFF & _INTRC_IO & _LVP_OFF & _MCLR_ON
void main(void)
{
osccon=0x72;
cmcon=0x07;
ansel=0;
trisa=0;
while(1){
porta.1=1;
delay_ms(500);
porta.1=0;
delay_ms(500);
}
}
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | |
| |
| | #29 |
|
Still nothing. Once I've saved the .asm, how do I get the .hex file? I've been going to file>export, then leaving the options as they are, and then saving as a .hex file. Then I import the .hex file. Is that right?
| |
| |
| | #30 |
|
It would help if we knew the programmer / software you're using. Some do not import the config fuses properly.
| |
| |
|
| Tags |
| mplab, problem, programming or compiling |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Programming C in MPLAB | simrantogether | Micro Controllers | 11 | 11th February 2008 07:40 PM |
| Programming PICC through MPLAB | MatrixPhreak | Micro Controllers | 25 | 9th December 2007 04:56 PM |
| Programming HEX file with MPlab/Inchworm | gregmcc | Micro Controllers | 4 | 27th April 2007 04:20 PM |
| compiling with MPLAB | evandude | Micro Controllers | 4 | 9th April 2005 09:08 AM |
| Compiling 16F628A - problem | kenmac | Micro Controllers | 4 | 23rd September 2004 06:00 AM |