problem with variable on PIC10f202


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2006
    Location
    Slovenia EU
    Posts
    32

    Default problem with variable on PIC10f202

    Hi,

    I have a simple program and make me problem. After receiving data blinking LED only one cycle and after this cycle LED is off
    I would that LED is after receiving data blinking constant. Why is not stored number in variable and loop the program?

    tnx

    here is my program:


    @ device pic10F202,wdt_off,mclr_off,protect_off
    define osc 4
    INCLUDE "modedefs.bas"



    led var GPIO.0
    out var gpio.1
    serial var gpio.3
    ena var gpio.2
    b0 var byte
    b1 var byte

    main:
    serin serial,T2400,[1],b0

    for b1=0 to b0
    high led
    pause 200
    low led
    pause 200
    next b1
    pause 2000
    goto main


    end

  2. #2
    Join Date
    Jul 2007
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Your code will go back to Main after first blink, and then wait again for a command as it see Serin, which wait forever until you send him data.

    look into adding a background timer if you want the led to blink, or use a timeout so the Serin will end if no new char is received.

    also, some indent in code help to see more clearly

    Code:
    main:
    serin serial,T2400,[1],b0
    
    for b1=0 to b0
      high led
      pause 200
      low led
      pause 200
      next b1
    
    pause 2000
    goto main

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 00:06
  2. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  3. Variable problem
    By Pesticida in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 30th May 2008, 21:25
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. PIC10F202 Variable trouble
    By George in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 13th October 2006, 02:14

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