Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

using AVR GPIO PINs to send and receive DATA

Status
Not open for further replies.

firstoption

New Member
Please i need your support on how to put these codes together.I am using Attiny24A to read Temperature from a temperature sensor and i want to send these Temperature value to the Computer through Attiny4313.I have two GPIO Pins from Attiny24A connected to two GPIO Pins of Attiny4313.
My question is that is it possiple to use These GPIO Pins to send and receive data.The program below was written to Attiny24A
Code:
DDRB|= (1<<PORTB1); //Attiny24A(PB1) as Output Pin(to send DATA)
DDRA|= (1<<PORTA7); //Attiny24A(PA7)as Output Pin(for clocking the DATA)
void ClearClock()
{
 PORTA &= ~(1 << PA7);  // Set PB1 LOW
}
void SetClock()
{
 PORTA |= (1 << PA7);  // Set PB1 HIGH
}
void ToggleClock()
{
 _delay_us(50);
 SetClock();
 _delay_us(50);
 ClearClock();
 clockcount++;
}
void SetData()
{
 PORTB |= (1 << PB1);  // Set PB1 HIGH
}
void ClearData()
{
 PORTB &= ~(1 << PB1);  // Set PB1 LOW
}
void Send_ObjTemp_8bit(unsigned int data10)
{
 int i=7;
 do
 {
 if (((data10 & (1<<i))>>i) == 1)
 SetData();
 else
 ClearData();
 ToggleClock();
 i=i-1;
 }
 while (i >= 0);
}
int  main( void )
{
 
 DDRB|= (1<<PORTB1); //µC Data_Out
 DDRA|= (1<<PORTA7); //µC Clock_In
  
  sei();
  setup();
  
  
  
  while(1)
  {
 
 Send_ObjTemp_8bit(Tobj);
 
  
  } 
}
---------------------------------------------------
The program below was written to Attiny4313
Code:
DDRB &= ~(1 << PB1);//Attiny4313(PB1)as Input Pin(to receive the temperature value from attiny24A)
int  main( void )
{
  unsigned int TempValue;  
  
  while(1)
  {
  TempValue=PINB1;
 
  USART_Transmit( TempValue) //this function sends the temperature value to the Computer. 
   
  
  } 
}
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top