// random RNG
#define PRREG(x) Serial.print(#x" 0x"); Serial.println(x,HEX)
#define REPS 50
#define RNG_CR_GO_MASK 0x1u
#define RNG_CR_HA_MASK 0x2u
#define RNG_CR_INTM_MASK 0x4u
#define RNG_CR_CLRI_MASK 0x8u
#define RNG_CR_SLP_MASK 0x10u
#define RNG_SR_OREG_LVL_MASK 0xFF00u
#define RNG_SR_OREG_LVL_SHIFT 8
#define RNG_SR_OREG_LVL(x) (((uint32_t)(((uint32_t)(x))<<RNG_SR_OREG_LVL_SHIFT))&RNG_SR_OREG_LVL_MASK)
#define SIM_SCGC6_RNGA ((uint32_t)0x00000200)
//#define Serial Serial1
uint32_t trng(){
RNG_CR |= RNG_CR_GO_MASK;
while((RNG_SR & RNG_SR_OREG_LVL(0xF)) == 0); // wait
return RNG_OR;
}
void setup() {
Serial.begin(9600);
Serial.println("hello"); delay(2000);
SIM_SCGC6 |= SIM_SCGC6_RNGA; // enable RNG
PRREG(SIM_SCGC6);
RNG_CR &= ~RNG_CR_SLP_MASK;
RNG_CR |= RNG_CR_HA_MASK; // high assurance, not needed
PRREG(RNG_CR);
PRREG(RNG_SR);
}
void loop() {
uint32_t t, r;
int i;
t=micros();
for(i=0;i<REPS;i++) r=trng();
t=micros()-t;
float bps = REPS*32.e6/t;
Serial.println(bps,2);
Serial.println(r,HEX);
delay(2000);
}
If anyone wants to dig into the details, the K66 has a large 8K cache. I honestly haven't even looked into whether it's even enabled. I'm mostly focused on getting code working correctly.... so by all means, play with this performance stuff I haven't even touched.
EDIT: also curious whether FASTRUN makes a big difference?
latency_test /dev/ttyACM0
port /dev/ttyACM0 opened
waiting for board to be ready:
.ok
latency @ 1 bytes: 0.14 ms average, 0.85 maximum
latency @ 2 bytes: 0.13 ms average, 0.54 maximum
latency @ 12 bytes: 0.16 ms average, 1.58 maximum
latency @ 30 bytes: 0.16 ms average, 0.41 maximum
latency @ 62 bytes: 0.28 ms average, 1.76 maximum
latency @ 71 bytes: 0.29 ms average, 1.69 maximum
latency @ 128 bytes: 0.39 ms average, 1.42 maximum
latency @ 500 bytes: 1.02 ms average, 2.52 maximum
latency @ 1000 bytes: 1.77 ms average, 2.85 maximum
latency @ 2000 bytes: 3.25 ms average, 3.56 maximum
latency @ 4000 bytes: 6.38 ms average, 6.55 maximum
latency @ 8000 bytes: 12.63 ms average, 13.04 maximum
receive_test /dev/ttyACM0
port /dev/ttyACM0 opened
ignoring startup buffering...
ignoring startup buffering...
ignoring startup buffering...
...
Bytes per second = 1023437
Bytes per second = 1023507
Average bytes per second = 1023484
random number generator, @180mhz, you get 7.7 million random bits/second
RNG_CR &= ~RNG_CR_SLP_MASK;
Is this the code as you used it? Cut and pasted and never runs past:Code:RNG_CR &= ~RNG_CR_SLP_MASK;
Note: I moved to Serial from Serial1. Was Serial1 used just to hit 180MHz?
Did you patch kinetis.h as indicated? (Serial1 was for running at 180mhz)
teensy35.menu.speed.180opt=180 MHz optimized [B](No USB)[/B]
C:...\teensytransfer>teensytransfer.exe -e
........................................
C:...\teensytransfer>teensytransfer.exe -i > 1.txt
C:...\teensytransfer>teensytransfer.exe -i teensy > 2.txt
C:...\teensytransfer>teensytransfer.exe -w 1.txt
.
C:...\teensytransfer>teensytransfer.exe -w 2.txt
.
C:...\teensytransfer>teensytransfer.exe -l
71 1.txt
164 2.txt
C:...\teensytransfer>teensytransfer.exe -r 1.txt
ID : EF 40 17
Serial: D1 65 38 25 47 25 39 2F
Size : 8388608 Bytes
C:...\teensytransfer>teensytransfer.exe -r 2.txt
Model : ?? (MK66FX1M0)
Serial: 327680
MAC : 05:00:00:05:00:00
EEPROM: 4096 Bytes
F_CPU : 192000000 Hz
F_PLL : 192000000 Hz
F_BUS : 48000000 Hz
F_MEM : 27428571 Hz
Anyone see a pad labeled VBAT?
On the round 1 & 2 boards, the K66's VBAT pin is hard-wired to 3.3V.
The touch (TSI) registers for the K66 are very different than the teensy 3 TSI registers. So additional logic will have to be added to hardware/teensy/avr/cores/teensy3/touch.cmore pin tests:
touchRead() hangs ????
If anyone wants to dig into the details, the K66 has a large 8K cache. I honestly haven't even looked into whether it's even enabled. I'm mostly focused on getting code working correctly.... so by all means, play with this performance stuff I haven't even touched.
EDIT: also curious whether FASTRUN makes a big difference?
BenS: Perhaps your post #3 could list items tested to work? (links to posts)
> XPT2046_Touchscreen, RTC, ILI9341_t3, TFT_ILI9163C, RNG, SerialFlash, TeensyTransferTool as HI, OSC, PROP_LC
"Of course bit create clock varies with multiplier :: 96MHz, 144MHz to 192 MHz:: 6,106,870.00<< bps, but 120 MHz (like 180 MHz) :: varies 7,619,047.50 to 7,7294,68.50<< bps"
Ref manual says RNG generates 32 random bits every 256 ticks of the F_BUS clock
I can do that, but to be honest I lost track of who is testing what.
Teensy 3.2 K64 K66 K66 mbed K64 stm32l4 F469NI mega2560
@120mhz @120mhz @180mhz @120mhz @120mhz @80mhz @180mhz @16mhz
NXP/kalman 3396 358 250 367 368 535 315 30272 us
madgwick 223 7 7 10 8 8 6 2628
mahony 125 5 5 8 6 6 4 1548
Are the filters using the "0x5f3759df" fast inverse square root? Maybe that speed-for-accuracy optimization can be omitted on the K66.Another example of floating point hardware in float-intensive filters for prop shield IMU, (no sensor data collection). The NXP kalman filter is compiled with
#pragma GCC optimize ("O3")
Times are in microseconds
Code:T3.2@120mhz K66@180mhz NXP 3396 285 madgwick 223 7 mahony 125 3