Thank you 
But I want to use interrupt
In your suggestions,16f19176_serial_hw_int_cts.jal,there isn't any 
interrupt routine?!!
And I read very sample , but I can't find interrupt and interrupt routine.
In your suggestions,in the main loop , you are waiting to receive data , I 
don't want to use this method
Ok , I will create new project and test it and said the result

[email protected] در تاریخ دوشنبه ۱۹ آوریل ۲۰۲۱ ساعت ۲۱:۲۳:۴۵ (UTC+4:30) 
نوشت:

> Hi Majid,
>
> You should include the serial library and then use it.
>
> Have a look in the Jallib sample directory and check a sample file with 
> the name 'serial_hw_int_cts' in it.
>
> For example: 16f19176_serial_hw_int_cts.jal 
>
> This sample file shows a simple use of the library.  There are many more 
> sample files.
>
> Kind regards,
>
> Rob
>
>
> ------------------------------
> *Van:* [email protected] <[email protected]> namens majid 
> ebru <[email protected]>
> *Verzonden:* maandag 19 april 2021 15:24
> *Aan:* jallib <[email protected]>
> *Onderwerp:* Re: [jallib] How to send & receive data with interrupt in 
> RS232 
>  
>
> Thank you very much 
> Please guide me
>  Should I use your procedure in my program?!
>
> vasile در تاریخ دوشنبه ۱۹ آوریل ۲۰۲۱ ساعت ۱۵:۳۳:۳۱ (UTC+4:30) نوشت:
>
> Hi,
> Perhaps you would look at the library serial_hw_int_cts.jal and adapt the 
> (not very) simplified routine below at your need.
> The received data is in RCREG and we assume has one byte length.
>
> var byte your_data = 0
> procedure  _serial_receive_interrupt_handler() is
>
>    pragma interrupt
>
>    var  byte  x
>    var  bit   usart_error
>
>    if (SERIAL_RCIF == TRUE)  then        -- UART receive interrupt
>       usart_error = FALSE
>
>       if (defined(U1CON0)== TRUE) then
>          -- Newer USART type
>          if U1ERRIR_FERIF | U1ERRIR_RXFOIF | U1ERRIR_RXBKIF | 
> U1ERRIR_PERIF then
>             -- reset framing and/or overflow errors
>             U1ERRIR_FERIF  = FALSE
>             U1ERRIR_RXFOIF = FALSE
>             U1ERRIR_RXBKIF = FALSE
>             U1ERRIR_PERIF  = FALSE
>             U1FIFO_RXBE    = TRUE       -- clear receive bufer
>             usart_error    = TRUE
>          end if
>       else
>          -- Classic USART type
>          if ((RCSTA_OERR == TRUE) | (RCSTA_FERR == TRUE)) then  -- 
> frame/overr error
>             x = RCREG                              -- flush hardware buffer
>             while RCSTA_OERR == TRUE loop          -- overrun state
>                RCSTA_CREN = DISABLED               -- disable UART
>                RCSTA_CREN = ENABLED                -- re-enable UART
>                x = RCREG                           -- \  flush hardware 
> buffers
>                x = RCREG                           -- /
>             end loop                               -- until no more overrun
>             usart_error = TRUE
>          end if
>       end if
>    your_data = RCREG  -- here is your data if no communication error 
> appears
>    end if
>
> end procedure
>
> On Mon, Apr 19, 2021 at 5:16 AM majid ebru <[email protected]> wrote:
>
>
> Sorry 
> Can I use interrupt in Serial-Hardware?!
> Thank you
> ‪majid ebru‬‏ در تاریخ دوشنبه ۱۹ آوریل ۲۰۲۱ ساعت ۶:۴۳:۱۴ (UTC+4:30) نوشت:
>
> Thank you very much 
> I just want to send/receive data with interrupt.
> How can i do that?!
> I should use i2c or spi
> I can't find any sample about interrupt sending/receiving data in pic
>
>
> Kiste در تاریخ یکشنبه ۱۸ آوریل ۲۰۲۱ ساعت ۲۳:۵۵:۴۵ (UTC+4:30) نوشت:
>
> Hi! 
>
> serial_software can't use interrupts. It is a "bit-bang" design which 
> blocks the processor while sending data, or while waiting for incoming 
> data. 
>
> If you're using a controller which doesn't have a usart peripheral and 
> need to send or receive asynchronous serial signals without blocking, you 
> would need to fire one interrupt per bit. There is no library which uses 
> this approach, and it would also be of little use. One interrupt per bit 
> means you can only use very low baud rates, unless your controller is a 
> very fast one. And all the fast controllers do have usart peripherals. 
>
> Greets, 
> Kiste 
>
>
>
>
>
>
> Am Sonntag, 18. April 2021, 21:15:21 MESZ hat majid ebru <
> [email protected]> Folgendes geschrieben: 
>
>
>
>
>
>
> Hi 
> i have two PIC16f877A. 
> how can i use Interrupt for send& receive data between they?? 
> i should use Serial_Software 
> ------------ 
>
>         ;@jallib section chipdef 
> -- chip setup 
> include 16f877a 
> pragma target clock 8_000_000                  -- xtal frequency 
> pragma target OSC   hs 
> pragma target WDT   disabled 
> pragma target LVP   disabled 
> enable_digital_io() 
> include print 
> include delay 
> intcon_gie =  true            -- Enable interrupt generally 
> -------------------------- Port A --------------------------------- 
> const bit  ADC_HIGH_rESOLUTION = low 
> const word ADC_rSOUrCE = 2_000 
> const byte ADC_NVrEF = ADC_VrEF_POS--ADC_NO_EXT_VrEF--ADC_NO_VrEF-- and 
> one Vref pin 
> const byte ADC_NCHANNEL = 3                --- our 6 ADC channel 
> include adc 
> include math 
> adc_init() 
> var word ADC_Input_general_1 = 0 
> var word ADC_Input_general_2 = 0 
> var word ADC_Input_general_3 = 0 
> -------------------------------------------- ok, now setup serial 
> alias serial_sw_tx_pin is pin_C4 
> alias serial_sw_rx_pin is pin_C5 
> pin_C4_direction = output 
> const serial_sw_baudrate = 9600 
> var bit serial_sw_invert = false 
> include serial_software 
> serial_sw_init() 
> -------------------------- Port B --------------------------------- 
> alias in1 is pin_b0 
> pin_b0_direction = input 
> -------------------------------- 
> alias in2 is pin_b1 
> pin_b1_direction = input 
> -------------------------------- 
> alias in3 is pin_b2 
> pin_b2_direction = input 
> -------------------------------- 
> alias in4 is pin_b3 
> pin_b3_direction = input 
> -------------------------------- 
> alias in5 is pin_b4 
> pin_b4_direction = input 
> -------------------------------- 
> alias in6 is pin_b5 
> pin_b5_direction = input 
> -------------------------- Port E --------------------------------- 
> alias SS1 is pin_e0 
> pin_e0_direction = output 
> SS1 = 0 
> -------------------------------- 
> alias SS2 is pin_e1 
> pin_e1_direction = output 
> SS2 = 0 
> -------------------------- Port D --------------------------------- 
> alias Buzzer1 is pin_d1 
> pin_d1_direction = output 
> Buzzer1 = 0 
> -------------------------------- 
> alias FlashLED1 is pin_d2 
> pin_d2_direction = output 
> FlashLED1 = 0 
> -------------------------------- 
> alias Out_1 is pin_d3 
> pin_d3_direction = output 
> Out_1 = 0 
> -------------------------------- 
> alias Out_5 is pin_d4 
> pin_d4_direction = output 
> Out_5 = 0 
> -------------------------------- 
> alias Out_4 is pin_d5 
> pin_d5_direction = output 
> Out_4 = 0 
> -------------------------------- 
> alias Out_3 is pin_d6 
> pin_d6_direction = output 
> Out_3 = 0 
> -------------------------------- 
> alias Out_2 is pin_d7 
> pin_d7_direction = output 
> Out_2 = 0 
> ------------------------------------------------------------------- 
> var word n = 0 , j = 0 
> ------------------------------------------------------------------- 
> var bit bitOut1 = 0,  bitOut2 = 0 
> ------------------------------------------------------------------- 
> var word press = 0 
> var word btnDelay = 500, btnDelay_1 = 0, btnDelay_2 = 0 
> var word btnDelay_3 = 0, btnDelay_4 = 0 
> var word buzDelay = 700, buzCount = 0 , sendByte = 0 
> var byte temp1 = 0 
> FlashLED1 = 1 
> --------------------------------------------------- >>> interrupt >>> ---- 
> procedure ????? is  pragma  interrupt 
>     if ????? then 
>         block 
>             -- if recevive 10 => set Out_2  ?????????????? 
>         end block 
>     end if 
> end procedure 
> ------------------------------------------------------------------- 
> forever loop 
> -----------------------     Buzzer 
>     if buzDelay < buzCount then 
>         buzCount = 0 
>     end if 
>     if 0 < buzCount then block 
>       Buzzer1 = 1 
>         buzCount = buzCount + 1 
>      end block 
>     else 
>       Buzzer1 = 0 
>     end if 
> -----------------------     btn1 
>     if in1 == 1 then 
>       btnDelay_1 =    btnDelay_1 + 1 
>     else 
>       btnDelay_1 = 0 
>     end if 
>     if btnDelay < btnDelay_1 then block 
>         buzCount = 1 
>       btnDelay_1 = 0 
>       Out_1 = 0 
>       -- send Data to USART ????????????????? 
>      end block 
>     end if 
> --------------------------------------------------     
>     if n < 8000 then block 
>       n = n + 1 
>      end block 
>     else block 
>         n = 0 
>         FlashLED1 = ! FlashLED1 
>    end block 
>     end if 
> ----------------------- 
> end loop 
> ----------------------------------------------------------- 
>
>
> please help or guide me 
>
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "jallib" group. 
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected]. 
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jallib/b69ef4ed-22dc-45d7-b710-f616ad6f3ed0n%40googlegroups.com.
>  
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "jallib" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jallib/667d11e7-254f-43bc-84bf-abed4acfc813n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jallib/667d11e7-254f-43bc-84bf-abed4acfc813n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "jallib" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jallib/0c4eadcc-45ed-4109-8dbe-aefc37f7ececn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jallib/0c4eadcc-45ed-4109-8dbe-aefc37f7ececn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/bfde65b2-b272-4a10-972a-72433dc85ef1n%40googlegroups.com.

Reply via email to