News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

problem RS485 read data.

Started by krizpin, Aug 18, 2021, 09:59 PM

Previous topic - Next topic

krizpin

Hi all. I am trying to read the packages that travel by the bus of the domotica that I have installed at home and I am not able to do it. the communication system is based on rs485. my problem is that the shipments are so continuous that I cannot capture the packets properly. I know that the protocol used by the installation sends 10-byte packets but the problem is that the second section of packets is sent practically often and I think I understand that my pic generates the interrupt jump so fast that it crushes the packets received previously. I leave you a screenshot of the data frame that is sent to see if you can help me with the code. Thanks a lot
I always capture the last 10 bytes and they are the only ones I can see

           
            If bandera_usart2=1 Then
                HSerIn2 120,salir,[Str busing]
           
                EndIf
                   
                         
salir:         
           Context Restore




I use the hserCaptura.PNGin2 function but I can't get it to work correctly

normnet

Capture the data to a buffer and process it when a bit of time is available.  Displaying the data will be slow so avoid if possible.

shantanu@india

Don't use Hserin inside interrupt service routine....just read RCREG and store it in  an array so that the interrupt flag is cleared and you can read the next byte when it arrives. Be clear about the size of your Rx buffer and the expected size of your packets. I hope you are using 18F
Regards
Shantanu

krizpin

#3
good morning. I try to read RCREG but I can't because when reading it and storing it in an array it is blank. I suppose that I have to configure some registry etc but I have not been able to do it.
Please can you show me an example of code to read the RCREG ??? Thank you

joesaliba

Check in the samples folder for a code example `Buffered HRsin'.

That is what you need.

Joe

krizpin

ok thanks I tried looking for it but I can't find it ...

normnet

C:\Users\normnet\PDS\Samples\New Samples\Buffered_Hrsin\Buffered_Hserin_Test.bas
Replace normnet with user on your PC. 

Or in FineLine simply: File > Open Samples Directory's > New Samples\Buffered_Hrsin\Buffered_Hserin_Test.bas

krizpin


John Lawton

Why is this topic under Forum Rules??

John Drew

Good point John,
I've moved it. Mistakes happen :)
John

John Lawton

Quote from: John Drew on Sep 01, 2021, 12:48 PMGood point John,
I've moved it. Mistakes happen :)
John
It's okay John, I won't call for your sacking just yet :)