Comments (8)
I have a majorly rewritten wiring_time and tone modules that works with above example (modified for remaining variables.
Running the task loop with FOUR tone signals and multiple calls to delay with some rough timing tests gives one pass through scheduler loop and run the call back tasks with execution times ranging from
5 to 20 microseconds, Depenfing on number of tasks in each loop pass
Leaving most of the 1 ms available for other processing in user code. The code is adaptable and changing new define in pins_arduino.h for a specific processor for example from 4 to 8 will ripple through all files. This may be useful for those using XMC4xxx series.
Unfortuantely to be compliant with Arduino delay() and its knock on effects the interval or delay time is uint32_t, so we could sit there for 50 years if required. There are better ways to do that in software and hardware.
More on serial startup delay, serial and analogRead interaction when I get to chase that down.
This patch and a few others hopefully will be pushed later this week.
As this is a major change there is a LOT of comments especially in wiring_time.c This is the extra added at the top of the file
/* Includes Co-operative Scheduler for XMC-for-Arduino
Using COMPILE time scheduling table
Version V1.00
Author: Paul Carpenter, PC Services, <[email protected]>
Date March 2018
Co-operative scheduler library that has some support functions and main
schedule function meant to be run as the Systick scheduler event handler, the
support functions should be used to get status on, start, stop, or configure tasks.
The schedule code is designed for MINIMAL overhead and SPEED.
The time interval of calling the schedule loop is determined by Systick timer
interval currently 1 ms, and calls a selection of tasks determined by two
parameters for each task
callback function address
parameter INTEGER to pass to function
From this we get TWO types of function calls when a task event happens
1/ callback and parameter are set gives a function call of
int callback( int ID, int16_t param )
function to use as this task that accepts TWO integer parameters
and MUST return an integer
(even if parameter not set it is initialised to task_id AT compile TIME)
2/ Special case if ANY task has its callback set to NULL a special variable
in wiring_time is set to TRUE. This enables the delay() function to work
for ms delays. As a side effect it stops runaway tasks for callback set to
NULL.
Callback functions in list
--------------------------
For different processors speeds it is suggested to keep the number of
total tasks (callback functions) to following limits -
Speed Max Tasks
< 50 MHz 8
> 50 MHz < 100 MHz 12
> 100 MHz 16
Callback function structure
---------------------------
Task is actually calling a function that should be defined as
function that returns int and takes TWO integer parameter
e.g. int func( int TaskId, (int16_t Parameter )
First parameter is TaskId,
Second parameter is user defined parameter (int16_t)
If interval of a task has to change call setInterval during task execution
NOT to STOP task use return code
Callback functions Contents
---------------------------
Callback functions are effectively interrupt routines so care should be taken
about which variables and flags set in these functions are volatiles.
Functions MUST be VERY SMALL as many tasks have to run in less than 1 ms as
well as the main code.
Do NOT use blocking or slow callbacks that use AT LEAST the following Ardunio
functions
delay (this would become recursive)
.print, .write, println on Serial or Liquid Crystal
analogread
PulseIn
Liquid Crystal ANY function
I2C or SPI ANY function
SD/MMC ANY function
All of these and maybe others are SLOW, block waiting for I/O or time
delays often MUCH longer than 1 ms
Callback Function Return value
------------------------------
The returned value is the NEW status for that task which tells scheduler
what to do next time. Values are
< 0 User error status (stops task execution)
0 Task stopped (if needed to be run will have to be started by Start)
> 0 Next status this can be used by call back function for state machines
Task runs again at the interval set
Scheduling Functions
--------------------
setInterval Set a task's NEW interval and schedule new time from now if not
already running
getInterval Get a task's interval
setParam Set a task's callback function parameter (signed int16_t)
getParam Get a task's callback function parameter (signed int16_t)
getTime Get a task's next time to execute
getStatus Get a particular task status word
StartTask Start a task (if not already running)
FindID get ID of first task from task address
*/
from xmc-for-arduino.
See Pull #42 for results for wiring_time
Delaymicroseconds is one of next tasks
from xmc-for-arduino.
Currently the serial side of needing a delay after serial.begin before using the serial port, is looking like somewhere in the USB debugger, programmer changeover to serial port mode, or host side.
Resurrecting a TTL to RS232 converter to use a real serial port and do side by side coimparisons.
from xmc-for-arduino.
Tests confirm having to put a delay before using serial functions after a begin is debugger or further up.
When using a putty session on a real com port alonside the arduino IDE serial monitor the USB vcersion is corrupted. The Arduino IDE is one of the few serial monitors that will stay running while programming or power cycling the unit (XMC1100 boot kit). Most close when USB serial port disappears.
Screen shots of WithDelay
Screen shot of NoDelay
This needs to be looked at by different folks who understand the Segger Jlink and debugger and possibly the Arduino interface to that for changing over to allow serial.
from xmc-for-arduino.
Further tests indicate the issue is related to integration of programmer and virtual com into IDE for serial monitor. Possibly with how the IDE sends target resets and does not check responses or timesout expecting a set sequence to occur then messes up.
from xmc-for-arduino.
Further evidence there is a problem between the Virtual COM driver and/or the Segger JLink when coming out of programme mode Basically a stream of garbage characters after programme mode before the micro is reset
the images are of side by side views from USB port (COM30) and a TTL converter on COM2.
First using Arduino Serial Monitor,
from xmc-for-arduino.
Sorry for replying with such a delay - I had this issue on my agenda, but forgot to reply.
I am facing currently some more issues with the VCOM port - do these issues still persist on your side?
Just would like to get a fresh update for next steps.
Thank you very much and best regards,
Manuel
from xmc-for-arduino.
Just back in I will look at doing same tests again as soon as possible.
from xmc-for-arduino.
Related Issues (20)
- a bug for chinese user HOT 10
- RS485 Modbus library throwing errors HOT 6
- Chose board to flash by port HOT 1
- Multiple definition of CCU40_0_IRQHandler HOT 1
- Poor voltage amplitude on RX pin HOT 4
- J-Link Debug HOT 1
- XMC Flasher not working HOT 4
- XMC2Go: Wire.begin() sends I2C start condition HOT 18
- Can not connect xmc2go to arduino ide HOT 2
- Only SPI or I2C? HOT 1
- Defining SERIAL_ONBOARD raises error HOT 4
- onboard serial not working HOT 1
- Update xmc2go Wiki with onboard serial information HOT 4
- XMC1100 2GO I2C unresponsive
- map() definition conflicts with STL version HOT 2
- Flashing failed: Failed to initialize BridJ error on MacOS HOT 4
- incorrect way to open application with python HOT 5
- Winreg required, not available on Linux HOT 2
- XMC1300 Boot Kit: Missing link for Arduino pinout HOT 3
- serial.write function seems to freeze the program after a certain time. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xmc-for-arduino.