ewb_at_pjrc
Member
I was attempting to setup an XBAR (A1) "mapping" on my teensy 4.0 (input 40 to output 6) and discovered I cannot write to the XBARA1_SEL3 register.
i.e.: it remains 0 after writing a new value to it - and appears to not take effect either (but I can't be sure of that yet). I'm aware that other things need to be done to bring the signal out to a pin and I have code to do that, but I've not been able to test it since this step doesn't work. I've looked into whether the MPU setup might be causing this, and I don't think so.
Any clue?
I'm also curious why the imxrt.h file has entries for XBARA1_SEL0 through XBARA1_SEL29 followed by XBARA1_CTRL0. Per the reference manual for the 1062 there are 132 outputs from XBAR1 and thus 66 select registers (0 to 65) and thus the CTRL0 and CTRL1 registers are at the wrong offset. This is not relevant to the problem above right now since I do not need to use the CTRL registers to setup edge detection, DMA or interrupts.
I am using teensyduino 1.49 via make and the teensy tools on a host running ubuntu. I am not using the Arduino IDE, although I did start out using it until I learned that make "just works" (which is terrific BTW). Yes I know that 1.49 is not the latest.
I created the following simple code fragment to demonstrate the problem. It is inserted into the main.cpp file. Nothing more is needed to demonstrate the problem (I think I also attached the file to this post).
Here is the output I get from this code:
Disconnect /dev/bus/usb/002/020
Opened /dev/ttyACM0 Serial
count=2
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
count=3
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
count=4
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
count=5
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
executed: XBARA1_SEL3 = 40;
count=6
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
count=7
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
Disconnect /dev/bus/usb/002/022
i.e.: it remains 0 after writing a new value to it - and appears to not take effect either (but I can't be sure of that yet). I'm aware that other things need to be done to bring the signal out to a pin and I have code to do that, but I've not been able to test it since this step doesn't work. I've looked into whether the MPU setup might be causing this, and I don't think so.
Any clue?
I'm also curious why the imxrt.h file has entries for XBARA1_SEL0 through XBARA1_SEL29 followed by XBARA1_CTRL0. Per the reference manual for the 1062 there are 132 outputs from XBAR1 and thus 66 select registers (0 to 65) and thus the CTRL0 and CTRL1 registers are at the wrong offset. This is not relevant to the problem above right now since I do not need to use the CTRL registers to setup edge detection, DMA or interrupts.
I am using teensyduino 1.49 via make and the teensy tools on a host running ubuntu. I am not using the Arduino IDE, although I did start out using it until I learned that make "just works" (which is terrific BTW). Yes I know that 1.49 is not the latest.
I created the following simple code fragment to demonstrate the problem. It is inserted into the main.cpp file. Nothing more is needed to demonstrate the problem (I think I also attached the file to this post).
Code:
extern "C" int main(void)
{
#ifdef USING_MAKEFILE
// To use Teensy 4.0 without Arduino, simply put your code here.
// For example:
pinMode(13, OUTPUT);
int count = 0;
while (1) {
++count;
digitalWriteFast(13, HIGH);
delay(100);
digitalWriteFast(13, LOW);
delay(100);
// MY ADDITION
Serial.print("count=");Serial.println(count);
uint32_t addr = (uint32_t)&XBARA1_SEL3;
uint16_t val = XBARA1_SEL3;
Serial.print("&XBARA1_SEL3=0x"); Serial.println(addr, HEX);
Serial.print("XBARA1_SEL3=0x"); Serial.println(val, HEX);
if(count == 5) {
// map XBAR1 input 40 (FLEXPWM1_PWM1_OUT_TRIG0 | FLEXPWM1_PWM1_OUT_TRIG1)
// to XBAR1 output 6 (XBAR1_OUT06 = IOMUX_XBAR_INOUT06) by writing 40 to
// XBARA1_SEL3 (@ 0x403BC006)
XBARA1_SEL3 = 40;
Serial.println("executed: XBARA1_SEL3 = 40;");
}
delay(1000);
}
#endif
}
Here is the output I get from this code:
Disconnect /dev/bus/usb/002/020
Opened /dev/ttyACM0 Serial
count=2
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
count=3
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
count=4
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
count=5
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
executed: XBARA1_SEL3 = 40;
count=6
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
count=7
&XBARA1_SEL3=0x403BC006
XBARA1_SEL3=0x0
Disconnect /dev/bus/usb/002/022