Forum Rule: Always post complete source code & details to reproduce any issue!
Page 4 of 4 FirstFirst ... 2 3 4
Results 76 to 83 of 83

Thread: T4 FlexIO - Looking back at my T4 beta testing library FlexIO_t4

  1. #76
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,350
    Sorry, sometimes this stuff can be a pain in the ...

    That is why most of my flexIO system code includes debug stuff, like:
    Code:
    		// Lets print out some of the settings and the like to get idea of state
    		#ifdef DEBUG_FlexSerial
    		Serial.printf("CCM_CDCDR: %x\n", CCM_CDCDR);
    		Serial.printf("VERID:%x PARAM:%x CTRL:%x PIN: %x\n", p->VERID, p->PARAM, p->CTRL, p->PIN);
    		Serial.printf("SHIFTSTAT:%x SHIFTERR=%x TIMSTAT=%x\n", p->SHIFTSTAT, p->SHIFTERR, p->TIMSTAT);
    		Serial.printf("SHIFTSIEN:%x SHIFTEIEN=%x TIMIEN=%x\n", p->SHIFTSIEN, p->SHIFTEIEN, p->TIMIEN);
    		Serial.printf("SHIFTSDEN:%x SHIFTSTATE=%x\n", p->SHIFTSDEN, p->SHIFTSTATE);
    		Serial.printf("SHIFTCTL:%x %x %x %x\n", p->SHIFTCTL[0], p->SHIFTCTL[1], p->SHIFTCTL[2], p->SHIFTCTL[3]);
    		Serial.printf("SHIFTCFG:%x %x %x %x\n", p->SHIFTCFG[0], p->SHIFTCFG[1], p->SHIFTCFG[2], p->SHIFTCFG[3]);
    		Serial.printf("TIMCTL:%x %x %x %x\n", p->TIMCTL[0], p->TIMCTL[1], p->TIMCTL[2], p->TIMCTL[3]);
    		Serial.printf("TIMCFG:%x %x %x %x\n", p->TIMCFG[0], p->TIMCFG[1], p->TIMCFG[2], p->TIMCFG[3]);
    		Serial.printf("TIMCMP:%x %x %x %x\n", p->TIMCMP[0], p->TIMCMP[1], p->TIMCMP[2], p->TIMCMP[3]);
    So that I can go through and look at the actual state of each of the registers.

    It looked like you setup the interrupt vector and enabled it... So something should be called

    But also part of the flexio_t4 code is a function addIOHandlerCallback.... which sets up the ISR with it's own IRQ handler where you could setup callbacks for different timers...

    Beyond that I am not sure.

  2. #77
    Senior Member
    Join Date
    Oct 2019
    Posts
    285
    Quote Originally Posted by KurtE View Post
    But also part of the flexio_t4 code is a function addIOHandlerCallback.... which sets up the ISR with it's own IRQ handler where you could setup callbacks for different timers...
    I was hoping to try this, but couldn't find a code example of it.
    My interpretation was I setup my own callback function, and pass it in addIOHandlerCallback() - it gets called based on whichever interrupts I enabled on the relevant instance (timer interrupt, shifter interrupt or error interrup).
    But talking another look, Im not sure that's the way to do it.

  3. #78
    Senior Member
    Join Date
    Oct 2019
    Posts
    285
    @KurtE been trying to register a callback with addIOHandlerCallback but to no avail.
    I created a callback handler:
    Code:
    FlexIOHandlerCallback *cb;
    I pass cb to addIOHandlerCallback
    Code:
    addIOHandlerCallback(cb);
    I have my own callback function,
    Code:
    bool myCB(){
    return true;
    }
    But how to I assign myCB to the callback handler cb?

  4. #79
    @Rezo - I've made some good progress which might be useful to you. I successfully got the interrupt method working. Functional proof of concept here:
    https://github.com/easone/FlexIO_interrupt

    The ISR needs to clear the interrupt signal - this is done by writing to the TIMSTAT register in case of a timer status interrupt, or writing data to the shifter buffers in case of a shifter status interrupt. Although, one subtlety is that the shifter status interrupt also triggers after a transfer is complete, so you have to disable the interrupt signal in the SHIFTSIEN register once the transfer is done... It's not sufficient to write to the SHIFTSTAT register to clear that interrupt, because clearing the shifter status flag also triggers FlexIO to shift more data.

  5. #80
    Im just making sure i get the flex io right.

    I needed another spi bus on a project, all dedicated buses are already in use, so i looked into flexIO and i have some pins on the MicroMod teensy available (44, 46, 48, 73) which is part of flexIO "2" which should be fully featured with dma support?

    So im hoping this config is possible: pin 44 mosi, pin 46 miso, pin 48 clk, pin 73 cs.

    other then that, are there any downsides to using the flexIO for spi rather then the dedicated spi?
    Last edited by mah; 11-12-2021 at 02:04 PM.

  6. #81
    I was trying to use FlexSerial to replicate a UART for MIDI Output. Unfortunately, I'm hitting some roadblocks. I'm not able to manipulate the baud rate for the FlexIO pin. begin(31250) should work, but the pin is still sending the MIDI message at a baud rate of 115200.
    Click image for larger version. 

Name:	FlexSerial.jpg 
Views:	0 
Size:	199.0 KB 
ID:	27967
    Photo above comparing the FlexIO pin (yellow) vs a Serial TX pin running at 31250baud (blue) and both writing the same bytes. I've looked at the code in FlexSerial.cpp and compared it to the IMXRT manual chapter 50 and the flexio configuration code looks fine. Adjusting the FLEXIO1_CLOCK value somewhat changes the speed but I am not able to determine a relationship between that and the baud rate.

    Any idea where I should be looking at?

  7. #82
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,748
    That looks like double the rate, ie 62500, not 115200.

  8. #83
    Ah yes, double. Getting close but something still isnt quite right.

    I tried to half the FlexIO clock speed by using the divider
    Code:
      CCM_CS1CDR &= ~( CCM_CS1CDR_FLEXIO2_CLK_PRED( 7 ) );
      CCM_CS1CDR |= CCM_CS1CDR_FLEXIO2_CLK_PRED( 0b11 );
    And its close to 31250 now, but still not quite. More like 34500.
    Click image for larger version. 

Name:	Untitled 2.jpg 
Views:	0 
Size:	193.7 KB 
ID:	27980
    Blue is MIDI TX from Serial1 running at 31250.
    Yellow is from the FlexIO pin.

    EDIT** Resolved! I just had to divide the clockrate (FLEXIO1_CLOCK) in FlexSerial.cpp as well.

Posting Permissions

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