Table of Contents        Previous topic       Next topic       

The Extension Interface->General Purpose Interface Calls->SetWaveForm

extern "C" void SetWaveForm(LONG nExtensionState, BYTE nPortAddress, BYTE nCount[8], BYTE* pWaveForm[8])

The SetPortPins() function is capable of handling transitions generated by the 8051 program when it writes to ports.  However, when the chip generates PWM output, pin transitions can occur faster than the calls to SetPortPins().  PWM output is therefore sent to the extensions using the SetWaveForm() call.

nPortAddress is the sfr address of the 8 bit port and arrays of output data are provided for each pin.

The nCount array contains the number of entries in the eight pWaveForm arrays.  For instance if nCount[0] is six, then the timer generating the waveform for pin 0 has clocked six times since the last call to SetWaveForm and pWaveForm[0] points to an array of six bytes containing 1's and 0's depending on the level on pin 0 at each clock transition.

nCount[i] will contain zero if there is no PWM output on pin i.

SetWaveForm() will not be called if none of the timers generating PWM signals for this port are running but it will be called if a timer is running and there have been no clock transitions (ie the clock it running too slow to have generated and data for this call to SetWaveForm).  In this case the nCount array entries for the appropriate pins will be zero.

Note that if the microcontroller generates PWM output in a pin that is not an 8 bit wide port that has an SFR address, then the extension for this variant may map that output to an 8 bit port pin.  See the documentation for the variant extension for specific details.