Benchmark Time (microseconds)
Screen fill 87690
Text 6410
Lines 36550
Horiz/Vert Lines 7300
Rectangles (outline) 4770
Rectangles (filled) 180500
Circles (filled) 35010
Circles (outline) 36470
Triangles (outline) 8480
Triangles (filled) 64100
Rounded rects (outline) 14140
Rounded rects (filled) 199420
Rectangles (filled) FB 20180
Rounded rects (filled) FB 22240
Thanks for confirmation - the Synchronization article didn't state any _isr - it read like it watched the actual var for write. Sample above updated to remove forced write in _isrYes, it triggers on any interrupt.
Re: systick, micros, GPT
Just one more thought on systick and micros. You could replace the core systick timing with GPT2 timer. GPTx has COMPARE register so can do the 1 ms tick interrupt, and the GPT clock is running at 24 mhz, so you get full resolution micros() and a clock independent of CPU clock.
Actually, I would like to see systick used at CPU clock speed, and systick reconfigured if user changes CPU clock speed ...
ccdelta = ARM_DWT_CYCCNT - systick_cycle_count;
usec = 1000 * systick_millis_count + (ccdelta / (F_CPU_ACTUAL / 1000000));
I don't know if you do that - in any case, here is an useful document, maybe interesting for others..When the related PLL is powered up from the power down state or made to go through a
relock cycle due to PLL regrogramming, it is required that the related PFDx_CLKGATE
bit in CCM_ANALOG_PFD_480n or CCM_ANALOG_PFD_528n, be cycled on and off
(1 to 0) after PLL lock. The PFDs can be in the clock gated state during PLL relock but
must be un-clock gated only after lock is achieved. See the engineering bulletin,
Configuration of Phase Fractional Dividers (EB790) at www.nxp.com for procedure
details.
Tim, my English sometimes makes it hard for me to follow you in the details...
Does that mean your code is now fully functional and shows no mismeasurements - or mismeasurements larger than micros() on T3.6?
Congratulations then
...
#define RFM69_IRQ 4 // "C"
#define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ )
pinMode(RFM69_RST, OUTPUT);
digitalWrite(RFM69_RST, LOW);
// manual reset
digitalWrite(RFM69_RST, HIGH);
delay(10);
digitalWrite(RFM69_RST, LOW);
delay(10);
#define RFM69_RST 3 // "A"
#define RFM69_CS 10 // "B"
#define RFM69_IRQ 2 // "C"
#define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ )
Tim, read my comment on github re:systick_safe_read ?
Post #1029 and Pull request updated
Mike - you just HAVE to try it out - it prints TEMP before each loop()! and as clock speed changes each three 10 second loops the temp drops/rises.
LED flashes - USB serial cryptic spew that tells (me) stuff. If an error occurs each line after will show that in case it scrolled off.
RADIOHEAD LIBRARY AND ADAFRUIT RF69 MODULE
When I tested the radiohead library using one of the supplier examples the module failed on initialization for the module. Looking at he Adafruit example for the module there are a couple of things they do that are not in the stock library example:
1. For the Teensy 3.1 they define the modules interrupt pin as:
2. They use a manual reset of the chip:Code:#define RFM69_IRQ 4 // "C" #define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ )
Code:pinMode(RFM69_RST, OUTPUT); digitalWrite(RFM69_RST, LOW); // manual reset digitalWrite(RFM69_RST, HIGH); delay(10); digitalWrite(RFM69_RST, LOW); delay(10);
Then the rest of the code is as it would be in the example. Doing it this way seems to work and the module inits and proceeds to listen. Have to hook the other one up to the T3.2 I have on the breadboard and make sure it actually is transmitting and receiving.
EDIT: Hooked up the other module to the T3.2 with the same construct and yes the are talking to each other. On the T3.2 the following config works:
If I switch pins 2 and 3 it doesn't work. Haven't tried it on the T4 yetCode:#define RFM69_RST 3 // "A" #define RFM69_CS 10 // "B" #define RFM69_IRQ 2 // "C" #define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ )
EDIT 2: Looks like I can move rst pin but the IRQ has to stay on 2. Not sure why? When I am more awake going to poke around the code.
// Set up interrupt handler
// Since there are a limited number of interrupt glue functions isr*() available,
// we can only support a limited number of devices simultaneously
// ON some devices, notably most Arduinos, the interrupt pin passed in is actuallt the
// interrupt number. You have to figure out the interruptnumber-to-interruptpin mapping
// yourself based on knwledge of what Arduino board you are running on.
#define RFM69_RST 3 // "A"
#define RFM69_CS 10 // "B"
#define RFM69_INT digitalPinToInterrupt(2 )
// Singleton instance of the radio driver
RH_RF69 rf69(RFM69_CS,RFM69_INT);
Assuming you are talking about your test case in post#1029 - will give it a try - fun watching what happens to the temperature as things change - at some point need to really stress the chip and see what the temp does
dd = rrN - usn;
if ( dd == 0 ) ;
else if ( dd == 1 ) nn++;
else if ( dd <= 2 ) // extra us ticks missed slower speeds
...
PFDs for PLL2 and PLL3:
- They have random, useless settings. The manual shows two different(!!!) "default" register values, both do not match the set values... (haha)
I created a pull-request to fix that for PLL2 (352, 594, 396, 297 MHz)
With PLL3, I have some problems.. something is not as it should be. Have asked Paul if he knows more..
This is also the reason why my assumed 144MHz for SPI are 72MHz in reality..- OK, found the Problem, but have no fix, yet.. should be easy as soon I know the reason for the "strange" PLL3
The exact PLL3 PFD freqs are:
PFD0: 720000000Hz
PFD1: 664615384Hz
PFD2: 508235294Hz
PFD3: 454736842Hz
Fix is here - without that the PFDs are not usable due to wrong settings: https://github.com/PaulStoffregen/cores/pull/335
System Clock: 600000000
IPG Clock: 150000000
Semc Clock: 200000000
RTC Clock: 32768
USB1pll Clock: 480000000
Peripheral Clock: 24000000
Osc Clock: 24000000
Arm Clock: 1200000000
Usb1PllPfd0 Clock: 720000000
Usb1PllPfd1 Clock: 664615368
Usb1PllPfd2 Clock: 508235292
Usb1PllPfd3 Clock: 454736826
Usb2Pll Clock: 24000000
SysPll Clock: 528000000
SysPllPfd0 Clock: 351999990
SysPllPfd1 Clock: 594000000
SysPllPfd2 Clock: 396000000
SysPllPfd3 Clock: 297000000
REASSIGNING ALT FUNCTIONS TO PINS 0 and 1 NOT WORKING
@Paul and others,
In post #996 I was able to reassign the pins (2, 3) to XBAR1 and read encoder values. As a test I tried to that this morning on pins 0 and 1 without any success, nothing being read! I made the pin pad and config changes by substituting 2 ->0 and 3->1, the IO numbers for pins 0,1 are IO16,17. Also checked the RM.
Not sure if there is something that I can't see that has locked the pin changes for 0,1? Right now this seems to be also affecting progress on Flexcan if they can't be changed.
00 GPIO_EMC_10_ALT3 — Selecting Pad: GPIO_EMC_10 for Mode: ALT3
01 GPIO_AD_B0_03_ALT0 — Selecting Pad: GPIO_AD_B0_03 for Mode: ALT0
10 GPIO_AD_B0_15_ALT6 — Selecting Pad: GPIO_AD_B0_15 for Mode: ALT6
11 GPIO_B1_09_ALT6 — Selecting Pad: GPIO_B1_09 for Mode: ALT6
All sequential functionality is controlled by the Bus Clock.
/* Set clock to use 24Mhz clock with a div by 1, pg 717
CCM_CSCMR2 = (CCM_CSCMR2 & 0xFFFFFC03) | CCM_CSCMR2_CAN_CLK_SEL(1) | CCM_CSCMR2_CAN_CLK_PODF(0);
//rx configure pin for flexcan, pg 1817
CORE_PIN0_CONFIG = 0x10; // 000 ALT0 — Select mux mode: ALT0 mux port: FLEXCAN2_RX of instance: flexcan2
IOMUXC_FLEXCAN2_RX_SELECT_INPUT = 0x01; //01 GPIO_AD_B0_03_ALT0 — Selecting Pad: GPIO_AD_B0_03 for Mode: ALT0, pg 2168
//pin1, can2TX B0_02
CORE_PIN1_CONFIG = 0x12;
//uint32_t fastio = IOMUXC_PAD_SRE | IOMUXC_PAD_DSE(3) | IOMUXC_PAD_SPEED(3);
CORE_PIN0_PADCONFIG = 0x10B0;
CORE_PIN1_PADCONFIG = 0x10B0; // 0x1A081, 0x10B0
Sorry, think I got you confused the Encoder is working on pins 2/3 not flexcan. Just tested the encoder sketch on pins 6 and 7 and its working there as well, just pins 0 and 1 are giving me a problem. Have two problems with pins 0 and 1. One is the encoder sketch is not working and second flexcan pins don't seem to enabled.Really appreciate the help, because I am stumped, especially with the encoder sketch that I know is working on pins 2/3 but not on pins 0/1.
FlexCAN_T4 Can1 = FlexCAN_T4(FLEXCAN1_BASE);
FlexCAN_T4 Can2 = FlexCAN_T4(FLEXCAN2_BASE);
FlexCAN_T4::FlexCAN_T4(uint32_t base) {
_baseAddress = base;
/* Set clock to use 24Mhz clock with a div by 1, pg 717*/
CCM_CSCMR2 = (CCM_CSCMR2 & 0xFFFFFC03) | CCM_CSCMR2_CAN_CLK_SEL(1) | CCM_CSCMR2_CAN_CLK_PODF(0);
//rx configure pin for flexcan, pg 1817
CORE_PIN0_CONFIG = 0x10; // 000 ALT0 — Select mux mode: ALT0 mux port: FLEXCAN2_RX of instance: flexcan2
IOMUXC_FLEXCAN2_RX_SELECT_INPUT = 0x01; //01 GPIO_AD_B0_03_ALT0 — Selecting Pad: GPIO_AD_B0_03 for Mode: ALT0, pg 2168
//pin1, can2TX B0_02
CORE_PIN1_CONFIG = 0x12;
//uint32_t fastio = IOMUXC_PAD_SRE | IOMUXC_PAD_DSE(3) | IOMUXC_PAD_SPEED(3);
CORE_PIN0_PADCONFIG = 0x10B0;
CORE_PIN1_PADCONFIG = 0x10B0; // 0x1A081, 0x10B0
if ( _baseAddress == FLEXCAN1_BASE ) {
_VectorsRam[16 + IRQ_CAN1] = can1_message_isr;
NVIC_IRQ = IRQ_CAN1;
CCM_CCGR0 |= (0xF << 14);
}
else if ( _baseAddress == FLEXCAN2_BASE ) {
_VectorsRam[16 + IRQ_CAN2] = can2_message_isr;
NVIC_IRQ = IRQ_CAN2;
CCM_CCGR0 |= (0xF << 18);
}
FLEXCANb_CTRL1(_baseAddress) |= FLEXCAN_CTRL_LOM; /* listen only mode enable */
FLEXCANb_MCR(_baseAddress) |= FLEXCAN_MCR_FRZ; /* enable freeze bit */
FLEXCANb_MCR(_baseAddress) &= ~FLEXCAN_MCR_MDIS; /* enable module */
while (FLEXCANb_MCR(_baseAddress) & FLEXCAN_MCR_LPM_ACK);
softReset(); /* reset bus */
while (!(FLEXCANb_MCR(_baseAddress) & FLEXCAN_MCR_FRZ_ACK));
FLEXCANb_MCR(_baseAddress) |= FLEXCAN_MCR_SRX_DIS; /* Disable self-reception */
disableFIFO();
disableFIFOInterrupt();
FLEXCANb_MCR(_baseAddress) |= FLEXCAN_MCR_IRMQ; // individual mailbox masking
FLEXCANb_MCR(_baseAddress) |= FLEXCAN_MCR_AEN; // TX ABORT FEATURE
FLEXCANb_MCR(_baseAddress) |= FLEXCAN_MCR_LPRIO_EN; // TX PRIORITY FEATURE
FLEXCANb_MCR(_baseAddress) |= FLEXCAN_MCR_LPRIO_EN; // TX PRIORITY FEATURE
FLEXCANb_MCR(_baseAddress) &= ~FLEXCAN_MCR_SUPV;
FLEXCANb_CTRL2(_baseAddress) |= FLEXCAN_CTRL2_RRS | // store remote frames
FLEXCAN_CTRL2_MRP; // mailbox > FIFO priority.
FLEXCANb_MCR(_baseAddress) &= ~FLEXCAN_MCR_HALT; // start the CAN //
while (FLEXCANb_MCR(_baseAddress) & FLEXCAN_MCR_FRZ_ACK);
while (FLEXCANb_MCR(_baseAddress) & FLEXCAN_MCR_NOT_RDY); // wait until ready /
//setRX(); setTX();
//NVIC_SET_PRIORITY(NVIC_IRQ, 1); // set interrupt priority /
NVIC_ENABLE_IRQ(NVIC_IRQ); // enable message interrupt /
}