On Interrupt


Closed Thread
Results 1 to 7 of 7

Thread: On Interrupt

  1. #1
    Join Date
    Dec 2005
    Location
    Corum,Turkiye
    Posts
    15

    Default On Interrupt

    Hi all,

    i m writing a moving message display code... all things good now. but i need help a on interrupt send data from pc.. and write data 24c64


    mainprogram:
    .
    .
    .
    interrupt rutine----> goto pclink
    ( help me for here)

    goto mainprogram

    --------------------------


    PCtalk:
    'start communicating with PC by sending acknowledge bit
    j = 0 : pause 100 :

    SERIN SERIALIN,N2400,["@"],bilgi 'wait for char. @ from the PC and store second @ in char...
    getserial: 'start receiving serial data
    Serin SERIALIN,N2400,bilgi 'receive at 9600bps and store in variable char
    I2CWRITE SDA,SCL,$A0,j,[bilgi] 'write each received character to the memory, starting at 0

    if bilgi = EOM then 'check to see if incoming character is EOM
    Goto start 'go back to the very beginning of program to reset everything
    endif 'end checking if character is EOM
    j = j + 1 'increment pointer that points to the next memory location
    goto getserial 'if incoming character was not EOM, return for more chars.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    it will help if we know what is the interrupt source... Usart, A/D converter, CCP, Timer, UFOs
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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

    Smile Minor Detail

    Quote Originally Posted by elektroline
    Serin SERIALIN,N2400,bilgi 'receive at 9600bps and store in variable char

    N2400 = 2400 Baud Inverted

    T9600 = 9600 True
    N9600 = 9600 Inverted

  4. #4
    Join Date
    Dec 2005
    Location
    Corum,Turkiye
    Posts
    15

    Default Right...

    Hi ,

    Mister_e;

    interrupt ll be for usart.....

    My code is godd running. but i want to send data from pc and when send will data from pc goto serin routine and write eprom


    Joe S. ;

    i m using 18f452
    and 10 MHz quartz. and config is hs_pll ( 10 x 4 = 40 mHz )
    so baud= 2400 x 4 = 9600 ( i hope )

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    So your PIC have a Hardware USART, use it and use it's interrupts.

    Use HSERIN instead of SERIN as it use the PIC Usart.

    Maybe the following may help.
    http://www.picbasic.co.uk/forum/show...1&postcount=11

    You just need to set you USART register for the Right baudrate
    something like
    Code:
    RCSTA = $90 ' Enable serial port & continuous receive
    TXSTA = $20 ' Enable transmit, BRGH = 0
    SPBRG = 64  ' 9600 Baud @ 0.16%
    OR
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 64  ' 9600 Baud @ 0.16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Dec 2005
    Location
    Corum,Turkiye
    Posts
    15

    Angry doesn't work...

    Hi, i write this codes but... i think interrupt is not working and data is not send from pc to pic eprom..





    DEFINE HSER_RCSTA 90h
    DEFINE HSER_SPBRG 64
    DEFINE HSER_CLROERR 1
    RCIF VAR PIR1.5
    EOM con ""
    bilgi var byte
    b var byte
    start:
    if RCIF then ' incomming data?
    HSERIN [bilgi]
    if bilgi= "@" then
    goto pctalk
    else
    goto start
    endif
    endif
    ....
    ....
    ... other codes
    ....
    ....


    pctalk:
    getserial:
    HSERIN [bilgi]
    write b, bilgi

    if bilgi = EOM then
    Goto start
    endif
    B = b + 1
    goto getserial

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358

    Default

    Consider...

    HSERIN [bilgi]

    ... at 9600 baud means you're sending 9600 bits in a second... for arguments sake, say it takes 10 bits for one byte (with start and stop bits), so it takes less than 1mS per byte to receive...

    And now...

    write b, bilgi

    ...takes 10mS to write to EEPROM...

    So for every ONE byte you save to EEPROM, using your code/method at only 9600 baud will ensure you lose the following 10/12 bytes of incoming data. Can you now see it's not so straightforward to receive RS-232 and write it to EEPROM... as you have to make sure that when you write to your EEPROM you're still going to grab any incoming data that may be arriving at the same time.

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  3. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  4. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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