Hello
The ADS1262 is reading successifully if the gain is 1 and the PGA is pypassed(MODE2 = 0x80)
changing the MODE2 register to any other value will result in noisy unpredictable results .
I want to use PGA = 32 .Please help.
attached is the liberar that I used to read the chip.
#include "ADS126X.h" #include "stdio.h" #include "ADC_Definitions.h" #include "main.h" #include "delay.h" uint8_t ADS126X_recBuffer[7]; int adcenable_flag; void ADS126X_soft_spi() { START_0() ; RESET_1(); CS_1(); SCK_0(); } // TO DO measure the timing void ADS126X_DelaySCLK(uint8_t clks)//debug { uint16_t i; for (i = 0; i < 3 * clks; i++);//old value 3 } void ADS126X_DelayDATA(void) { delay_us(6); } void ADS126X_Send_8Bit(uint8_t _data) { uint8_t i; ADS126X_DelayDATA(); for (i = 0; i < 8; i++) { SCK_1(); if (_data & 0x80) { DI_1(); } else { DI_0(); } _data = _data << 1; ADS126X_DelaySCLK(1); SCK_0(); ADS126X_DelaySCLK(1); } } uint8_t ADS126X_Recive_8Bit(void) { uint8_t i; uint8_t read = 0; ADS126X_DelayDATA(); for (i = 0; i < 8; i++) { SCK_1(); read = read << 1; ADS126X_DelaySCLK(1); SCK_0(); read = read | Read_DO(); ADS126X_DelaySCLK(1); } return read; } void ADS126X_Init(void) { ADS126X_soft_spi(); } /* write a command to ADS126X1a02 */ void ADS126X_WRITE_CMD(uint8_t command) { CS_0(); delay_us(10); ADS126X_Send_8Bit(command); CS_1(); delay_us(10); } /***************************************************************************************** * Function Name: ADS126X_RREG * Description : Read Reg * Arguments : address: Reg Address� * Return Value : Reg Value ******************************************************************************************/ uint8_t ADS126X_RREG(unsigned char address) { unsigned char temp = 0x00; unsigned char receive = 0x00; temp = ADS126X_RREG_COMMAND | address; //0X20|REG CS_0(); delay_us(10); ADS126X_Send_8Bit(temp);//001r rrrr, where r rrrr is the starting register address. ADS126X_Send_8Bit(0x00);//000n nnnn, where n nnnn is the number of registers to read �C 1. receive = ADS126X_Recive_8Bit(); CS_1(); delay_us(10); return receive; //�return reg value . } /***************************************************************************************** * Function Name: ADS126X_WREG * Description : д�뵥��ADS126X1�ڲ��Ĵ� * Arguments : address:�Ĵ�����ַ data:д������ * Return Value : �� ******************************************************************************************/ void ADS126X_WREG(unsigned char address, unsigned char data) { unsigned char temp = 0x00; temp = ADS126X_WREG_COMMAND | address; //0X40|REG CS_0(); delay_us(10); ADS126X_Send_8Bit(temp); //001r rrrr, where r rrrr is the starting register address. ADS126X_Send_8Bit(0x00); //000n nnnn, where n nnnn is the number of registers to read �C 1. ADS126X_Send_8Bit(data); delay_us(10); CS_1(); delay_us(10); } /***************************************************************************************** * Function Name: ADS126X_PowerOnInit * Description : ADS126X�ϵ縴λ * Arguments : NONE * Return Value : NONE ******************************************************************************************/ int adcenable_flag; void ADS126X_PowerOnInit(void) { uint8_t RECEIVE = 0X00; //����spi���ص��ַ� uint8_t ID; ADS126X_Init(); delay_ms(20); ADS126X_WRITE_CMD(ADS126X_RESET_COMMAND); //RESET ADS126X1 ID = ADS126X_RREG(ADS126X_ID); //SET MODE0 ADS126X_WREG(MODE0, 0X10); //chopper enabled //SET MODE2 ADS126X_WREG(MODE1, 0X60); //Sinc4 mode //SET MODE2 ADS126X_WREG(MODE2, 0X90); //Positive:2.5SPS /gain 2 //SET POWER ADS126X_WREG(POWER, 0X11); //Internal reference enabled (default) //SET REFMUX ADS126X_WREG(REFMUX, 0X00); //Internal 2.5 V reference //SET INPMUX ADS126X_WREG(INPMUX, 0X76); //Positive:7 Negative:6 // ADS126X_WREG(INPMUX, 0X54); //Positive:5 Negative:4 //CHECK THE REGS RECEIVE = ADS126X_RREG(INPMUX); RECEIVE = ADS126X_RREG(MODE2); //Start ADC1 conversions ADS126X_WRITE_CMD(ADS126X_START1_COMMAND); adcenable_flag = 1; } void ADS126X_Start_ADC1() { START_1() ; ADS126X_DelaySCLK(4) ; //wait for 4 clocks START_0() ; } void ADS126X_Read_BUFFER_DATA(void) { uint8_t i = 0; CS_0(); for(i = 0; i < 7; i++) { ADS126X_recBuffer[i] = ADS126X_Recive_8Bit(); } CS_1(); } unsigned long ADS126X_Read_Value(void) { unsigned long value = 0; union { unsigned long voltage; struct { unsigned char frist; unsigned char second; unsigned char three; unsigned char four; } byte; } volt; while( DR_IS_HIGH()); delay_ms(10); ADS126X_Read_BUFFER_DATA(); volt.byte.frist = ADS126X_recBuffer[4]; volt.byte.second = ADS126X_recBuffer[3]; volt.byte.three = ADS126X_recBuffer[2]; volt.byte.four = ADS126X_recBuffer[1]; value = volt.voltage; return value; }