Forum Rule: Always post complete source code & details to reproduce any issue!
Page 129 of 174 FirstFirst ... 29 79 119 127 128 129 130 131 139 ... LastLast
Results 3,201 to 3,225 of 4340

Thread: Teensy 4.0 First Beta Test

  1. #3201
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,433
    Quote Originally Posted by mjs513 View Post
    ANALOG READ on PINS 26/27

    Looking at this issue: Looks like pins_arduino.h has to be changed and analog.c. pins_arduino.h I understand what has to be changed so that's not a problem. Don't understand this table in analog.c though - "pin to channel". It references pg482 in the RM but don't think that's correct page reference, but know to be wrong:


    Updated pins_arduino.h and noticed that pins 24/25 weren't working either - was wrapped in an ifdef for 1052 only. Fixed that and got pins 24/25 working.
    Note: Page 482 was from first version of the 1052 reference manual. I believe that this is now page: 2457 in the current 1062 manual.

    Edit: I may be also missing it, but I think the analog.c code does need some work....

    Like if I do analogRead(10);

    I believe will fail likewise likewise 11-13 - Instead of mapping to 24-27...

    Also Looks like we are not doing anything yet with ADC2 object?
    Last edited by KurtE; 06-07-2019 at 01:37 PM.

  2. #3202
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,120
    Quote Originally Posted by KurtE View Post
    Note: Page 482 was from first version of the 1052 reference manual. I believe that this is now page: 2457 in the current 1062 manual.

    Edit: I may be also missing it, but I think the analog.c code does need some work....

    Like if I do analogRead(10);

    I believe will fail likewise likewise 11-13 - Instead of mapping to 24-27...

    Also Looks like we are not doing anything yet with ADC2 object?
    Fix for analogRead(10) I fixed in pins_arduino.h. There was a ifdef for only 1052 board which caused the problem. A12/A13 had to added as well for the 1062. So I got that updated.

    I found the old version of the manual and pins 26 and 27 are on ADC2 channels 3/4 respectively. Was in the process of seeing what I had to do to add ADC2 but asked the question do we want to add ADC2 or not use A12/A13 but think I know the answer to that question - but wanted to ask anyway. T Have to reread the ADC section of the manual to double check the setup for ADC2 registers. Only really looked at ADC1.

    EDIT: If you want to check A10/A11 heres the updated pins_arduino.h file
    Attached Files Attached Files

  3. #3203
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,433
    @mjs513...

    Wonder in changes: in pins_arduino.h that now have: #if defined(__IMXRT1052__) || defined(__IMXRT1062__)
    Should just be removed from #if... As I think this file is only used for 1052/1062...

    Also I believe that your fix will work for analogRead(A10);
    But I unsure if you simply call analogRead(10); it will work. As I don't believe there is any code doing the mapping, like it does for A0-A9.

    I just looked at T3.x code and it does this for A0-A13... Example table for T3.2...
    Code:
    #elif defined(__MK20DX256__)
    static const uint8_t pin2sc1a[] = {
    	5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 19+128, // 0-13 -> A0-A13
    	5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 are A0-A9
    	255, 255, // 24-25 are digital only
    	5+192, 5+128, 4+128, 6+128, 7+128, 4+192, // 26-31 are A15-A20
    	255, 255, // 32-33 are digital only
    	0, 19, 3, 19+128, // 34-37 are A10-A13
    	26,     // 38 is temp sensor,
    	18+128, // 39 is vref
    	23      // 40 is A14
    };
    Again T3.x has second ADC marked with 128+ch... And they have the 255 for invalid...

  4. #3204
    hi Paul & Robin, thanks for staying away from kickstarter. looking forward to the release.

  5. #3205
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,120
    @KurtE
    Wonder in changes: in pins_arduino.h that now have: #if defined(__IMXRT1052__) || defined(__IMXRT1062__)
    Should just be removed from #if... As I think this file is only used for 1052/1062...
    You are probably right, I am still playing so will make the change,

    Also I believe that your fix will work for analogRead(A10);
    But I unsure if you simply call analogRead(10); it will work. As I don't believe there is any code doing the mapping, like it does for A0-A9.
    No - have to use A10 or pin number, I know because I tried it by accident. But it think that's the way its suppose to work?

    Will look at the T3.2 stuff - have too many distractions going on today.

  6. #3206
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,785
    Quote Originally Posted by KurtE View Post
    Hi @defragster (and others) - As I mentioned I thought some of these items could be removed or replaced (reworded).
    That is, there is code in place that is about 10 or do from the bottom of list #6 is (I think comment added)
    Code:
    serialEvent() missing, #2561, 		Not present :: Normal T_3.x main() {setup() while(1){loop();delay();}}
    I believe that the issue is not that SerialEvent is missing? As SerialEvents are called from yield.... The issue(s) are:
    a) the main code in startup.c needs to be cleaned up and made ready for release (probably minimum is to comment out printf calls.
    b) The while(1) loop is not calling yield() Edit: Note calling delay(0) does not do anything, delay checks for 0 and returns

    c) eventResponder code - Edit call to run from yield is in yield. Also more long term I know that Paul want's to implement some of the Serial Event code to use the event Responder code.... Currently the version is similar to T3 code and loops through the different Serial ports, checking for SerialX.avaliable() and then call the SerialEvent... There are some shortcuts in this current code. There is an array of (N) SerialEventHandlers functions, which if the pointer is NOT null, it will call off to that Serials. objects check for pending Serial... This is called in SerialX.begin(). If the default SerialEventX (weak pointer) is called the default code will remove itself from the list. If all such functions, removed the loop is not called...

    d) One part of the SerialEvent missing call, that is NOT in, is for the USB serial, as we did not have a working USB Serial input code. Probably can/should add soon.
    I missed the 'reworded aspect There are two lists #4 and #6 - and some duplication within them - like yesterday with 4 entries for RTC in Msg #6

    I was thinking of this (terse) entry updated with a link : serialEvent() missing, #2561,

    All three T4's on the same second this morning - of course they were powered. Of course micros() wrapped and the pretty synchronization is gone.

  7. #3207
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,785
    Quote Originally Posted by mjs513 View Post
    @defragster

    I just reran Coremark to see if this was still applicable:


    At 24000 iterations I am not seeing any faults:
    Think it can be closed/deleted.
    Cool - there was something odd at that time { trying to find where it faulted was a chase } perhaps, and it was on B1_1052.

  8. #3208
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,120
    @KurtE @Paul @...

    Think I got all the changes to get Pins 26/27 operational for A12/A13. If anyone wants to give a quick test and let me know if it works for them let me know - still have to edit pins_arduino.h to modify the ifdef per @KurtE's comments.
    Attached Files Attached Files

  9. #3209
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,120
    Quote Originally Posted by defragster View Post
    Cool - there was something odd at that time { trying to find where it faulted was a chase … } perhaps, and it was on B1_1052.
    Just trying to see if I can delete stuff for Paul before he had to start working it where I can. Know it ain't much but every little bit helps - besides its way too long

  10. #3210
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,433
    Hi @mjs513 - looks like it should work. Currently don't have any hardware to easily test... I did not install any Pogo pins on 26/27 - I think I have some still around here somewhere... But on test boards, I don't think they actually run anywhere...

    If need be I could semi verify by pulling board out of test board, and using test setup to do it...

    Again wondering about analogRead(11) versus analogRead(A11);

    So tried it sample sketch:


    Code:
    void setup() {
      while (!Serial) ;
      Serial.begin(115200);
      
    }
    
    
    void loop() {
      static int A11_last = -1;
      static int N11_last = -1;  
    
      int A11_in = analogRead(A11);
      int N11_in = analogRead(11);
    
      if ((A11_in != A11_last) || (N11_in != N11_last)) {
        Serial.printf("A11 = %d 11 = %d\n", A11_in, N11_in);
        A11_last = A11_in;
        N11_last = N11_in;    
      }
      delay(250);
      
    }
    On T4 the (11) always returned 0... When I ran it on T3.6 it got similar values as A11... Same values if pulled to 0v or 3.3v...

    So hacked your code slightly like:
    Code:
    const uint8_t pin_to_channel[] = { // pg 482
    	7,	// 0/A0  AD_B1_02
    	8,	// 1/A1  AD_B1_03
    	12,	// 2/A2  AD_B1_07
    	11,	// 3/A3  AD_B1_06
    	6,	// 4/A4  AD_B1_01
    	5,	// 5/A5  AD_B1_00
    	15,	// 6/A6  AD_B1_10
    	0,	// 7/A7  AD_B1_11
    	13,	// 8/A8  AD_B1_08
    	14,	// 9/A9  AD_B1_09
    #if 0
    	128,	// 10
    	128,	// 11
    	128,	// 12
    	128,	// 13
    #else
    	1,	// 24/A10 AD_B0_12 
    	2,	// 25/A11 AD_B0_13
    	128+3,	// 26/A12 AD_B1_14 - only on ADC2, 3
    	128+4,	// 27/A13 AD_B1_15 - only on ADC2, 4
    #endif	
    	7,	// 14/A0  AD_B1_02
    	8,	// 15/A1  AD_B1_03
    	12,	// 16/A2  AD_B1_07
    	11,	// 17/A3  AD_B1_06
    	6,	// 18/A4  AD_B1_01
    	5,	// 19/A5  AD_B1_00
    	15,	// 20/A6  AD_B1_10
    	0,	// 21/A7  AD_B1_11
    	13,	// 22/A8  AD_B1_08
    	14,	// 23/A9  AD_B1_09
    	1,	// 24/A10 AD_B0_12
    	2,	// 25/A11 AD_B0_13
    	128+3,	// 26/A12 AD_B1_14 - only on ADC2, 3
    	128+4	// 27/A13 AD_B1_15 - only on ADC2, 4
    };
    
    
    static void wait_for_cal(void)
    {
    	//printf("wait_for_cal\n");
    	while (ADC1_GC & ADC_GC_CAL) ;
    	// TODO: check CALF, but what do to about CAL failure?
    	calibrating = 0;
    	//printf("cal complete\n");
    }
    
    
    int analogRead(uint8_t pin)
    {
    	if (pin > sizeof(pin_to_channel)) return 0;
    	if (calibrating) wait_for_cal();
    	uint8_t ch = pin_to_channel[pin];
    //	printf("%d\n", ch);
    //	if (ch > 15) return 0;
    	if(!(ch & 0x80)) {
    		ADC1_HC0 = ch;
    		while (!(ADC1_HS & ADC_HS_COCO0)) ; // wait
    		return ADC1_R0;
    	} else {
    		ADC2_HC0 = ch & 0x7f;
    		while (!(ADC2_HS & ADC_HS_COCO0)) ; // wait
    		return ADC2_R0;
    	}
    }
    Marked usage of second ADC to be like T3.x with 128+... Did not mark any with 255 as none in this range that don't work...

    However also wondering: If we should be adding some psuedo pins like we have to T3.5/6 and I believe others, where
    70 is internal temp sensor and 71 is VRef.

    Which are different than T3.2... 38 and 39...

    I know there have been some discussions about wishing there was something like A_TEMP, A_VREF (or other logical names) that were defined in core_pins.h for the different boards...

  11. #3211
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,785
    Really hoping we get to see a T4 CARD soon - much easier to read and trust than the update beta 2 sheet ... just noticed the edited lines are too faint to read as printed from Word - have to fix/reprint

    Quote Originally Posted by KurtE View Post
    Hi @mjs513 - looks like it should work. Currently don't have any hardware to easily test... I did not install any Pogo pins on 26/27 - I think I have some still around here somewhere... But on test boards, I don't think they actually run anywhere...

    ...
    Indeed 26 and 27 go nowhere I see on the DIY breakout I looked at. Paul sent POGO pins - I could add a pair on the DIY board for test … soon ... need to pull 24-29 to get Serial6&7 too - can wire them to blank pins on those headers.

    I started the RTC edit code to merge into the WAV Audio test edits I made …

  12. #3212
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,120
    @KurtE

    I added you mods to the pins_arduino.h and tested on 12/13 and a couple of other pins and the hack you put in seemed to work no problem.

    As you suggestion:
    However also wondering: If we should be adding some psuedo pins like we have to T3.5/6 and I believe others, where
    70 is internal temp sensor and 71 is VRef.

    Which are different than T3.2... 38 and 39...

    I know there have been some discussions about wishing there was something like A_TEMP, A_VREF (or other logical names) that were defined in core_pins.h for the different boards...
    Don't know enough about using logical pins or where they would be tied to if anywhere on the T4. Right now internal temp is software only - I didn't see any pins associated with internal temp when I was doing the temp monitor stuff and you got me on the V_Ref pin. Right now its not setup in analog.c.

  13. #3213
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,120
    @KurtE - @defragster
    Yeah on the Paul's breakout boards you would need to add the pogo's and wires to unused pins. I got my version of the breakout board running so I have those pins broken out for testing. Mine doesn't have a SD Card or Audio on so going back and forth between breakouts. Going to test now on the T4B2M with Paul's board to make sure nothing has changed. Kind of use the old T4B2 for initial testing and then going back for official testing you might say.

    EDIT:
    Oh, forgot I also had modified one of the breakout boards for all pogo pins and brought out 26/27/30/31 to unused pins as well for testing. I have a POT somewhere so will hook that up later. Have to go play with the little one now.

  14. #3214
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,433
    Quote Originally Posted by defragster View Post
    Really hoping we get to see a T4 CARD soon - much easier to read and trust than the update beta 2 sheet ... just noticed the edited lines are too faint to read as printed from Word - have to fix/reprint
    Yep - I keep going back to my Excel document... But a Card would be Nice... Although I still go to my T3.6 document at times than card as to get more precise information like which CS pin is what... More Alternate pins...
    Code:
    Pin	Name	GPIO	Serial	I2C	SPI	PWM	CAN	Audio	XBAR	FlexIO	Analog	SD
     0	AD_B0_03	1.3	Serial1(6) RX		SPI1(3) CS0	PWM1_X1	2_RX		IO-17			
     1	AD_B0_02	1.2	Serial1(6) TX		SPI1(3) MISO	PWM1_X0	2_TX		IO-16			
     2	EMC_04	4.4				PWM4_A2		2:TX_DATA	IO-06	1:4		
     3	EMC_05	4.5				PWM4_B2		2:TX_SYNC	IO-07	1:5		
     4	EMC_06	4.6				PWM2_A0		2:TX_BCLK	IO-08	1:6		
    5	EMC_08	4.8				PWM2_A1		2:RX_DATA	IO-17	1:8		
    6	B0_10	2.10				PWM2_A2	QT4_1	1:TX3_RX1		2:10		
    7	B1_01	2.17	Serial2(4) RX			PWM1_B3		1:TX_DATA	IO-15	2:17, 3:17		
    8	B1_00	2.16	Serial2(4) TX			PWM1_A3		1:RX_DATA	IO-14	2:16, 3:16		
     9	B0_11	2.11				PWM2_B2	QT4_2	1:TX2_RX2		2:11		
    10	B0_00	2.0			SPI(4) CS0	QT1_0		MQS_RIGHT		2:0     		
    11	B0_02	2.2			SPI(4) MOSI	QT1_2	1_TX			2:2		
    12	B0_01	2.1			SPI(4) MISO	QT1_1		MQS_LEFT		2:1     		
    13	B0_03	2.3			SPI(4) SCK	QT2_0	1_RX			2:3		
    14/A0	AD_B1_02	1.18	Serial3(2) TX			QT3_2		SPDIF_OUT		3:2	A1:7, A2:7	
    15/A1	AD_B1_03	1.19	Serial3(2) RX			QT3_3		SPDIF_IN		3:3	A1:8, A2:8	
    16/A2	AD_B1_07	1.23	Serial4(3) RX	Wire1(3) SCL				SPDIF_EXTCLK		3:7	A1:12, A2:12	
    17/A3	AD_B1_06	1.22	Serial4(3) TX	Wire1(3) SDA				SPDIF_LOCK		3:6	A1:11, A2:11	
    18/A4	AD_B1_01	1.17	Serial3(2) CTS	Wire(1) SDA		QT3_1				3:1	A1:6, A2:6	
    19/A5	AD_B1_00	1.16		Wire(1) SCL		QT3_0				3:0	A1:5, A2:5	
    20/A6	AD_B1_10	1.26	Serial5(8) TX					1:RX_SYNC		3:10	A1:15, A2:15	
    21/A7	AD_B1_11	1.27	Serial5(8) RX					1:RX_BCLK		3:11	A1:0, A2:0	
    22/A8	AD_B1_08	1.24				PWM4_A0	1_TX			3:8	A1:13, A2:13	
    23/A9	AD_B1_09	1.25				PWM4_A1	1_RX	1:MCLK		3:9	A1:14, A2:14	
    ---	----	----	------	---	---	---	---	----	----	-----	------	
    24/A10	AD_B0_12	1.12	Serial6(1) TX	Wire2(4) SCL		PWM1_X2					A1:1  	
    25/A11	AD_B0_13	1.13	Serial6(1) RX	Wire2(4) SDA		PWM1_X3	GPT1_CLK				A1:2	
    26/A12	AD_B1_14	1.30			SPI1(3) MOSI			1:TX_BCLK		3:14	A2:3  	
    27/A13	AD_B1_15	1.31			SPI1(3) SCK			1:TX_SYNC		3:15	A2:4  	
    28	EMC_32	3.18	Serial7(7) RX			PWM3_B1						
    29	EMC_31	4.31	Serial7(7) TX		SPI2(1) CS1	PWM3_A1						
    30	EMC_37	3.23				GPT1_3 	3_RX	3:MCLK	IO-23			
    31	EMC_36	3.22				GPT1_2	3_TX	3:TX_DATA	IO-22			
    32	B0_12	2.12						1:TX1_RX3	IO-10	2:12		
    33	EMC_07	4.7				PWM2_B0		2:MCLK	IO-09	1:7		
    												
    34	SD_B0_03	2.15	Serial5(8) RTS		SPI2(1) MISO	PWM1_B1			IO-07			DATA1
    35	SD_B0_02	3.14	Serial5(8) CTS		SPI2(1) MOSI	PWM1_A1			IO-06			DATA0
    36	SD_B0_01	3.13		Wire1(3) SDA	SPI2(1) CS0	PWM1_B0			IO-05			CLK
    37	SD_B0_00	3.12		Wire1(3) SCL	SPI2(1) SCK	PWM1_A0			IO-04			CMD
    38	SD_B0_05	3.17	Serial5(8) RX		SPI2(1) B_DQS	PWM1_B2			IO-09			DATA3
    39	SD_B0_04	3.16	Serial5(8) TX		SPI2(1) B_SSO_B	PWM1_A2			IO-08			DATA2
    Probably won't align properly here...

  15. #3215
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,433
    SerialEvent(s) and main() loop call yield...

    I have been playing with it today and trying to get all the SerialEvent(x) calls to work.

    This includes updating the main loop to not do debug prints, plus have it call yield and the like:

    Still WIP, but current stuff up at: https://github.com/KurtE/cores/tree/SerialEvents_main

    Test program:
    Code:
    #define DO_SERIALEVENT
    uint32_t current_baud = 38400;
    
    
    void setup() {
      pinMode(2, OUTPUT);
      digitalWrite(2, LOW);
      while (!Serial && (millis() < 3000)) ;
      Serial.begin(38400);
      Serial.println("Test Serial ports");
      Serial.println("Test Serial ports");
      Serial1.begin(current_baud);
      Serial2.begin(current_baud);
      Serial3.begin(current_baud);
    #if defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__)
      Serial4.begin(current_baud);
      Serial5.begin(current_baud);
      Serial6.begin(current_baud);
    #if defined(__IMXRT1062__)
      Serial7.begin(current_baud);  
    #endif
    #endif
    }
    
    void loop() {
    #if !defined(DO_SERIALEVENT)
      Serial.printf("Output to all Serial ports at Baud %d\n", current_baud);
     
      digitalWriteFast(2, HIGH);
      Serial1.println("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
      // Test some of the Serial1 helper functions that still may be used for debug
    
    #if !defined(__IMXRT1062__)
    
      serial_print("!@#$%^&*()_+");
      serial_phex(0x01);
      serial_print(" ");
      serial_phex16(0x0102);
      serial_print(" ");
      serial_phex32(0xaabbccdd);
      serial_print("\n");
    #endif
      digitalWriteFast(2, LOW);
      delay(200); // give time for it to happen
    
      Serial.println("Enter new baud or hit enter to continue using previous baud");
    
      uint32_t new_baud = 0;
      int ch;
      while ((ch = Serial.read()) != '\n') {
        if ((ch >= '0') && (ch <= '9'))
          new_baud = new_baud * 10 + ( ch - '0');
      }
      if (new_baud && (new_baud != current_baud)) {
        current_baud = new_baud;
        Serial1.end();
        Serial2.end();
        Serial3.end();
        Serial1.begin(current_baud);
        Serial2.begin(current_baud);
        Serial3.begin(current_baud);
    #if defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__)
        Serial4.end();
        Serial5.end();
        Serial6.end();
        Serial4.begin(current_baud);
        Serial5.begin(current_baud);
        Serial6.begin(current_baud);
    #endif
    #if defined(__IMXRT1062__)
        Serial7.end();
        Serial7.begin(current_baud);
    #endif
      }
    #endif  
    }
    
    #if defined(DO_SERIALEVENT)
    void serialEvent() {
      Serial.println("serialEvent called");
      uint8_t buffer[80];
      uint8_t cb = min (min((int)sizeof(buffer), Serial.available()), Serial1.availableForWrite());
      Serial.printf("serialEvent called cb: %d\n", cb);
      uint8_t cb_read = Serial.readBytes(buffer, cb);
      Serial.printf("   cb read = %d\n", cb_read);
      Serial1.write(buffer, cb);
    }
    #endif
    
    void serialEvent1() {
    //  Serial.println("serialEvent1 called");
      uint8_t buffer[80];
      uint8_t cb = min (min((int)sizeof(buffer), Serial1.available()), 16 /*Serial.availableForWrite()*/);
      Serial1.readBytes(buffer, cb);
      Serial.write(buffer, cb);
    }
    
    void serialEvent2() {
      uint8_t buffer[80];
      uint8_t cb = min (min((int)sizeof(buffer), Serial2.available()), Serial2.availableForWrite());
      Serial2.readBytes(buffer, cb);
      Serial2.write(buffer, cb);
    }
    void serialEvent3() {
      uint8_t buffer[80];
      uint8_t cb = min (min((int)sizeof(buffer), Serial3.available()), Serial3.availableForWrite());
      Serial3.readBytes(buffer, cb);
      Serial3.write(buffer, cb);
    }
    #if defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__)
    void serialEvent4() {
      uint8_t buffer[80];
      uint8_t cb = min (min((int)sizeof(buffer), Serial4.available()), Serial4.availableForWrite());
      Serial4.readBytes(buffer, cb);
      Serial4.write(buffer, cb);
    
    }
    void serialEvent5() {
      uint8_t buffer[80];
      uint8_t cb = min (min((int)sizeof(buffer), Serial5.available()), Serial5.availableForWrite());
      Serial5.readBytes(buffer, cb);
      Serial5.write(buffer, cb);
    }
    void serialEvent6() {
      uint8_t buffer[80];
      uint8_t cb = min (min((int)sizeof(buffer), Serial6.available()), Serial6.availableForWrite());
      Serial6.readBytes(buffer, cb);
      Serial6.write(buffer, cb);
    }
    #endif
    #if defined(__IMXRT1062__)
    void serialEvent7() {
      uint8_t buffer[80];
      uint8_t cb = min (min((int)sizeof(buffer), Serial7.available()), Serial7.availableForWrite());
      Serial7.readBytes(buffer, cb);
      Serial7.write(buffer, cb);
    }
    #endif
    The SerialEvent function in this is not working... Actually it is, but:
    void serialEvent() {
    Serial.println("serialEvent called");
    uint8_t buffer[80];
    uint8_t cb = min (min((int)sizeof(buffer), Serial.available()), Serial1.availableForWrite());
    Serial.printf("serialEvent called cb: %d\n", cb);
    uint8_t cb_read = Serial.readBytes(buffer, cb);
    Serial.printf(" cb read = %d\n", cb_read);
    Serial1.write(buffer, cb);
    }
    the call to Serial.readBytes(buffer, cb); is not working.
    I typed: ABCD and setup to output cr/lf as well
    Code:
    Test Serial ports
    serialEvent called
    serialEvent called cb: 6
       cb read = 0
    serialEvent called
    serialEvent called cb: 6
       cb read = 0
    serialEvent called
    serialEvent called cb: 6
    So it got the right counts from Serial.available, but Serial.readBytes(buffer, 6)
    is not working!

    Will debug later, but now other distractions

  16. #3216
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,120
    @KurtE - @defragster

    Finally got a chance to hook up a extra thumb pot I had to A12 and A13 and all the changes seemed to work fine. Think for now it gets operational A12/A13 and we can add logical names later. Going to go ahead and create a PR for this now and go look at T3.x to see what they did for vref - to be honest didn't touch that because I didn't understand what had to be done from the RM.

  17. #3217
    Senior Member
    Join Date
    Oct 2015
    Location
    Roma (IT, EU)
    Posts
    193
    Quote Originally Posted by KurtE View Post
    Still WIP, but current stuff up at: https://github.com/KurtE/cores/tree/SerialEvents_main
    SerialEvent() does not work for me with any Teensy 3.x and TD 1.46.
    Could it be related to this issue?
    And if not, do you think it would make sense for me to try your source tree?

  18. #3218
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,433
    Quote Originally Posted by XFer View Post
    SerialEvent() does not work for me with any Teensy 3.x and TD 1.46.
    Could it be related to this issue?
    And if not, do you think it would make sense for me to try your source tree?
    No should not be related as they use completely different sets of code. That is Teensy3 boards use the code in the cores\teensy3 and T4 code uses cores\teensy4...

    Once I get this simple test program to work, I might try it on a T3.x board...

  19. #3219
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,785
    Should not be related as the Teensy 3 and 4 are distinct. T_3.1 just worked for me.

    Perhaps function is not proper case - it needs to be :: void serialEvent() {

  20. #3220
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,433
    @PaulStoffregen @mjs513, @defragster...

    In the previous program I posted, that did:
    Code:
    void serialEvent() {
      Serial.println("serialEvent called");
      uint8_t buffer[80];
      uint8_t cb = min (min((int)sizeof(buffer), Serial.available()), Serial1.availableForWrite());
      Serial.printf("serialEvent called cb: %d\n", cb);
      uint8_t cb_read = Serial.readBytes(buffer, cb);
      Serial.printf("   cb read = %d\n", cb_read);
      Serial1.write(buffer, cb);
    }
    Was failing as the current implementation for Serial.readBytes is calling usb_serial_read, which is all #if 0 code and return 0... So did not work at all...

    In my branch above, I put in a probably temporary version of usb_serial_read
    Code:
    	// Quick and dirty to make it at least limp...
    	uint8_t *p = (uint8_t *)buffer;
    	uint32_t count=0;
    
    	while (size) {
    		int ch = usb_serial_getchar();
    		if (ch == -1) break;
    		*p++ = (uint8_t)ch;
    		size--;
    		count++;
    	}
    	return count;
    Which gets the above code to work...

    @Paul - I am thinking of doing a PR as to get several things at least working:
    a) Main loop would now call yield
    b) yield now has code to do if (Serial.available()) SerialEvent();
    c) default SerialEvent code tries to disable these calls ...
    d) The above first pass code for Serial.readBytes.

    @mjs513 - I am also running with your analog (with the minor changes) as well. I have not checked those changes in as I am assuming you will do a PR to Pauls...


    EDIT
    Created PR: https://github.com/PaulStoffregen/cores/pull/379

    And I see @mjs513 create PR: https://github.com/PaulStoffregen/cores/pull/378

    EDIT2
    Tried the above program on T3.6... I only wired it up to use Serial1-3 so far but it is running fine so far...
    Last edited by KurtE; 06-07-2019 at 10:24 PM.

  21. #3221
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,785
    Quote Originally Posted by mjs513 View Post
    @KurtE @Paul @...

    Think I got all the changes to get Pins 26/27 operational for A12/A13. If anyone wants to give a quick test and let me know if it works for them let me know - still have to edit pins_arduino.h to modify the ifdef per @KurtE's comments.
    Added POGO pins and the Analog Pins 26/27 ZIP in 3208 lets them be read w/ KurtE's 3210 code.

    Have to check my SD socket - @mjs513 - did you get that DVM that does freq?

  22. #3222
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,120
    @KurtE
    Finally had a chance to download and give it a try on the T4. I tested it on Serial and Serial1 and seems to be working using your test sketch.

  23. #3223
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,120
    Quote Originally Posted by defragster View Post
    Added POGO pins and the Analog Pins 26/27 ZIP in 3208 lets them be read w/ KurtE's 3210 code.

    Have to check my SD socket - @mjs513 - did you get that DVM that does freq?
    @defragster - yep got the DVM that does freq - used it once for something else though. Haven't tested the SD Card pogo pins to see what I get.

  24. #3224
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,785
    @KurtE - IIRC Serial.readBytes is not yet implemented in current implementation.

    Cool you made progress on serialEvent().

    I just hit the USBHost logger_RawWrite sketch and ...\libraries\uSDFS\src\utility\ff_utils.c needs some work on the Time with the update 1062 bootloader v4. I hacked it enough to compile - but not quite a valid time string .

  25. #3225
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,346
    Quote Originally Posted by defragster View Post
    I just hit the USBHost logger_RawWrite sketch and ...\libraries\uSDFS\src\utility\ff_utils.c needs some work on the Time with the update 1062 bootloader v4. I hacked it enough to compile - but not quite a valid time string .
    Will have a look

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •