Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

ADCS7476 problem on programming

Status
Not open for further replies.

satria02

Junior Member level 2
Joined
Apr 22, 2011
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Bandung
Activity points
1,467
Hi....

i want to use ADCS7476 (ADC 12 bits, 1MSPS) to convert analog signal to digital signal to be processed on microcontroller (i use microcontroller AVR ATmega8535), but i get problem on programming of this ADC....

using I2C or SPI....?

i was also browsing on internet, but i can't found the sample program of this ADC (ADCS7476), i look for C programming (AVR-GCC)...

thanks before


best regards,
Satria
 

panos_papajohn

Member level 2
Joined
Mar 18, 2011
Messages
46
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,640
Satria you should use the SPI since that the interface that the ADC supports. Look at this link for help with the coding AVR Freaks

panos_papajohn
 

satria02

Junior Member level 2
Joined
Apr 22, 2011
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Bandung
Activity points
1,467
i want to use two ADCS7476 which was read at the same time, and then be displayed on LCD (i use LCD graphic on this case)

this is my schematics design
MCU_ATmega32.pdf

and this is my list program...

#include <avr/io.h>
#include <avr/iom8535.h>
#include <stdio.h>
#include "T6963C.h"
#include "graphic.h"
#include <util/delay.h>

#define DD_MISO PD4
#define DD_SCK PD6
#define DDR_SPI DDRD
#define PORT_SPI PORTD
#define DD_CS PD5

#ifndef F_CPU
//define cpu clock speed if not defined
#define F_CPU 16000000

#endif

unsigned char i,coba;
unsigned int data;
char lcd_buffer[30];
char data_buf[20];

void GLCD_start()
{
GLCD_Initalize(); // Initalize LCD
GLCD_ClearText(); // Clear text area
GLCD_ClearCG(); // Clear character generator area
GLCD_ClearGraphic(); // Clear graphic area
}

void SPI_MasterInit(void)
{
// Set MOSI and SCK output, all others input
DDR_SPI = (1<<DD_CS)|(1<<DD_SCK);
// Enable SPI, Master, set clock rate fck/16
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
}

char SPI_SlaveReceive(void)
{
PORT_SPI = (0<<DD_CS);
while(!(SPSR & (1<<SPIF)));
return SPDR;
}

int main(void)
{

PORTA = 0xFF;
DDRA = 0xFF;

PORTC = 0xFF;
DDRC = 0xFF;



/*
asm volatile (
"in r30,spsr"
"in r30,spdr"
);
*/

GLCD_start();
SPI_MasterInit();
i = 1;
coba = 0xAC;

while(i < 5)
{
GLCD_TextGoTo(0,i);
GLCD_WriteString("rosya satria");
i++;
_delay_ms(10);
}
sprintf(lcd_buffer,"ROSYA SATRIA FIRDHAUST");
GLCD_TextGoTo(0,6);
GLCD_WriteString(lcd_buffer);

GLCD_Rectangle(1,1,238,126);


data=SPI_SlaveReceive();
sprintf(data_buf," %u", data);
GLCD_TextGoTo(0,9);
GLCD_WriteString(data_buf);

while(1);
return 0;
}

on this program, i try to access one ADCS7476, but still can't access it...
can you tell me what is the problem of this case?

thanks.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top