Kind of stuck


Closed Thread
Results 1 to 7 of 7

Thread: Kind of stuck

  1. #1
    Join Date
    May 2009
    Posts
    9

    Default Kind of stuck

    Hello,

    Ive got a really simple problem but i cannot see why i can not sort it.

    Im using a K8048 board with the standard 18pin 16F627A pic. Ive managed to hook it up and ive compiled the blink app in mplab and put it on the pic fine.

    The problem is ive tried to drop a if statement in as i thought it was a simple enough thing to do next. Only problem is it does not work

    This is the code ive done
    Code:
    OPTION_REG = %11010111	'Set PIC options (See datasheet).
    TRISA = %11111111	'all RA ports are inputs
    TRISB = %11000000 	'RB7 & RB6 are inputs.RB5...RB0 are outputs.
    
    
    led1 var portB.0 
    led2 var portB.1
    sw1 var portA.0
    
    
    loop:   
    
    	if sw1 = 1 then	Goto loop	
    
    	high led1          ' Turn on LED connected to PORTB.0
    	low led2
            Pause 500       ' Delay for .5 seconds
    
    		
           	low led1          ' Turn off LED connected to PORTB.0
    	high led2
            Pause 500       ' Delay for .5 seconds
    		
    
    
            Goto loop       ' Go back to loop and blink LED forever
    End
    This is part of the schematic for the k8084


    Ive looked at the code and ive got the A bank set as an input, and the push button goes to RA0.

    Any ideas where ive gone wrong, and sorry for such a dumb problem

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Try CMCON = 7
    It disabled comparators on Port A
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    May 2009
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    thanks loads Joe,

    That worked a treat. As my second app, ive just changed my app to do the knight rider led thing.


    Thanks again

    Trev

  4. #4
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Different pics would require different arguments to achieve this; disable the comparator, disable the adc and so on.

    Make things simpler for yourself; just add darrel Taylor's alldigital.pbp as an include to your code to never having to bother remembering it in the future. Available at http://www.picbasic.co.uk/forum/showthread.php?t=11100

    Regards,

    Anand

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default K2000

    Hi Trev,

    I did something similar a year ago http://home.citycable.ch/flotulopex/...0_Frames_e.htm

    Maybe this gives you some other ideas
    Roger

  6. #6
    Join Date
    May 2009
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    thanks for the replys guys, im loving the idea of being able to just code a pic to do stuff that would take a fair circuit to do.

    Ill add that all digital file to my pic programming stuff.

    Is there any good book that talks of good programming practices with pics, ie use this command instead of that ect?

    Thanks again

    Trev

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gti_uk View Post
    Is there any good book that talks of good programming practices with pics, ie use this command instead of that ect?

    Trev
    . . . BRUCE is still writing it . . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. lcd stops after about 5 minutes and gets stuck
    By robertpeach in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th September 2009, 12:03
  2. Stuck with 85C temp on ds18b20
    By revelator in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd April 2009, 19:50
  3. Getting Stuck in loop
    By Frozen001 in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 19th November 2008, 15:46
  4. Upgraded to MPLAB IDE 8.14 and now I'm stuck
    By BlueHairBob in forum General
    Replies: 2
    Last Post: - 20th August 2008, 01:15
  5. MPLAB Quickbuild stuck on
    By RichardBowser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th July 2006, 02:52

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts