Project: SPI_MSTransfer

I GOT 1 KHZ WORKING!!!

Code:
F&F (OT=0) OT_CALC==3000000  micros() _time==24784
F&F (OT=0) OT_CALC==3000000  micros() _time==24784
F&F (OT=0) OT_CALC==3000000  micros() _time==24783
F&F (OT=0) OT_CALC==3000000  micros() _time==24783
F&F (OT=0) OT_CALC==3000000  micros() _time==24783
F&F (OT=0) OT_CALC==3000000  micros() _time==24784
F&F (OT=0) OT_CALC==3000000  micros() _time==24783
F&F (OT=0) OT_CALC==3000000  micros() _time==24783
F&F (OT=0) OT_CALC==3000000  micros() _time==24783
F&F (OT=0) OT_CALC==3000000  micros() _time==24783
F&F (OT=0) OT_CALC==3000000  micros() _time==24783
F&F (OT=0) OT_CALC==3000000  micros() _time==24784
 
Yes mike!

Short answer!

Spi slave register configuration ordering is important! THAT OR the 3.2 isnt capable of a single ninstruction set!!
 
Trial and error!?!?! AND A POWER NAP!

I knew something was wrong when the BUS WAS UNAFFECTED by the T3.2 slave crashing when the T3.5 continued operation!
So I went to poke around the registers!
 
Can you test and let me know your 3.2 functionality at all speeds????????????????


Code:
[ATTACH]13641._xfImport[/ATTACH]
 
Amazing what a power nap can do for you. Glad you found the root cause of the all the issues with the 3.2

Will do and let you know shortly
 
even 1Hz is working lol

EDIT: events(0) is working with 400uS f&f’s!
but thats too much overhead, leave events() blank, it defaults to 500uS :)
 
Ok did a whole bunch of testing, master at 168Mhz and slave at 120Mhz:
  • Max is 26Mhz but you get a bunch of OTs so for practical purposes 24Mhz should be the max
  • Tested down to 500hz and worked even at that speed.
  • Can't even remember all the speeds I tested at but I remember 4Mhz, 14Mhz 10Mhz.

With Master at 120Mhz and slave at 120Mhz still worked at 24MHz

With Master at 120Mhz and slave at 72Mhz and bus at 24Mhz worked but now well, get a lot of OTs on the master side and bad lastvals on the slave side and the transfer is choppy. Probably get better results adjust events/timer.

By the way all tests done with 1ms loops and 0us events.
 
Yes you have my permission :) Guess I will have to solder up the LC just so I can give you more problems to solve. :)
 
I know - but I some other soldering to do anyway so I might as well do that at the same time :) I usually solder in batches...
 
3.5/3.5 Not working

Eh Tony. As a test I went and loaded the master and slave sketches on the two 3.5's.

Unfortunately it is not running - getting F&F's on the master but nothing on the slave. Same sketches used on the 3.5/3.2 combo except I left SPI at 30Mhz.

Do you think the spi order that you had previously is good for the 3.5/3.6 while the order for 3.2 is different?
 
If it is... I can always add if/def's to make it automatic switchable :)

can you try to copy the old ::begin() over to test?
 
Keep the SAME library, just change in the CPP, let me know if that works:

Change this:
Code:
    SIM_SCGC6 |= SIM_SCGC6_SPI0; // enable slave clock

    SPI0_MCR |= SPI_MCR_HALT | SPI_MCR_MDIS;
    SPI0_MCR = 0x00000000;
    SPI0_MCR &= ~SPI_MCR_HALT & ~SPI_MCR_MDIS;

    SPI0_CTAR0_SLAVE = 0;
    SPI0_MCR |= SPI_MCR_HALT | SPI_MCR_MDIS;
    SPI0_CTAR0_SLAVE = SPI_CTAR_FMSZ(15);
    SPI0_MCR &= ~SPI_MCR_HALT & ~SPI_MCR_MDIS;

    SPI0_MCR |= SPI_MCR_HALT | SPI_MCR_MDIS;
    SPI0_CTAR0_SLAVE = SPI0_CTAR0_SLAVE & ~(SPI_CTAR_CPOL | SPI_CTAR_CPHA) | 0x00 << 25;
    SPI0_MCR &= ~SPI_MCR_HALT & ~SPI_MCR_MDIS;

    SPI0_RSER = 0x00020000;

    CORE_PIN14_CONFIG = PORT_PCR_MUX(2);
    CORE_PIN11_CONFIG = PORT_PCR_DSE | PORT_PCR_MUX(2);
    CORE_PIN12_CONFIG = PORT_PCR_MUX(2);
    CORE_PIN2_CONFIG =  PORT_PCR_PS | PORT_PCR_MUX(2); // this uses pin 2 for the CS so Serial2 can be used instead.
    NVIC_SET_PRIORITY(IRQ_SPI0, 1); // set priority
    NVIC_ENABLE_IRQ(IRQ_SPI0); // enable CS IRQ


To this:
Code:
    SIM_SCGC6 |= SIM_SCGC6_SPI0; // enable slave clock
    SPI0_MCR |= SPI_MCR_HALT | SPI_MCR_MDIS; // stop
    SPI0_CTAR0_SLAVE = SPI_CTAR_FMSZ(15) & SPI0_CTAR0_SLAVE & (~(SPI_CTAR_CPOL | SPI_CTAR_CPHA) | 0x00 << 25);
    SPI0_RSER = 0x00020000;
    CORE_PIN14_CONFIG = PORT_PCR_MUX(2);
    CORE_PIN11_CONFIG = PORT_PCR_DSE | PORT_PCR_MUX(2);
    CORE_PIN12_CONFIG = PORT_PCR_MUX(2);
    CORE_PIN2_CONFIG =  PORT_PCR_PS | PORT_PCR_MUX(2); // this uses pin 2 for the CS so Serial2 can be used instead.
    SPI0_MCR &= ~SPI_MCR_HALT & ~SPI_MCR_MDIS; // start
    NVIC_SET_PRIORITY(IRQ_SPI0, 1); // set priority
    NVIC_ENABLE_IRQ(IRQ_SPI0); // enable CS IRQ

Then upload to your slave
 
I don't think we'll be able to do LC... the LC requires writes to 2 addresses, and without re-writing all the switches in the ISR to compensate for 2 writes, we can't do much
The register expects 8bit writes only, and the POPR & PUSHR_SLAVE (kinetisK) is a SPI0_DL (lower byte register) and SPI0_DH (upper register) for the data, for in and out its the same register.

This would require re-writing a complex sphagetti code with ifdef's everywhere....

Mike, did you get the section of code changed for result?
 
I don't think we'll be able to do LC... the LC requires writes to 2 addresses, and without re-writing all the switches in the ISR to compensate for 2 writes, we can't do much
The register expects 8bit writes only, and the POPR & PUSHR_SLAVE (kinetisK) is a SPI0_DL (lower byte register) and SPI0_DH (upper register) for the data, for in and out its the same register.

This would require re-writing a complex sphagetti code with ifdef's everywhere....

LC with less RAM and speed would run at slower speeds and the RAM hit would be higher % - so maybe not worth too much trouble?

It would work for Master as you use standard SPI# routines right?

It would "just" take a single #ifdef ... alternate spi0_isr() for use on T_LC?

Just like it would take an alternate spi#_isr() to support SPI1 or SPI2 _isr() for T_3.5 and T_3.6?
 
I cant seem to get it above 24mhz either, even with the old SPI registers. The working one should be recommended though because "it works" for both, the 30mhz issue is from something else....
 
Yeah but we need to push 2 8bit registers SPI0_DL && SPI0_DH, and read them like the POPR, it's a 2 way register, but thats alot of ifdefs and code rewriting to adapt!
it's not as simple as a redefine...
 
Back
Top