This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DAC module issue (89LPC935)

I wrote a simple code for output both channels to an osciloscope. But DAC module 0 P2.0 waveform(sawtooth) is much distorted. The other DAC module 1 (P0.4) outputs a perfect sawtooth. Any ideas (?) By the way i am sure it is not the code or the Tektronix oldwolf oscilloscope :(

Take a look at the code :

#include <REG935.H>

void main()
{
        unsigned char data x;
        //configure Port 2 as quasi-bidirectional
        P2M1 = 0x00;
        P2M2 = 0x00;

        //Configure the DAC
        ADCON0 = 0x04;          //AD0 enabled
        ADCON1 = 0x04;          //AD1 enabled
        ADMODB = 0x0C;          //DAC mode for ADC0 & 1

        //Sawtooth wave generation
        while(1)
        {
                for(x=0; x<256; x++)
                {
                        AD0DAT3 = x;    //write to conversion register
                        AD1DAT3 = x;    //write to conversion register
                }
        }
}

.


0