plese help me

General discussion on mikroC PRO for AVR.
Post Reply
Author
Message
azr536
Posts: 4
Joined: 04 Jun 2014 18:48

plese help me

#1 Post by azr536 » 04 Jun 2014 21:34

hi:
I need to communicate with ADE7758
Using SPI
I need the settings below.
1- SPI mode = master
2- Clock rate= 4
3-clock polarity=Low
4-data order = MSB
5- interrupt=on
6-sample on = rising edge

i want send one byte 0x14 to ade7758 ,
and i know i should recive 0xfc and i write program wait "SPI1_Init " and "SPI1_Init_Advanced"
but i can not recive any action from my slave device.
mybe help me write for me wait it setting

1- SPI mode = master
2- Clock rate= 4
3-clock polarity=Low
4-data order = MSB
5- interrupt=on
6-sample on = rising edge

thank you

bpislife
Posts: 539
Joined: 11 Jun 2006 21:16
Location: Cumberland, RI

Re: plese help me

#2 Post by bpislife » 21 Jun 2014 04:35

If you post your code we may be able to help.

azr536
Posts: 4
Joined: 04 Jun 2014 18:48

Re: plese help me

#3 Post by azr536 » 22 Sep 2014 11:53

hi:
thank you for your answer.
it is my program for start spi .


sbit buzer at PORTB.B3;
sbit led at PORTA.B4;
sbit bllcd at PORTA.B5;
// NAME FOR INPUT
/*sbit key1 at PINA0_BIT;
sbit key2 at PINA1_BIT;
sbit key3 at PINA2_BIT;
sbit key4 at PINA3_BIT;*/
/// Glcd module connections
char GLCD_DataPort at PORTC;
char GLCD_DataPort_Direction at DDRC;


sbit GLCD_CS1 at PORTD3_bit;
sbit GLCD_CS2 at PORTD4_bit;
sbit GLCD_RS at PORTD7_bit;
sbit GLCD_RW at PORTD6_bit;
sbit GLCD_EN at PORTD5_bit;
sbit GLCD_RST at PORTD2_bit;

sbit GLCD_CS1_Direction at DDD3_bit;
sbit GLCD_CS2_Direction at DDD4_bit;
sbit GLCD_RS_Direction at DDD7_bit;
sbit GLCD_RW_Direction at DDD6_bit;
sbit GLCD_EN_Direction at DDD5_bit;
sbit GLCD_RST_Direction at DDD2_bit;


sbit Chip_Select at PORTB4_bit;
sbit SoftSpi_CLK at PORTB7_bit;
sbit SoftSpi_SDI at PINB5_bit; // Note: Input signal
sbit SoftSpi_SDO at PORTB6_bit;

sbit Chip_Select_Direction at DDB4_bit;
sbit SoftSpi_CLK_Direction at DDB7_bit;
sbit SoftSpi_SDI_Direction at DDB5_bit;
sbit SoftSpi_SDO_Direction at DDB6_bit;


SPI1_Init(); // Initialize SPI1 module


char buffer[50];
char temp;


void main()
{ unsigned char i;
Glcd_Init(); // Initialize GLCD
Glcd_Fill(0x00);

DDA0_bit= 0;
DDA1_bit= 0;
DDA2_bit= 0;
DDA3_bit= 0;
oldstate0=0;
oldstate1=0;
oldstate2=0;
oldstate3=0;
DDB3_bit=1; //OUT Buzer
DDA4_bit=1; //OUT LED
DDA5_bit=1; //OUT BLLcd


i=0;
buzer=1;
bllcd=0; // back light lcd on
do{
buzer=1;
delay_ms(500);
buzer=0;
delay_ms(10);
Glcd_Write_Text("START", 5, 1, 1);

sprintf(buffer, "code = %d", i);
glcd_Write_text(buffer, 10, 4, 1);
i=i+1;
SPI1_Write(i);

}while(1);




}

Post Reply

Return to “mikroC PRO for AVR General”