I'm just starting with Teensys, so apologies if this is a rudimentary question.
I'm trying to port an app from Arduino to Teensy 3.2 so I can use the extra resources. My app involves sending a 6-byte serial 2400 8N2 message to a remote module, then receiving a response which is in a PWM-type format. As the remote module start replying very soon after receiving the last byte of the transmission, I need to turn off the transmitter and set up (hopefully) one of the FTM units using Input Capture mode to find the time of the returned data pulses.
As a first step, I've managed to get the data bytes coming out of the Teensy. I now want to access the TCIE bit in UART1_C2 to determine when the transmission is complete. However, I find that if I read a UART register, my program hangs.
My code is:
and the response with the line "temp = UART1_C2; "commented out is:
With the comment removed so I actually read UART1_C2, all I get is:
I'm successfully accessing the registers in the FTM.
I'm probably missing something pretty basic, but have looked at the source files in \Arduino\hardware\teensy\avr\cores\teensy3 and don't think there is anything wrong with what I am trying.
I'm using a Teensy 3.2
VID: 16C0
PID: 0483
SN: 506318
I'm accessing the Teensy from Windows 10 version 1803 with the 28/09 update. I'm running Teensyduino version 1.8.5.
I'm trying to port an app from Arduino to Teensy 3.2 so I can use the extra resources. My app involves sending a 6-byte serial 2400 8N2 message to a remote module, then receiving a response which is in a PWM-type format. As the remote module start replying very soon after receiving the last byte of the transmission, I need to turn off the transmitter and set up (hopefully) one of the FTM units using Input Capture mode to find the time of the returned data pulses.
As a first step, I've managed to get the data bytes coming out of the Teensy. I now want to access the TCIE bit in UART1_C2 to determine when the transmission is complete. However, I find that if I read a UART register, my program hangs.
My code is:
Code:
int timeOut;
int trigLo = 2240;
int trigHi = 560;
byte message[] = { 0xFF, 0xFE, 0xFE, 0xFE, 0xFE, 0x00 };
long intTime;
boolean int0Flag, timedOutFlag;
long temp;
void setup()
{
Serial.begin(115200);
Serial1.begin(2400, SERIAL_8N2);
Serial.println(" ----------------");
// temp = UART1_C2;
Serial.println(" ----------------");
for (int i = 4; i < 13; i++)
{
pinMode(i, OUTPUT);
digitalWrite(i, LOW);
}
Serial.print(FTM0_SC, HEX);Serial.print(" ");Serial.print(FTM0_MOD, HEX);Serial.print(" ");Serial.print(FTM0_C7SC, HEX);Serial.print(" ");Serial.print(FTM0_MODE, HEX);
Serial.print(" "); Serial.print(SIM_SCGC6, HEX);Serial.print(" ");Serial.print(FTM0_FMS, HEX);Serial.print(" ");Serial.println(PORTD_PCR7, HEX);Serial.println(" ----------------");
ftmSetup();
FTM0_C7V = 0x2000;
Serial.print(FTM0_SC, HEX);Serial.print(" ");Serial.print(FTM0_MOD, HEX);Serial.print(" ");Serial.print(FTM0_C7SC, HEX);Serial.print(" ");Serial.print(FTM0_MODE, HEX);
Serial.print(" "); Serial.print(SIM_SCGC6, HEX);Serial.print(" ");Serial.print(FTM0_FMS, HEX);Serial.print(" ");Serial.println(PORTD_PCR7, HEX);
}
and the response with the line "temp = UART1_C2; "commented out is:
Code:
----------------
----------------
89 8FFF 28 4 6B000001 0 144
----------------
8 3AC0 28 5 6B000001 0 400
TOF set 8 A8
28
TOF set 8 A8
28
With the comment removed so I actually read UART1_C2, all I get is:
Code:
----------------
I'm successfully accessing the registers in the FTM.
I'm probably missing something pretty basic, but have looked at the source files in \Arduino\hardware\teensy\avr\cores\teensy3 and don't think there is anything wrong with what I am trying.
I'm using a Teensy 3.2
VID: 16C0
PID: 0483
SN: 506318
I'm accessing the Teensy from Windows 10 version 1803 with the 28/09 update. I'm running Teensyduino version 1.8.5.