 |
 |
| View previous topic :: View next topic |
| Author |
Message |
bkamen
Joined: 07 Jan 2004 Posts: 1619 Location: Central Illinois, USA
|
|
Posted: Mon Aug 30, 2010 4:32 pm |
|
|
Post a short example of your code as it stands now.
We'd like to see the primary setup (#fuses and #use delay and such) as well as the beef of main() and then your ISR's and possible the code that does the processing.
I've never had the problem you describe -- and I have routines that are busy spinning other loops without missing serial data.
The thing I'm going to look for first is:
* Are you processing your data inside ISR's? If so: bad. That's not how you want to do it.
* The next is, are you disabling INT_RDA or INT_RDA2 at any point? You shouldn't be.
* Another would be: do you have any blocking/stalling loops or conditionals in either ISR? That won't work either.
The rest will come when we see your code.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
 |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Aug 30, 2010 4:43 pm |
|
|
As bkamen said: You didn't post your latest software implementation so it is guessing for us where your problem might be.
For the receiving part it is good practice to implement an interrupt driven circular buffer. You showed this in your first post and I assume this is still in place?
The transmit FIFO buffer in the hardware UART is very small (1 byte) so here it is good practice to implement an interrupt driven circular buffer as well. Do you have this? An example implementation is shown in the ex_stisr.c (as opposed to ex_sisr.c for the receiving part). |
|
 |
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Tue Aug 31, 2010 4:16 am |
|
|
thnx, I will do but I need to trim it because it is just one big rubbish bag now...
PS. I think it may be related to speed 115200, it maybe just to much to be handled properly by mpu on both ports. _________________ Help "d" others and then you shell receive some help from "d" others. |
|
 |
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Tue Aug 31, 2010 6:48 am |
|
|
Gentleman,
I have found my problem, first it was loading getc into string directly, second I had a bug in my decryption protocol. Now all is working well.
This works,
| Code: | c = fgetc(bus);
temp_capture[next_in_bus] = c;
|
this not,
| Code: | temp_capture[next_in_bus] = fgetc(bus);
|
-----------------------------
I have one more question,
"setup_uart or set_uart_speed" is it permanent change or is it executed only once after it is called and then goes back to default in the RS232 settings? I want to get possibility to change speeds dynamically and my rs looks like this:
| Code: |
#use rs232(uart1,baud=115200,xmit=Tx_Out,rcv=Rx_In,parity=N,bits=8,stop=1,stream=bus,restart_wdt,errors,TIMEOUT=5)
|
So I did simple switch:
| Code: |
char set57600[] = "#set57600";
if (strncmp(rx_eth_buffer_decrypted,set57600,9) == 0) {
set_uart_speed(57600,bus);
fprintf(eth,"Bus set to 57600\n");
}
|
But this seems to be working only once and then goes back to the speed in #use rs232 function.
Thank you for your help. _________________ Help "d" others and then you shell receive some help from "d" others. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20159
|
|
Posted: Tue Aug 31, 2010 8:25 am |
|
|
Depends 'where' your USE_RS232 is placed.
If it is placed outside the program as part of the header (normal location), then the change should be permanent.
However, if you have the #use statement, somewhere inside your code, and it gets 'passed' again by the code flow, then the value will be reset. This was the 'old' way of changing baud rates (multiple #use statements, and routing the code past the one that was wanted).
Also remember that with a hardware UART, if you have multiple streams accessing the single UART, with different names, and call another stream, this will change the baud rate.
Best Wishes |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|