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

    Thank you all for help and i will satill trying everythings to get it works.my project i want to buil is to control a cam and transmeter and some hardwares away from me and to shut them off and the pic to .so when i wake up the pic i send data to start the tranmeter and other hardware i will use the relays , i know how to do it but i need to save energy bcz the elctric goes off sometimes when its raining or windy thats why i want to put everythings shuted off and pic in deep sleep lol. THANK U ADAIN N MY WISHES
    HELLO

  2. #2
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Hi again i did tried portb.0 with rx using led it works good , but if u tried by resistor or sometthing else it will wake up pic but no data receiving from usart .well thank u everyones for helping me.
    Regards
    Code:
    SLP:
    CLEAR
    PORTB = %00000011
     OPTION_REG = %00000001
     INTCON.1 = 0
     INTCON.4 = 1 
     @ SLEEP
     @ NOP
     B0 = 0
    GOTO LOOP
    Last edited by Mus.me; - 27th November 2009 at 20:08.
    HELLO

  3. #3
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Thumbs up

    this is my code example it works great, i put pic to sleep sinding 1919 and i wake up pic when i send any number ,using serial communicator in mcode studio.
    Code:
    'pic16f628a 
    @ DEVICE WDT_ON, PWRT_OFF,MCLR_ON,CPD_OFF, BOD_OFF, PROTECT_OFF,INTRC_OSC_NOCLKOUT
          Include "modedefs.bas"
    PCON.3=1      
    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  
    define RX_INT    PIR1,RCIF       ;-- USART Receive Interrupt
    PORTA = %00000
    PORTB = %00000011
    TRISA = %00000
    TRISB = %00000011
    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 
    j var  BYTE
    
    
    
    
    
    b0 = 0 
    LOOP:
    if B0 = 1919 then SLP
    HSERIN 10,main,[DEC4 b0]
    MAIN:
    'im using here  dsr 7segment leds with 74hc164 , bcz not found lcds in my country no pic ic 
    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
    PORTB = %00000011 ,,, tried portb.0 with rx port ising led ot IR ld .
    OPTION_REG = %00000001
    pause 100
    INTCON.1 = 0
    INTCON.4 = 1 
    @ SLEEP
    @ NOP
    B0 = 0000
    PAUSE 100
    HIGH PORTB.7 ' just to see pic is wake up
    PAUSE 1000
    LOW PORTB.7
    GOTO LOOP
    END
    data @0,3,159,37,13,153,73,65,31,1,9 'here s  the numbers  from 0 to 9
    thanks a lots for helping
    Last edited by Mus.me; - 27th November 2009 at 21:46.
    HELLO

  4. #4
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    HELLO EVERYONES AGAIN LOL, IM TRYING TO SEND DEC NUMBERS FROM PC TO PIC BUT I DONNO HOW TO WHY WHEN I SEND EX: 15 IT STORES $60 IN EEPROM OR DEC 20 IT STOR $08 . AND IT STUCKS I SEND 5 TIMES OR MORE THEN IT RECEIVE THEM 1 TIME ....????????

    Code:
    @ DEVICE WDT_ON, PWRT_OFF,MCLR_ON,CPD_OFF, BOD_OFF, PROTECT_OFF,INTRC_OSC_NOCLKOUT  
      INCLUDE "MODEDEFS.BAS"
    
    intcon = 0		
    vrcon = 0
    CMCON = 7
    
    
    
    PORTB =%00000010
    TRISB = %00000010
    
    
    SO      con     2                       
    SI      con     1                       
    B0      var     byte
    
    mainloop:
     Serin2 SI,N2400,[B0]        ' GETTING DECIMAL  NUMBERS FROM PC
                                      'USING SERIAL COMMUNICATOR 
            If B0  Then print  
    GOTO MAINLOOP
    print:
      
    WRITE 5,B0      'SAVE NUMBERS IN EEPROM
    PAUSE 100
    Serout2 SO,N2400,[B0]                    
            Goto mainloop
    HELLO

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


    Did you find this post helpful? Yes | No

    Default

    Code:
    HELLO EVERYONES AGAIN LOL, IM TRYING TO SEND DEC NUMBERS FROM PC TO PIC BUT I DONNO HOW TO WHY WHEN I SEND EX: 15 IT STORES $60 IN EEPROM OR DEC 20 IT STOR $08 . AND IT STUCKS
    Mus.me,
    Serin2 SI,N2400,[B0] is wrong. For 2400 bauds use : Serin2 SI,396,[B0]. The same apply for SEROUT2.

    Do you use hyperterminal for RS232 com with the pic?

    ...... I SEND 5 TIMES OR MORE THEN IT RECEIVE THEM 1 TIME ....????????
    WRITE 5,B0 'SAVE NUMBERS IN EEPROM

    You are writing "5 TIMES OR MORE" in the same location, so at the end you will see only the last byte Txed.

    Al.
    Last edited by aratti; - 30th November 2009 at 01:31.
    All progress began with an idea

  6. #6
    Join Date
    May 2009
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    Code:
    hello everyones again lol, im trying to send dec numbers from pc to pic but i donno how to why when i send ex: 15 it stores $60 in eeprom or dec 20 it stor $08 . And it stucks
    mus.me,
    serin2 si,n2400,[b0] is wrong. For 2400 bauds use : serin2 si,396,[b0]. The same apply for serout2.

    Do you use hyperterminal for rs232 com with the pic?



    write 5,b0 'save numbers in eeprom

    you are writing "5 times or more" in the same location, so at the end you will see only the last byte txed.

    Al.
    thank you aratti im using serial communicator in microcode studio . But still gettin wiered symboles when i send from pic to the pc . I want to send dec and ascii but i donno how
    HELLO

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


    Did you find this post helpful? Yes | No

    Default

    ...... But still gettin wiered symboles when i send from pic to the pc . I want to send dec and ascii but i donno how
    Mus.me, all the ascii from 0 to 31 will give you wierd symboles, and 32 will show nothing because is space. This is the reason why you use the notation DEC before the variable to Tx.

    If you want to receive both decimal and ascii you can Tx twice the variable

    Serout2 SO,390,[DEC B0, " ", B0,13,10]

    or you can select in which format to send out the variable depending on its value

    IF B0<33 Then
    Serout2 SO,390,[DEC B0,13,10]
    ELSE
    Serout2 SO,390,[B0,13,10]
    ENDIF


    Al.
    All progress began with an idea

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 22:55
  2. 16F883 Code Verify Problem
    By munromh in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2009, 12:47
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  4. problem with my code
    By civicgundam in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd February 2008, 02:52
  5. Code problem
    By chai98a in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th May 2006, 05: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