For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.
Hi Guys,
I have been trying to use microsecond (us) delays, I understand the accuracy warnings and implications but i see the following
"Caution: argument of 'delay_us' calls must have a value of 1 or more" any time us delay is used. Is the delay value getting passed to the delay correctly?
This might explain why my prototype is not working...
The error is produced even with a 1 icon fcode of just a 100us delay.
Thanks Andy
The value you are getting suggests an overall delay of 12.4us every cycle.
Are you using the 19.6608MHz clock onboard the dev board and have you specified this in Flowcode.
The logic to control the loop and the output commands will take a little amount of time so you will not get an exact frequency however I wouldn't have thought it would be that much lower. If you need to output an exact frequency then maybe using a timer interrupt would be a better option.
As I mentioned before there is an overhead for switching on and off leds and for jumping back to the start of the loop which will mean that your timings are not exact.
One way around this is to use a timer interrupt. This way you will not need any delay icons and your output frequency will be much easier to get right.
Try this attached program, it should give you a very solid output of 4800hz.
Hi Ben and Steve,
Thanks for the reply and info...
Whilst I understand there is an overhead, these seem far too excessive?
e.g. I believe the chip is capable of almost 5 MIPs - therefore not being able to perform a simple on/off Flowcode loop at say 125 KHz seems to indicate something is very inefficient? What other Flowcode instructions are being added to the final machine code and why?
My problem is that I am trying to generate an almost fully packed RS485 signal at 250k baud,
If I use the interrupts to trigger the start of each word, how can I successfully space the bits without using (accurate) delays?
I don’t think I can use the UART because generation of special breaks and marks are required. Also I am now not confident that Flowcode will get the data to the UART quick enough (9 databit mode due to needing and extra stop bit)?
Please advise on how to solve this situation with Flowcode?
I have done some testing with an 16F877A running at 19.6608MHz using the attached test program and have found the following.
uS Delay : 1
Delay Period : 4.5us
uS Delay : 2
Delay Period : 6us
uS Delay : 30
Delay Period : 35us
I then switched to the Hi Tech C compiler and repeated the testing.
uS Delay : 1
Delay Period : 7us
uS Delay : 2
Delay Period : 10.5us
uS Delay : 30
Delay Period : 105us ???
I then switched back to BoostC and used an ECIO running at 48MHz (12MIPS)
uS Delay : 1
Delay Period : 2.6us
uS Delay : 2
Delay Period : 3.75us
uS Delay : 30
Delay Period : 32us
So my conclusion is to either use a faster device like the ECIO or another 48MHz PIC. Or alternativly you could use an AVR as these run around 4 x faster then a PIC running at the same clock speed. A 48MHz PIC can process 12 MIPS, a 20MHz AVR can process 20 MIPS.