hey, i am configuring dac through microcontroller TM4C123gH6pge. but my dac was not showing proper sinosuidal wave( as required).
on testing by outputting different values from the pins, i got the following results:
Decimal voltage(volts)
value
0 0
16 0.024
32 0.060
64 0.14
128 0.24
256 0.48
512 0.96
768 1.5
896 1.7
960 1.8
992 1.9
1024 4.7
1536 4.8
2048 4.9
4095 4.93
on reaching 1024, the voltage level shoots up to 4.7 volts from ~2 volts.
here is the code to configure and outputting the data:
void dac_dataOut(short int data){
// PD = PJ7 always high
// LDAC = PJ6
// WE = PJ5
// CS = PJ4
// D0-3 = PJ0-3
// D4-11 = PN0-7
// data .. CS = 0 .. WE = 0 .. wait 13ns .. WE = 1 .. LDAC = 0 .. wait 25ns .. CS = 1 .. LDAC = 1
GPIO_PORTJ_DATA_R |= 0x80; // PD = PJ7 always high
data=0x0600; //putting different test values here
GPIO_PORTJ_DATA_R = GPIO_PORTJ_DATA_R & (0xF0 | (data & 0x0F)); //set D0-3
GPIO_PORTN_DATA_R = data >> 4; //set D4-11
d=(GPIO_PORTN_DATA_R<<4)| (GPIO_PORTJ_DATA_R &0x0F);
GPIO_PORTJ_DATA_R &= ~0x30; // CS = 0, WE= 0
GPIO_PORTJ_DATA_R |= 0x20; // WE= 1
GPIO_PORTJ_DATA_R &= ~0x40; // LDAC = 0
GPIO_PORTJ_DATA_R |= 0x50; // CS = 1, LDAC = 1
}
other pins: VDD=5V, refin=2V, GND=0V.
so, any idea guys, whats the problem thats causing that discontinuity at 1024 value?
data=0x0600;
GPIO_PORTJ_DATA_R = GPIO_PORTJ_DATA_R & (0xF0 | (data & 0x0F)); //set D0-3
GPIO_PORTN_DATA_R = data >> 4; //set D4-11
d=(GPIO_PORTN_DATA_R<<4)| (GPIO_PORTJ_DATA_R &0x0F);
GPIO_PORTJ_DATA_R &= ~0x30; // CS = 0, WE= 0
GPIO_PORTJ_DATA_R |= 0x20; // WE= 1
GPIO_PORTJ_DATA_R &= ~0x40; // LDAC = 0
GPIO_PORTJ_DATA_R |= 0x50; // CS = 1, LDAC = 1