PIC programme doesnt run completely

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

PIC programme doesnt run completely

Postby sse » Fri Oct 12, 2012 1:15 pm

Hi all, help me please~ i met up some critical issued~
I'm using MicroCodeStudio as software and uic00b & icsp as hardware.
My question is ;
I'm 1st time bought an uic00b, did i need to setting up something in (PICkit 2)?
Following is my program BUT im not sure whether it's correct or not~ :?
input/MCLR= 2 switchs
output=leds
4MHz as OSC, 30pF x2
CODE: SELECT_ALL_CODE
define OSC 4

trisa = %11111111     
porta = %11111111
     
adcon1 = 7             
flag var byte
flag = 0
trisb = %00000000       
portb = %00000000

START   

pb1:
if porta.2 = 0 then lampu1
goto lampu1

lampu1:
high portb.0
PAUSE 30
LOW portb.0
high portb.1
PAUSE 30
LOW portb.1
high portb.2
pause 30
low portb.2
goto lampu1
 
end

At the end, when the +5v supply is given to this circuit, the program r run automatically even i nvr press pb1(porta.2)~ :cry:
sse
Newbie
 
Posts: 11
Joined: Mon Mar 19, 2012 8:08 pm
Location: johor bahru, m'sia

Re: PIC programme doesnt run completely

Postby robosang » Fri Oct 12, 2012 9:31 pm

Don know what are you writing, not familiar with basic.

So show us the schematic and better with the hardware photo.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: PIC programme doesnt run completely

Postby gadgetng » Sat Oct 13, 2012 3:59 pm

why don't u try in C. Im sure there will be more people willing to help you if u write in C. :lol:
Cytron did a nice tutorial for beginner ... u can check it there..

1. http://tutorial.cytron.com.my/2011/08/05/sk40c-tutorial/
2. http://tutorial.cytron.com.my/2012/07/03/mplab-v8-63-with-hi-tech-compiler-v9-80/
3. http://tutorial.cytron.com.my/2011/08/18/how-to-create-a-project-in-mplab-ide/
gadgetng
Discoverer
 
Posts: 97
Joined: Tue Jul 24, 2012 11:20 am

Re: PIC programme doesnt run completely

Postby zhenning » Sun Oct 14, 2012 9:47 am

sse WROTE:Hi all, help me please~ i met up some critical issued~
I'm using MicroCodeStudio as software and uic00b & icsp as hardware.
My question is ;
I'm 1st time bought an uic00b, did i need to setting up something in (PICkit 2)?
Following is my program BUT im not sure whether it's correct or not~ :?
input/MCLR= 2 switchs
output=leds
4MHz as OSC, 30pF x2
CODE: SELECT_ALL_CODE
define OSC 4

trisa = %11111111     
porta = %11111111
     
adcon1 = 7             
flag var byte
flag = 0
trisb = %00000000       
portb = %00000000

START   

pb1:
if porta.2 = 0 then lampu1
goto lampu1

lampu1:
high portb.0
PAUSE 30
LOW portb.0
high portb.1
PAUSE 30
LOW portb.1
high portb.2
pause 30
low portb.2
goto lampu1
 
end

At the end, when the +5v supply is given to this circuit, the program r run automatically even i nvr press pb1(porta.2)~ :cry:


Did you tie your porta.2 low? or you leave it hanging?
zhenning
Enthusiast
 
Posts: 351
Joined: Thu Dec 30, 2010 12:32 am

Re: PIC programme doesnt run completely

Postby sse » Tue Oct 16, 2012 11:30 am

robosang WROTE:Don know what are you writing, not familiar with basic.

So show us the schematic and better with the hardware photo.

Apologise coz present with my poor languages but i'm still learning. :|
Here is my schematic:
Untitled.jpg
But i modified the input pin to porta.5 yesterday


zhenning WROTE:Did you tie your porta.2 low? or you leave it hanging?


Neither hanging or given low~ :?

gadgetng WROTE:why don't u try in C. Im sure there will be more people willing to help you if u write in C. :lol:
Cytron did a nice tutorial for beginner ... u can check it there..


u mean C language? ya, i'll try it next after i understood this 1st(coz some fren suggest that it's more simple than C)
sse
Newbie
 
Posts: 11
Joined: Mon Mar 19, 2012 8:08 pm
Location: johor bahru, m'sia

Re: PIC programme doesnt run completely

Postby ABSF » Tue Oct 16, 2012 12:13 pm

sse WROTE:
define OSC 4

trisa = %11111111
porta = %11111111

adcon1 = 7
flag var byte
flag = 0
trisb = %00000000
portb = %00000000

START

pb1:
if porta.2 = 0 then lampu1
goto lampu1

lampu1:
high portb.0
PAUSE 30
LOW portb.0
high portb.1
PAUSE 30
LOW portb.1
high portb.2
pause 30
low portb.2
goto lampu1

end

At the end, when the +5v supply is given to this circuit, the program r run automatically even i nvr press pb1(porta.2)~ :cry:


pb1:
if porta.2 = 0 then lampu1
goto lampu1


I think there's something wrong with the code above. Whether button at port a2 is pressed or not, it would go to "lampu1" and start blinking the LED.

I think you should change the "goto lampu1" to "goto pb1" for your program to work as intended.

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


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 4 guests