21.4.1.7 Synchronous Transmitter Mode

The module can be alternatively configured as a synchronous transmitter. In this mode, the module will transmit only one message frame each time the SYNCTXEN bit (SENTxSTAT[0]) is set. When the data frame is complete, the SYNCTXEN bit will be cleared in hardware. The line will be driven low for five ticks to complete the CRC nibble and then the line will tri-state and remain in the Idle state until SYNCTXEN is set again. An interrupt is generated, five ticks after the completion of the CRC nibble. Figure 21-6 shows the relationship between the control, status and interrupt events.

Figure 21-6. SENTx Data Transmission, Synchronous Mode
To fully configure the module, the following must be known:
  • Tick Time, TTICK (Equation 21-1)
  • Number of Data Nibbles
  • Hardware or Application Calculated CRC
To initialize the module for synchronous transmission:
  1. Clear the RCVEN bit (SENTxCON1[11]) for Transmit mode.
  2. Set the TXM bit (SENTxCON1[10]) for synchronous transmit operation.
  3. Write the desired data frame length to NIBCNT[2:0] (SENTxCON1[2:0]).
  4. Set or clear CRCEN (SENTxCON1[8]) to configure the module for hardware or software CRC calculation.
  5. Write the desired value for TICKTIME to SENTxCON2.
  6. Enable the SENT interrupts and set the interrupt priority.
  7. Set the ON bit (SENTxCON1[15]) to enable module.
When the application is ready to transmit data:
  1. Write the data to be transmitted to the SENTxDAT register.
  2. Set the SYNCTXEN bit to begin transmission.

Updates to SENTxDAT must be performed after the completion of the CRC and before the next message frame’s status nibble. The recommended method is to use the message frame completion interrupt or poll the SYNCTXEN bit.

Note: Software may need to wait additional time before starting a new message frame. The J2716 specification allows up to 18 μs of rise time on the SENT data line. The rise time will be a function of the external pull-up resistor and EMI filtering on the SENT data line. It is recommended that the wait time be longer than one Sync time of 56 ticks + 20%.

SENT1 Synchronous Transmission Code

#include <stdio.h>
#include <stdlib.h>
#include <xc.h>
#define mFclk (4E+6)
#define mTickTime (70E-6)
#define mFrameTime (25E-3)
int main(void) {
    _RP23R = 57; // Assign SENT1OUT to pin RP23
    SENT1CON1bits.RCVEN = 0; // Module operates as a transmitter
    SENT1CON1bits.TXM = 1; // Synchronous Transmit
    SENT1CON1bits.NIBCNT = 6; // 6 data nibbles per data packet
    SENT1CON1bits.CRCEN = 1; // CRC is calculated using the J2716 method
    SENT1CON1bits.PPP = 1; // SENTx messages transmitted with Pause Pulse
    SENT1CON1bits.PS = 0; // Module clock is FSENT
    SENT1CON2 = ( (mTickTime * mFclk) - 1); // TICKTIME
    SENT1CON3 = ( mFrameTime / mTickTime) ; // FRAMETIME
    _SENT1IE = 1; // Enable SENT1 interrupt
    _SENT1IP = 4; // SENT interrupt priority
    SENT1DATbits.STAT = 0; // Status Nibble
    SENT1DATbits.DATA1 = 1; // Data Nibble 1
    SENT1DATbits.DATA2 = 2; // Data Nibble 2
    SENT1DATbits.DATA3 = 3; // Data Nibble 3
    SENT1DATbits.DATA4 = 4; // Data Nibble 4
    SENT1DATbits.DATA5 = 5; // Data Nibble 5
    SENT1DATbits.DATA6 = 6; // Data Nibble 6
    SENT1CON1bits.ON = 1; // Enable SENT module
    SENT1STATbits.SYNCTXEN = 1; // Initiate Synchronous Transmission
    while(1);
    return 0;
}
void __attribute__((__interrupt__,__auto_psv__)) _SENT1Interrupt (void)
{
    _SENT1IF = 0; // Clear interrupt flag
    // Update SENT1DAT here
}