I recently purchased flowcode 4 for PIC controllers (using it for the ECIO40).
Currently my aim is to get the serialUSB working with interrupts since the PC side is easy in this approach (in a first step hyperterminal or TerraTerm are enough to get communication).
Unfortunately I couldn't find documents on USBINT in combination with serialUSB, so I just started flowcharting
In my first application I'm trying to make a led (on portpin B0) blink with delays, which I can change through USB communication.
For this I enabled the USBINT and assigned a macro.
In the macro I was wanting to readout with de ReadString function.
Afer Stringmanipulation (first 3 chars should tell what I want to do StD= SetDelay), I should e able to retrieve the delay to set and put it in the right variable.
When using a Readstring in my interrupt, the application seemed to freeze.
Because of this I decided to do following first:
- flag initialization to ensure there is no usb reading when an interrupt should take place during initialization (I think that shouldn't be necessary at all). After initialization I set Initial to 1. To ensure initialization has its time I added 2 second delays (which shouldn't be necessary either)
- I removed the reading function and replaced the part to set the delay with an increment of an int counter. I didn't take any overflow precautions, so when overflowing, the thing turn negative (but that's none of my concerns at the moment)
- in the main I have a while loop, which makes the led blink and which sends at start of the loop the countervalue.
When viewing the received values at my PC, I get an increment of about 2000 every cycle.. the delay is set to 1 second and takes place two times per cycle. this means an USBint handling every msec.... so I'm doing something very wrong
Is it possible I should say the received interrupt is handled after handling it ? I got the feeling the reading data makes things worse and causes the ecio to get to busy with interrupt handling.
Kind regards
Maarten