Use PIC18F25K22 with two serials and interrupt reception, it seems that the USART1 does not receive anything, the input signal is present. The transmission instead seems correct, I don't understand where I'm wrong, can you give me some help?
I do not think your approach will work. You will need a ring buffer for both USARTs
Something like this. There are two buffers and in the buffer you simply load the buffer - DO NOT hserprint the incoming data... you dont have time to do that before the next char is in arriving.
I thank you for your great availability as always, you are right that to do a good job you have to create a buffer that I have already done and it works well, but there is something that does not convince me using the serial in a simple way. This code, for example, looks very simple, but it doesn't work, I use PIC16F628 just text transmission I don't think it works, I don't understand why.
Thanks for your great help
'''A demonstration program for EUSART'''--------------------------------------------------------------------------------------------------------------------------------'''********************************************************************************; ----- Configuration#chip 16f628,8#option explicit; ----- Define USART settings#define USART1_BAUD_RATE 38400#define USART1_TX_BLOCKING' -- temp vardim Tmp0,Temp,I_tmp as bytedim Tmp1 as bytedim N_pan as byte ' pannello attivodim tempw,tempw1 as word; ----- Define Hardware settings 'Set pin directions Dir PORTB.2 Out ' TX USART seriale Dir PORTB.1 In ' RX USART dir portb.3 out dir portb.0 In; ----- Main body of program commences here. Wait 100 Ms 'Message after resetdo portb.3= ! portb.3 hserprint "Test-" wait 1 SLoop
Last edit: Anobium 2019-05-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
TYPO...... #define USART1xxxx should be #define USARTxxxxxx
Works on test here. Read the datasheet... the error % at 38400 could be very large but it still is workable on test there.
I only had a 20mhz osc to hand, so, please change the frequency.
Evan
'''A demonstration program for EUSART'''--------------------------------------------------------------------------------------------------------------------------------'''********************************************************************************; ----- Configuration#chip 16f628,20#option explicit; ----- Define USART settings 'USART settings #define USART_BAUD_RATE 38400 #define USART_TX_BLOCKING' -- temp vardim Tmp0,Temp,I_tmp as bytedim Tmp1 as bytedim N_pan as byte ' pannello attivodim tempw,tempw1 as word; ----- Define Hardware settings 'Set pin directions Dir PORTB.2 Out ' TX USART seriale Dir PORTB.1 In ' RX USART dir portb.3 out dir portb.0 In; ----- Main body of program commences here. Wait 100 Ms 'Message after resetdo portb.3= ! portb.3 hserprint "Test-" wait 1 SLoop
I'm doing some tests, a use is the transmission of various information to a PC or other device, I have already done other times with the software serial and it works well but should also go into hardware. If it is not possible I manage the logs manually it is not a very difficult job, I have already done some time ago I still have code in PicBasic.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Use PIC18F25K22 with two serials and interrupt reception, it seems that the USART1 does not receive anything, the input signal is present. The transmission instead seems correct, I don't understand where I'm wrong, can you give me some help?
I do not think your approach will work. You will need a ring buffer for both USARTs
Something like this. There are two buffers and in the buffer you simply load the buffer - DO NOT hserprint the incoming data... you dont have time to do that before the next char is in arriving.
Adapt as you need.
I thank you for your great availability as always, you are right that to do a good job you have to create a buffer that I have already done and it works well, but there is something that does not convince me using the serial in a simple way. This code, for example, looks very simple, but it doesn't work, I use PIC16F628 just text transmission I don't think it works, I don't understand why.
Thanks for your great help
Last edit: Anobium 2019-05-01
What is the target of this serial transmission?
TYPO...... #define USART1xxxx should be #define USARTxxxxxx
Works on test here. Read the datasheet... the error % at 38400 could be very large but it still is workable on test there.
I only had a 20mhz osc to hand, so, please change the frequency.
Evan
Looks like this on the PC Terminal
Last edit: Anobium 2019-05-01
I'm doing some tests, a use is the transmission of various information to a PC or other device, I have already done other times with the software serial and it works well but should also go into hardware. If it is not possible I manage the logs manually it is not a very difficult job, I have already done some time ago I still have code in PicBasic.
See my post... you have a typo.
Perfect I tried, it works well. !!!!!!!!!!!!!!!
Thank you