Logger to USB stick running on KL25Z

Dependencies:   F401RE-USBHost FastAnalogIn RTC mbed tsi_sensor2 mbed-rtos2

Fork of ReadSendData by Stuart Scott

Homepage for kXX_logger(was kl25x_usb_logger)

2014Nov12 - Added TSI - only works for kl25z, and fails after 4287seconds

Tests sequences for freezing 4287seconds 4287 4287 - Changed to USB write update every two seconds and lasted 4283seconds. Added mbed TSI_sensor - kudos to mbed as it turns out to be complex to do capacitive touch sensing. Kinetis L series Cortex-M0 (kl25z) has simpler capacitive sensing hardware which mbed/TSI_sensor lib uses, but doesn't support Cortex-M4 versions. K20D is older more complex interface. TSS hasn't had an open source support by Freescale in the past however that has changed. Currently I found KDS1.1.1 has a Processor Expert TSSlib that can be imported - but I'm getting a weird compile/include error - and not found any examples of how to make it work.

2014Oct05 - Published simple kl25z_usb_logger

Testing: Version (2:f06fbf86887e) has run over 28days starting 2014Sept07, reading a sensor data every seconds and then on the USB stick open file, write record, close file

This is over 2,419,200seconds ( 28days*24hrs*3600seconds) The stick data reflected 2,447,633 seconds, but only had 1,776,366 data records. After 407,650 data records started missing updates - analysis: the file could not be opened and read to the end in the allocated 1 second, and therefore missed the next ADC deadline.

By the end of the test period with 1,776,366 records on the USB Stick, ever read then write was causing it to miss two/three ADC updates - ie taking longer than two seconds.

Analysis: this was an aggressive test, and normally would not be opening, writing, closing every 1 second. However big plus the file mechanism held up and the program continued to operate, with a graceful failure of a missed ADC readings. The output used JSON, which reads nicely but turns out not to be supported by Excel (2014?) I was using.

Conclusion: Overall the USB Mechanisms and file read is stable. However the USB stack used doesn't have an event based management for stick insertion and removal, or OTG power management . This KL25Z has been a very useful test to prove the configuration of clocks for USB Stack is possible and stable. The target processor being looked at is the MK20 and is similar in clocks, but slightly more comprehensive USB OTG Next step is to investigate the full Freescale Kinetis USB OTG Stack with power management on a custom K20 board, using Kinetis Design Studio, and very low power capability.

Example https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/FRDM-K20D50M/FRDM-K20_MSD_Host http://mcuoneclipse.com/2014/10/25/usb-cdc-with-the-frdm-k64f-finally/#comment-37727 - Commentary on Freescale USB versions

Committer:
neilh20
Date:
Tue May 19 16:03:50 2015 +0000
Revision:
15:91ef840c442c
Initial pub to share

Who changed what in which revision?

UserRevisionLine numberNew contents of line
neilh20 15:91ef840c442c 1 /*
neilh20 15:91ef840c442c 2 Custom board descriptions
neilh20 15:91ef840c442c 3 */
neilh20 15:91ef840c442c 4 #ifdef BOARD_CUST_H
neilh20 15:91ef840c442c 5 #define BOARD_CUST_H
neilh20 15:91ef840c442c 6 /* CustomMK20DX128
neilh20 15:91ef840c442c 7 Customer Visible interfaces - NH B022_Rev1
neilh20 15:91ef840c442c 8
neilh20 15:91ef840c442c 9 //R-Bridge sensor
neilh20 15:91ef840c442c 10 DacOut senseRaDrv (connected electrically ADC_DP0)
neilh20 15:91ef840c442c 11 ADC0_DP0 adcDiffInP0
neilh20 15:91ef840c442c 12 ADC0_DM0 adcDiffInP1 senseRbAdcP
neilh20 15:91ef840c442c 13
neilh20 15:91ef840c442c 14 ptB1 adcIn adcTemperature1
neilh20 15:91ef840c442c 15 ptB2 adcIn adcTemperature2
neilh20 15:91ef840c442c 16 ptB0 adcIn adcAir
neilh20 15:91ef840c442c 17 ptB16 out CustLedRed
neilh20 15:91ef840c442c 18 ptB17 out CustLedGrn
neilh20 15:91ef840c442c 19 ptB18 cap capSens1
neilh20 15:91ef840c442c 20 ptB19 cap capSens2
neilh20 15:91ef840c442c 21 */
neilh20 15:91ef840c442c 22
neilh20 15:91ef840c442c 23 /* Internal LiIon management interfaces
neilh20 15:91ef840c442c 24 ptA13 digOut enExtBat
neilh20 15:91ef840c442c 25 ptB3 adcIn adcVrechargeBat
neilh20 15:91ef840c442c 26 ADC0_DP3 adcIn adcRbatP
neilh20 15:91ef840c442c 27 ADC0_DM3 adcIn adcRbatM
neilh20 15:91ef840c442c 28
neilh20 15:91ef840c442c 29 ptc0 adcIn adc10Vbat
neilh20 15:91ef840c442c 30 ptC1 spare
neilh20 15:91ef840c442c 31 */
neilh20 15:91ef840c442c 32 /* External Power Management
neilh20 15:91ef840c442c 33 ptC2 adcIn adcVextIn
neilh20 15:91ef840c442c 34 ptC8 adcIn adc10Vslr
neilh20 15:91ef840c442c 35 */
neilh20 15:91ef840c442c 36
neilh20 15:91ef840c442c 37 /* Serial North Bound Interfaces
neilh20 15:91ef840c442c 38 Shared Uart1Tx Halfduplex
neilh20 15:91ef840c442c 39 enSdiTx
neilh20 15:91ef840c442c 40 enSdiRx
neilh20 15:91ef840c442c 41 enWire1Tx
neilh20 15:91ef840c442c 42 enWire1Rx
neilh20 15:91ef840c442c 43 */
neilh20 15:91ef840c442c 44
neilh20 15:91ef840c442c 45 /* USB OTG
neilh20 15:91ef840c442c 46 Vusb (input to cmpUSB
neilh20 15:91ef840c442c 47 UsbDM
neilh20 15:91ef840c442c 48 UsbDP
neilh20 15:91ef840c442c 49 UsbOtg_Id
neilh20 15:91ef840c442c 50 */
neilh20 15:91ef840c442c 51
neilh20 15:91ef840c442c 52 /* External Two FLASH chips.
neilh20 15:91ef840c442c 53 ptc3 C4 C5 C6 C7
neilh20 15:91ef840c442c 54 */
neilh20 15:91ef840c442c 55
neilh20 15:91ef840c442c 56 /*Debug Serial Interafaces
neilh20 15:91ef840c442c 57 either JTAG or openSDA
neilh20 15:91ef840c442c 58 ptA0 SWD_CLK
neilh20 15:91ef840c442c 59 pta1 Uart0RxDebug
neilh20 15:91ef840c442c 60 pta2 Uart0RxDebug
neilh20 15:91ef840c442c 61 pta3 SWD_DI0
neilh20 15:91ef840c442c 62 */
neilh20 15:91ef840c442c 63
neilh20 15:91ef840c442c 64
neilh20 15:91ef840c442c 65 #endif // BOARD_CUST_H