RX Series SCI SPI Continuous Data Transmission Problem

CPU:RX23T

Implemented function: To control DAC7513 (16bit)through SCI SPI(8bit) , the timings to be implemented as below:

SCI SPI  16bit transfer by sending 2 data in succession, but there is always about 3us interval between the 2 bytes, how to remove this 3us interval?  Achieving continuous transmission of 2 bytes? Please ask the expert for guidance.

                    
   	sci_hdl_t sspiHandle;
	sci_err_t err;
    uint8_t sspi_buf[2];
    sci_cfg_t config;

//Initialize SCI
      config.sspi.spi_mode = SCI_SPI_MODE_1;/* SPMR Register CKPH=0, CKPOL=1 Mode 1: 01 CPOL=0 resting lo, CPHA=1 trailing edge/falling */
		config.sspi.bit_rate = 1000000; // 1 Mbps
		config.sspi.msb_first = true;
		config.sspi.invert_data = false;
		config.sspi.int_priority = 1;

		
		err = R_SCI_Open(SCI_CH1, SCI_MODE_SSPI, &config, NULL,
		&sspiHandle);
		R_SCI_PinSet_SCI1();
      
      
      
      
//send 2 bytes
             
                    SPI_CS  = CS_LOW;
		    	
		    	R_SCI_Send(sspiHandle, sspi_buf, 2);

		    		while (SCI1.SSR. BIT. TEND <1)
		    		{ }
		    	
		    		SPI_CS  = CS_HIGH;

Parents
  • void    send_test_spi(uint8_t *send_data, uint16_t send_cnt)
    {
        volatile uint8_t dummy_rec;
        SCI12.SCR.BIT.RE = 1;
        SCI12.SCR.BIT.RIE = 0;
        SCI12.SCR.BIT.TIE = 0;
        SCI12.SCR.BIT.TEIE = 0;
        SCI12.SCR.BIT.TE = 1;
        dummy_rec = SCI12.RDR;            // empty receiver buffer
        while (send_cnt) {
            while (SCI12.SSR.BIT.TDRE == 0) {
                dummy_rec = SCI12.RDR;
            }
            dummy_rec = SCI12.RDR;
            SCI12.TDR = *send_data;
            send_data ++;
            send_cnt --;
        }
        while (SCI12.SSR.BIT.RDRF == 0);
        dummy_rec = SCI12.RDR;                // empty receiver buffer
    }

  • You are right, with your code, 16 consecutive pulses are generated perfectly, CPU speed is 40Mhz, SPI pulse is max 5Mhz. Thank you very much for your support!

  • you can simplify the routine by turning on only transmitter function:

        SCI1.SCR.BYTE = 0;     // disable all
        nop();
        nop();
        nop();
        SCI1.SCR.BIT.TE = 1;     // enable transmitter only
        while (send_cnt) {
            while (SCI1.SSR.BIT.TDRE == 0);    // wait for tx ready
            SCI1.TDR = *send_data;
            send_data ++;
            send_cnt --;
        }
        while (SCI1.SSR.BIT.TEND == 0);    // wait for buffer empty
        SCI1.SCR.BYTE = 0;     // disable all

  • The code is very professional and has practical value, thanks JanekD

Reply Children
No Data