urgent..please help am stuck

Thread Starter

ali shaheen

Joined Jan 24, 2009
3
hello

i had made the JDM programmer by my self:),I got the schematic of that from the below given link

http://www.circuit-projects.com/microcontroller/pic-and-eeprom-programmer.html

I am using MPLAB for programming and PICpgm for burning the PIC18f452 microcontroller.

i am using 10mhz crystal osc with 22pf of parallel capacitors...a 5v power supply driven from a 9v battery and then lm7805....my basic code for only flashing the led from portB is given below

;;SIMPLE led FLASHER
;;USING BIT SET AND BIT CLEAR ((BSF,,BCF)...
#INCLUDE<P18F452.INC>
ORG 100H


V1 EQU 25H;
V2 EQU 35H;
R2 EQU 15H;
R3 EQU 20H;
R4 EQU 22H;

LOOP
CLRF TRISB;
BSF PORTB,0;
CALL DELAY;
BSF PORTB,1;
CALL DELAY;
BSF PORTB,2;
CALL DELAY;
BSF PORTB,3;
CALL DELAY;
BSF PORTB,4;
CALL DELAY;
BSF PORTB,5;
CALL DELAY;
BSF PORTB,6;
CALL DELAY;
BCF PORTB,5
CALL DELAY;
BCF PORTB,4
CALL DELAY;
BCF PORTB,3
CALL DELAY;
BCF PORTB,2
CALL DELAY;
BCF PORTB,1
CALL DELAY;
BCF PORTB,0
CALL DELAY;

GOTO LOOP;
DELAY
;DELAY 20*100*250*5*400ns=1,000,000,000 ns = 1,000,000 us = 1s
MOVLW D'20';
MOVWF R4;
BACK MOVLW D'100';
MOVWF R3
AGAIN MOVLW D'250'
MOVWF R2
THERE NOP
NOP
DECF R2,F
BNZ THERE
DECF R3,F
BNZ AGAIN
DECF R4,F
BNZ BACK
RETURN


END


the problem I am getting is that the LEDs are not flashing as i want them to...instead they are not turning on either..:confused:.from any of the ports....in configuration bits i had disabled watchdog timer,used HS osc type,.

please let me know what is the problem with it...either its the programmer or the code.......plaese please help me......am really in a hell lot of trouble.:(

best regards
ali shaheen
 

Markd77

Joined Sep 7, 2009
2,806
This is from the datasheet, might be worth a try. Just put clrf TRISB instead of the last 2 instructions.
Rich (BB code):
CLRF PORTB ; Initialize PORTB by
; clearing output
; data latches
CLRF LATB ; Alternate method
; to clear output
; data latches
MOVLW 0xCF ; Value used to
; initialize data
; direction
MOVWF TRISB ; Set RB<3:0> as inputs
; RB<5:4> as outputs
; RB<7:6> as inputs
 

Thread Starter

ali shaheen

Joined Jan 24, 2009
3
hello MARKD77

well thankyou very much for your quick reply but i cldnt understand wht u are trying to say......am a bit confused that which last two instruction u are talking about

best regard
ali shaheen
 

Markd77

Joined Sep 7, 2009
2,806
Try putting this in your code instead of just CLRF TRISB. It's probably better to put it before your LOOP as well.
Rich (BB code):
CLRF PORTB 
CLRF LATB 
CLRF TRISB
 
Rich (BB code):
GOTO LOOP;
DELAY
;DELAY 20*100*250*5*400ns=1,000,000,000 ns = 1,000,000 us = 1s
MOVLW D'20';
MOVWF R4;
BACK MOVLW D'100';
MOVWF R3
AGAIN MOVLW D'250'
MOVWF R2
THERE NOP
NOP
DECF R2,F
BNZ THERE 
DECF R3,F
BNZ AGAIN
DECF R4,F
BNZ BACK
RETURN
I'm not familiar with the 18F pics, but I think the branch on non zero is missing you up. If the bnz command is sending you back to your label (the GOTO portion of bnz), then you are reloading the registers R3 and R2 (maybe more) with your literal value. I'm not up on the bnz command, but just a thought.
 

t06afre

Joined May 11, 2009
5,934
I can see any setting of the configuration word (data sheet cap 19.0 SPECIAL FEATURES OF THE CPU). If the configuration word is not correct set, your MCU will not work. Also the JDM programmer is well known to be unpredictable. Are you able to verify that your code is programmed correct into the MCU?
 

Markd77

Joined Sep 7, 2009
2,806
Any luck yet?
Also where are you based? Maybe there is a member near you that can check if the PIC is getting programmed.
 
Top