help..my program doesn't work

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Re: help..my program doesn't work

Postby FakeSheep » Sun Apr 15, 2012 5:37 pm

Bro, it is build successful and works in simulating, but my PIC still doesn't work @@
i use PIC18f4550, program/verify with Microchip USB HID Bootloader v2.6, is it matter?
with 40 pins PIC, pin 20 to anode of LED, cathode of LED connect to ground(Vss) right
FakeSheep
Novice
 
Posts: 24
Joined: Sun Jul 10, 2011 4:13 pm

Re: help..my program doesn't work

Postby ABSF » Mon Apr 16, 2012 6:51 am

Try modify this:

;connect LED to PortD, Bit 1
#include P18F4550.INC
CONFIG WDT=OFF; disable watchdog timer
CONFIG MCLRE = ON; MCLEAR Pin on
CONFIG DEBUG = ON; Enable Debug Mode
CONFIG LVP = OFF; Low-Voltage programming disabled (necessary for debugging)
CONFIG FOSC = INTOSCIO_EC;Internal oscillator, port function on RA6

CBLOCK 0
Delay1:1
Delay2:1
ENDC

ORG 0 ; start code at 0
goto Start

ORG 0x10
Start:
CLRF PORTD
CLRF TRISD
CLRF Delay1
CLRF Delay2
MainLoop:
BTG PORTD,RD1 ;Toggle PORT D PIN 1 (20)
Delay:
DECFSZ Delay1,1 ;Decrement Delay1 by 1, skip next instruction if Delay1 is 0
GOTO Delay
DECFSZ Delay2,1
GOTO Delay
GOTO MainLoop
end
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: help..my program doesn't work

Postby FakeSheep » Sun Apr 22, 2012 1:00 am

Bro, it still can't work out =[
the only program can work until now is the HEX file which given from cytron
the LED blinking like a police car that 1...

i used the firmware and sample code which is from:
http://www.cytron.com.my/viewProduct.ph ... 0Combo%202
or any latest usb programming firmware for PIC18Fx55x is released?
FakeSheep
Novice
 
Posts: 24
Joined: Sun Jul 10, 2011 4:13 pm

Re: help..my program doesn't work

Postby ober » Mon Apr 30, 2012 6:57 pm

FakeSheep WROTE:i still can't work with it...any sample can let me refer?
or suggest me any other assembler or IDE etc?(ASM based pls, I'm suck in C, yet)
bcoz seems like no much body are using MPLAB...
it is quite sad that no much body can help with my problem and i can't even control a LED blinking
i stuck at situation like now for a long time

Is not that no one using MPLAB IDE, there is many using MPLAB IDE, but the real problem is not much people using Assembly. Most of us use C Language. For PIC18F we are using MPLAB C18 C Compiler from Microchip.

FakeSheep WROTE:Bro, it is build successful and works in simulating, but my PIC still doesn't work @@
i use PIC18f4550, program/verify with Microchip USB HID Bootloader v2.6, is it matter?
with 40 pins PIC, pin 20 to anode of LED, cathode of LED connect to ground(Vss) right

If you have try with sample code from Cytron and LED blinks, this at least indicate the hardware is working, the basic portion is working. 5V, Oscillator, LED connections are correct. So left your code. As far as I know, if you are using bootloader, normally the configuration bits cannot be changed. It will follow the configuration bits from the bootloader firmware, which in your case is HID bootloader. Since you have bootloader, please do not start your code in the 1st 4K byte, because the bootloader itself have taken up that space. You need to start your code from ORG 0x1000 (for reset vector). Focus on initializing the TRISx and PORTx for the LED.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: help..my program doesn't work

Postby takao21203 » Mon Apr 30, 2012 9:21 pm

@reply by ober

True most people these days use C, not assembler.

As for me I went through everything using only assembler,
some large projects include a 144 LED dot matrix clock (18F assembler),
the source by the way is horrible to read even for myself.

It was good for me, as I gained a fundamental grasp on the technology.
But I changed to C some months ago.

In the beginning, I spent hours sometimes only to flash the PIC, and to get the LED blinking!
And this remained difficult over maybe 2 years.
It's not so hard now to get to this point.

@OP

Decide for yourself where you want to go, hobby, or part-time use of the technology,
or more professional.

The technology including MPLAB, blinking LED, ASM on 18F worked for others, so it's not impossible to get it working.
There is a way in most cases! Don't give up, go through everything 20 times if neccessary.

PICs really can demand a lot of discipline. As I wrote, in the beginning it took me hours sometimes for simple programs.
And bootloaders, well my opinion is they can cause trouble...

If you don't yet master the technology, get some baseline PICs, and make a raw circuit, as simple as possible.

Because you don't need complicate configuration for these.
User avatar
takao21203
Discoverer
 
Posts: 111
Joined: Mon Mar 19, 2012 7:52 pm
Location: Ireland, Europe

Re: help..my program doesn't work

Postby robosang » Tue May 01, 2012 11:12 am

Agreed! I started with Assembly language too, take me 3 months just to get LED blinking on PIC16F877A those days :mrgreen: Now, though I still understand Assembly, I use C more as it is faster and tidier to develop program.

Yes, bootloader stop a lot of people from learning especially when they want to skip the rules! As highlighted by ober, you need to have program memory offset and reserve the space for bootloader. Now, I don use bootloader anymore even is USB :) I use the programmer from Cytron, it is cheap and it can program fresh new or uses PIC.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: help..my program doesn't work

Postby Brian Griffin » Tue May 01, 2012 11:49 am

I don't use the bootloader - when I started learning PIC, I used the PICkit 2 straight away. Works every time.

Assembly is good if you need to keep track of the number of cycles in the program. Some people will put inline assembly inside the interrupt routine so that the programmer can keep track of his/her interrupt latency. A high latency can stall the program, so care must be taken.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: help..my program doesn't work

Postby ABSF » Thu May 03, 2012 9:43 am

I never used Bootloader too. The bootloader that I've seen from another site says that it only occupies 256 words and it uses the highest memory space so I though that it should appeared transparent to the user. Last time when I programmed in 8051, it has a built in monitor program which control the serial interface and it has a menu for loading and saving of users' Hex programs from PC.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: help..my program doesn't work

Postby FakeSheep » Thu May 03, 2012 9:55 am

thx to you all guys, i found that the problem is just because of the bootloader indeed!!
ya, it's work fine when i use UIC00B instead of HID USB bootloader,
damn, how come i stuck at this stupid situation for so long time
anyway, now should put my effort to cover up the wasted time!haha
FakeSheep
Novice
 
Posts: 24
Joined: Sun Jul 10, 2011 4:13 pm

Previous

Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 2 guests