Problem runing my code


Closed Thread
Results 1 to 34 of 34

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mus.me View Post
    i think none understands my quetion.i want to run like this code ..
    i want both programes to run apart from each other its just example so i can write my programe like this plz help
    Code:
    main:   ' i wa]nt this led to blink  forever without any other delay or stops
    high led
    pause 100    
    low led
    pause 100
    goto main
    
    loop: ' and i want this led1 to blink without any other delay or stop
    high led1
    pause 2000
    low led1
    pause 200
    goto loop
    You might try this:
    Code:
    main:
    For ledvar = 0 to 100
    low led
    pause 100
    high led
    pause 100
    
    next ledvar
    
    low led1
    For ledvar = 0 to 100
    low led
    pause 100
    high led
    pause 100
    
    High LED1
    goto Main
    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.

  2. #2
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Angry i solved that code joe thank u for help

    the big problem i have now is to wake up pic 16f628 from sleep using usart interrupt hserin i tested PIR1 it occur but in sleep mode it doesnt occur . i donno i think im runing usart on synchronous slave mode thats what says the datasheet but i donno wheres my problem .my project is to transmet data to pic then wake it up . here is my code .
    Code:
     @ DEVICE WDT_ON, PWRT_OFF,MCLR_ON,CPD_OFF, BOD_OFF, PROTECT_OFF,INTRC_OSC_NOCLKOUT
          Include "modedefs.bas"
          
    DEFINE OSC 4
    RCSTA=$90'DEFINE HSER_RCSTA 90H
    TXSTA = $20'DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 2400
    DEFINE HSER_SPBRG 25
    'DEFINE HSER_EVEN 1
    'DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    'DEFINE HSER_TIMEOUT 1 ' Clear overflow automatically  
    
    PORTA = %00000
    PORTB = %00000010
    TRISA = %00000
    TRISB = %00000010
    intcon = 0		
    vrcon = 0
    CMCON = 7	     
    j var  BYTE
    led var portb.7
    
    LOOP:
    j = j + 1
    if j = 255 then SLP
    high led2
    HSERIN 10,main,[DEC4 b0]
    
    goto loop
    
    ' here will be  my programe 
    SLP:
    low led
    RCSTA.4=0
     pause 100
    INTCON.6 = 1
    RCSTA.4 = 1
    PIE1.5 = 1
    PIR1.5 = 0
    @ SLEEP
    @ NOP
    PAUSE 1000
    HIGH PORTB.6
    PAUSE 1000
    LOW PORTB.6
    GOTO LOOP
    END
    please help i had read all the usart datasheet and i did what it says but nothings i think the problem in sync slave mode or the osc goes off during sleep or usart not reciving data even i did set it to recive data and interrupt..
    and acetronics says (Alain

    ... and now, just use " Wake up on interrupt " ... as you have the interrupt flag !!! i donno where to put on interupt i trayed it many ways but nothings when it goes to sleep it die just like my nan bless her ..
    Last edited by Mus.me; - 27th November 2009 at 01:14.
    HELLO

  3. #3
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Mus.me, the time you are using to go to sleep it seems to to be too short. You have 2.5 secs available than your micro enter into the sleep process. I would use a word (J VAR WORD) and set at least 20 seconds, otherwise you cannot even read the display.

    Code:
    LOOP:
    j = j + 1
    if j = 255 then SLP '2.5 secs is a too short time use a word 
    high led2
    HSERIN 10,main,[DEC4 b0]
    
    goto loop
    Remove the two long pause in your code (after sleep command) otherwise when micro wakes has to process the two pauses and will loose the Tx data, and will return to sleep.

    Code:
    @ SLEEP
    @ NOP
    PAUSE 1000
    HIGH PORTB.6
    PAUSE 1000
    LOW PORTB.6
    GOTO LOOP
    Al.
    Last edited by aratti; - 27th November 2009 at 07:44.
    All progress began with an idea

  4. #4
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    thank u aratti for reply i think the problem is in usart when pic goes in sleep mode the something aint working to receive data from PC TX , i tryed everythings 3days now but nothings .here where i have the problem, why it doesnt wake up the chip ?? lol
    Code:
    SLP:
    OPTION_REG.7 = 0
    RCSTA.4=0
    pause 100
    INTCON.6 = 1
    RCSTA.4 = 1
    PIE1.5 = 1
    PIR1.5 = 0
    @ SLEEP
    @ NOP
    GOTO LOOP
    sorry for asking to much but i really wants to learn pbp very good im reading the whole datasheet every nights it helps and i get to much help and ideas from this forum thank u everyone
    HELLO

  5. #5
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Post

    Hi Mus.me,

    I think you should turn on global interrupt enable (GIE) bit.
    Code:
    INTCON.7 = 1
    Isn't that the master switch for all interrupts?

    BR,
    -Gusse-

  6. #6
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by Gusse View Post
    Hi Mus.me,

    I think you should turn on global interrupt enable (GIE) bit.
    Code:
    INTCON.7 = 1
    Isn't that the master switch for all interrupts?

    BR,
    -Gusse-
    hello Gusse thank u for help , i did that not working, i think i have problem in slave senchronous or somethings goes off when sleep mode .im sending 4 numbers from the pc and it works great .but in sleep mode it doesntwake it up
    HELLO

  7. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Mus.me, HSERIN is an asynchronous serial function. You cannot awake from sleep the mcu with HSERIN you should search another way. If you have PortB.0 available then you could use the interrupt on portB.0, for instance you could connect RTS pin to portB.0 (via a level translator) and before TX you pull high RTS to wakeup the pic.

    Al.
    All progress began with an idea

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi, Mus

    I played a bit with the HSERIN Command ... but Wake up only works in Synchronous mode ( roughly consider USART is disabled when sleep mode ... as the system clock is ... down !)

    sooo ...

    last option is to use a comparator interrupt: tie the comparator input to RX Pin ( seems Porta is unused ...) and use the comparator interrupt for wake up ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. 16F883 Code Verify Problem
    By munromh in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2009, 11:47
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. problem with my code
    By civicgundam in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd February 2008, 01:52
  5. Code problem
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th May 2006, 04:43

Members who have read this thread : 0

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