Problem runing my code


Closed Thread
Results 1 to 34 of 34

Hybrid View

  1. #1
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    WELL THIS IS MY CODE WHEN I CLICK SENT DATA (1234)FROM PC TO PIC16F628. I SEE IT FOR LESS THAN 1 SECOND THEN THE 7SEG GOES OFF TILL I CLICK AGAIN TO SEND I SEE IT JUST BLINK 1234. I DONNO HOW TO USE INTERRUPTS OR STOP HSERIN AND LET THE LOOP WORKING .PLZ HERE I WANT TO SAVE THE HSERIN DATA IN HR VAR AND STAY ON TILL I SENT OTHER DATA TO CHANGE .PLZ HELP ,THANK U...
    Code:
    @ DEVICE WDT_ON, PWRT_ON,MCLR_ON,CPD_OFF, BOD_OFF, PROTECT_OFF,INTRC_OSC_NOCLKOUT
          Include "modedefs.bas"
    DEFINE OSC 4
    DEFINE HSER_RCSTA 90H
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 2400
    DEFINE HSER_SPBRG 25
    DEFINE HSER_EVEN 1
    DEFINE HSER_ODD 1
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically  
    
    PORTA = %00000
    PORTB = %11000000
    TRISA = %00000
    TRISB = %11000000
    intcon = 0		
    vrcon = 0
    CMCON = 7	     
    
    SDO  Var PortB.4
    SCLK Var PortB.5
    BTM  Var PortB.6
    BTN VAR PORTB.7
    SEG var byte 
    Digit var byte[4] 
    index var byte 
    B0 var word
    D0 var byte 
    MN VAR WORD
    HR VAR word
    
    
    
    MAIN:
    HSERIN [DEC4 hr]
    
    B0 = HR
    D0 = B0 DIG 0                    
    READ D0,DIGIT[0]
    D0 = B0 DIG 1
    READ D0,DIGIT[1]
    D0 = B0 DIG 2
    READ D0,DIGIT[2]
    D0 = B0 DIG 3
    READ D0,DIGIT[3]
    
    for index = 0 to 3
    seg = digit [index]
    SHIFTOUT SDO,SCLK,0,[SEG\8]
    PORTA.0[index] = 1
    PAUSEus 999
    PORTA=0
    NEXT INDEX
    
    goto main
    
    END
    data @0,3,159,37,13,153,73,65,31,1,9
    Last edited by Mus.me; - 24th November 2009 at 02:33.

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


    Did you find this post helpful? Yes | No

    Default

    Try to make these two correction to your code:

    Code:
    MAIN:
    HSERIN 10,Skip00, [DEC4 hr]
    
    B0 = HR
    D0 = B0 DIG 0                    
    READ D0,DIGIT[0]
    D0 = B0 DIG 1
    READ D0,DIGIT[1]
    D0 = B0 DIG 2
    READ D0,DIGIT[2]
    D0 = B0 DIG 3
    READ D0,DIGIT[3]
    
    Skip00:
    
    for index = 0 to 3
    seg = digit [index]
    SHIFTOUT SDO,SCLK,0,[SEG\8]
    PORTA.0[index] = 1
    PAUSEus 999
    PORTA=0
    NEXT INDEX
    
    goto main
    Al.
    All progress began with an idea

  3. #3
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    THANK YOU ARATTI,Acetronics FOR HELPING ME, I DID THIS IT WORKS GREAT NOW IM PULLING SOME HAIR TO WAKE THE PIC FROM SLEEP WHEN I SEND DATA BUT STILL NOT WORKING YET HERE S MY CODE
    Code:
    @ DEVICE WDT_OFF, PWRT_OFF,MCLR_ON,CPD_OFF, BOD_OFF, PROTECT_OFF,INTRC_OSC_NOCLKOUT
          Include "modedefs.bas"
    DEFINE OSC 4
    DEFINE HSER_RCSTA 90H
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 2400
    DEFINE HSER_SPBRG 25
    DEFINE HSER_EVEN 1
    DEFINE HSER_ODD 1
    'DEFINE HSER_TIMEOUT 1 ' Clear overflow automatically  
    
    PORTA = %00000
    PORTB = %00000000
    TRISA = %00000
    TRISB = %00000000
    intcon = 0		
    vrcon = 0
    CMCON = 7	     
    
    SDO  Var PortB.4
    SCLK Var PortB.5
    BTM  Var PortB.6
    BTN VAR PORTB.7
    SEG var byte 
    Digit var byte[4] 
    index var byte 
    B0 var word
    D0 var byte 
    MN VAR WORD
    HR VAR word
    j var byte
    
    b0 = 0
    loop:
    j = j + 1
    if j = 200 then SLP
    HSERIN 10,main,[DEC4 b0]
    MAIN:
    
    D0 = B0 DIG 0                    
    READ D0,DIGIT[0]
    D0 = B0 DIG 1
    READ D0,DIGIT[1]
    D0 = B0 DIG 2
    READ D0,DIGIT[2]
    D0 = B0 DIG 3
    READ D0,DIGIT[3]
    
    for index = 0 to 3
    seg = digit [index]
    SHIFTOUT SDO,SCLK,0,[SEG\8]
    PORTA.0[index] = 1
    PAUSEus 999
    PORTA=0
    NEXT INDEX
    goto loop
    SLP:
    CLEAR
    RCREG = 1
    RCSTA .7=1
    RCSTA.4=1
    RCSTA.5 = 1
    RCSTA.6=1
    TXSTA.7=0
    TXSTA.4=1
    PIE1.5 = 1
    PORTB= %00000001
    
    OPTION_REG = %00000001 'F628 can use  4>7 pins to wake up sleep
    INTCON.1 = 0
    INTCON.4 = 1
    @ SLEEP 
    @ NOP  
    HIGH PORTB.6
    PAUSE 100
    LOW PORTB.6
    CLEAR
    RETURN
    END
    data @0,3,159,37,13,153,73,65,31,1,9
    Last edited by Mus.me; - 25th November 2009 at 13:57.
    HELLO

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


    Did you find this post helpful? Yes | No

    Wink in the end

    Hi, Mus.me

    Took me time to find the thread ...

    have a look here ...

    That is what you're looking for ...

    http://www.picbasic.co.uk/forum/show...28&postcount=2

    best :
    http://www.picbasic.co.uk/forum/show...51&postcount=2


    Alain

    ... and now, just use " Wake up on interrupt " ... as you have the interrupt flag !!!
    Last edited by Acetronics2; - 25th November 2009 at 14:11.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  5. #5
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    i will have a look THANK YOU VERY MUCH Acetronics and aratti and my wishes for u
    HELLO

  6. #6
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Angry

    i did all these reading the datasheep 16f628a but still dont work
    Code:
    CLEAR
    RCREG = 1
    RCSTA .7=1
    RCSTA.4=1
    RCSTA.5 = 1
    RCSTA.6=1
    TXSTA.7=0
    TXSTA.4=1
    PIE1.5 = 1
    PIR1.5=0 
    OPTION_REG = %00000001 'F628 can use  4>7 pins to wake up sleep
    INTCON.1 = 0
    @ SLEEP 
    @ NOP
    HELLO

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