I'm using the basic method you are using but sending the data out to a multimedia card rather than a compact flash. The data is in FAT format and I'm using a 16F648 with the internal osc and running the serial at 19.2K. I don't have any lost bytes. For my interrupt routine I put the uart data in a 80 byte circular buffer. The main routine sends the data to the mmc as well as parses the data for display. I make sure that I call the save mmc routine regularly so I don't overflow the buffer. I initially tried sending the data in the interrupt to the mmc but there are periods where the mmc has to wait several ms while the data internal to mmc is flashed. This delay caused uart overruns because the interrupt routine was waiting for the mmc rather than returning and picking up the next uart byte. I strongly suspect that your CF code is just too slow. I can write to the mmc card at about 50k bits/sec which is on the order of 2+ times the uart speed. You should benchmark your CF code to see what speed you can send data to your card. I don't know why people use CF. I thought that it used lots of data lines. MMC is just a spi interface and takes 4 pic pins. Regards, Gordon Williams ----- Original Message ----- From: "Padu" To: "Microcontroller discussion list - Public." Sent: Friday, November 12, 2004 2:05 AM Subject: [PIC]: Interrupt vs. Main loop I'm facing a conceptual dilemma, many of the gurus here and elsewhere recommend to keep interrupt code to a minimum. That's what I'm trying to do, but I'm having some serious problems to transfer data gathered at the interrupt procedure and use it on the main loop. The interrup is receiving a constant stream of UART data at 19200baud (it will be faster as soon as I get the appropriate crystal). What I have to do is to interface with my compactflash card and store each one of those bytes in it. I intend to store data as FAT files (I know, 512 bytes blocks). Thing is when I'm trying to process something on the main loop, things are coming at a faster rate on the interrupt. One thing I've tried was to setup a circular list of 64 bytes, push data on the interrupt and pop it on the main loop, it didn't work. Then I've increased the circular buffer size to 128, then I started to see some of the expected bytes on my CF (actually I'm sending them via USART to the PC just to test, but I'll replace to writing to the CF later). When I increased to 255, then almost got it, but still the interrupt was winning the race. I feel that if I had a big enough buffer, eventually it would work out, but perhaps there is a better way to solve it. Should I put all my CF writing code in the interrupt procedure? Would I be risking to get overrun errors? I have to confess, I'm enjoying learning all these new things about PIC and electronics, but sometimes it's frustrating, things don't happen at the same speed of software development... or I'm too impatient to be a newbie again. Thanks again! Padu _______________________________________________ http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist _______________________________________________ http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist