printf - Implementation without interrupts using a co-operative scheduler

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

printf - Implementation without interrupts using a co-operative scheduler

627 Views
hmhr
Contributor I

Hi,

 

Using CW10.1 on Kinetis K60 TWR platform. I'm also using Processor Expert LDD for the UART, etc.

 

I'm building applications around a co-operative scheduler (only a tick interrupt is enabled to drive the scheduler).

 

I'm trying to use as much as possible standard functions such as "printf" due to the flexibility built in to achieve some basic messaging loging capability.

 

The trouble is that printf would not work when the UART interrupts are disabled, at least when being supported by the LDD functions provided for console UART by PE. Just enabling interrupts will spring printf back to life.

 

I guess the question is, how could I make printf "work" in a co-operative environment where UART interrupts are disabled?

The generic idea is to send some characters to the queue and "periodically" poll the device for sending one character (or a partial number) in the time slot allocated for the task. Then in the next tick come back and complete the task.

 

Any help is much appreciated.

Thanks,

0 Kudos
1 Reply

348 Views
PaulJ
Contributor II

You could 1) set up a timer interrupt for roughly a 1msec tick frequency, and place all your important calls in there, and 2) Put your diagnostic code that uses printf in your main loop -- in the non-interrupt world.

 

 

I'm current having trouble getting printf to work on my K60 tower using CW10.1.  Did you start with an example, or doumentation on how to get printf working?  Al I've done thus far is 1) implement the LDD called TWR_SER_K60_UART, setting it up for 115200, N,8,1 and making sure all interrupts are enabled and ISRs implemented, 2) Call the intialize code, and 3) Call printf("This is a test.").  I get nada.  Any ideas would be greatly appreciated.

0 Kudos