Pages: 1 2 3 [4] 5 6 ... 10   Go Down
Author Topic: attiny 85, any pointers?/  (Read 20693 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Srry I meant to post it last post, my phone doesn't seem to want to post it right now, ill tyr again tomorrow on an actual computer
Logged

Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Go Banana!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, can't wait to get this working.
Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

srry for the delay

* ATTINY85MIRF.ino (1.7 KB - downloaded 55 times.)
Logged

Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Go Banana!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No problem. Could I bother you for the receiver code as well?
Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

heres some code that recieves a message and i think replies as ewell as readoff to an lcd, but it is for an uno and doesnt use the attiny85 spi

* mirfreply.ino (2.12 KB - downloaded 36 times.)
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not quite sure what I'm not doing correctly. Hopefully you can help me out. My pin connections:

ATtiny84        -> Nrf24L01+
MISO (PA6) -> MISO
MOSI (PA5) -> MOSI
SCK   (PA4) -> SCK
CSN   (PA3) -> CSN
CE     (PA2) -> CE

The code uploads to the ATtiny84 perfectly well, and seems to be working.

When I run the uno code you provided, though, it fails to detect any data. Here are the connections:

UNO            -> Nrf24L01+
D9               -> CE
D10             -> CSN
D11 (MOSI) -> MOSI
D12 (MISO) -> MISO
D13 (SCK)   -> SCK  

And here is the stripped down code:
Code:
ATTinyMirf.ino

#include <avr/io.h>
#include <inttypes.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <SPI85.h>
#include <Mirf85.h>
#include <nRF24L0185.h>
#include <MirfHardwareSpiDriver85.h>
#include "SoftwareSerial.h"



byte data[32] = {
  'T','T','W','I','R','E','L','E','S','S','Q','Q','Q','Q','Q','Q',
  'Q','Q','R','J','F','E','D','O','R','Q','Q','Q','Q','Q','Q','Q'
};

SoftwareSerial mySerial(9,10);

void setup(){
  mySerial.begin(9600);
  mySerial.write("ATTINY - Setup\n");
  
  // pinMode(3,0);
  pinMode(0, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  // digitalWrite(3,1);
  delay(1000);
  
  Mirf.cePin = 2; //attiny
  Mirf.csnPin = 3; //attiny
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();

  Mirf.setRADDR((byte *)"sendr");
  Mirf.payload = 32;
  Mirf.channel = 8;
  Mirf.setTADDR((byte *)"reply");
  Mirf.send(data);
delay(3000);
mySerial.write("ATTINY - End Setup\n");

}

void loop(){

  delay(1000);
  digitalWrite(0, HIGH);
  mySerial.write("ATTINY - Sending... \n");

  Mirf.send(data);
  digitalWrite(0, LOW);
  delay(100);

  
}


and for the UNO:

Code:
UnoMIRF.ino

//mirf recieve and replay
/*
PIN ||arduino || mirf
 GND ||  GND   ||  1
 VCC ||  5V    ||  2
 CE  ||     9  ||  3
 CSN ||     10 ||  4
 SCK ||     13 ||  5
 MOSI||     11 ||  6
 MISO||     12 ||  7
 IRQ ||  NA    ||  8
 */
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
byte data[32]; //size of payload
void setup(){
  Serial.begin(9600);
  //begin nrf24ll01
  Mirf.cePin = 9; //uno
  Mirf.csnPin = 10; //uno
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();

  Mirf.setRADDR((byte *)"reply");
  Mirf.setTADDR((byte *)"sendr");
  Mirf.payload = 32;
  Mirf.channel = 8;
  Mirf.config();
  Serial.println("Setup finished");
}
void loop(){
  // Serial.print(".");

  if(Mirf.dataReady()){
    Mirf.getData(data);


    delay(50);
    for (int i = 0; i < 32; ++i)
    {
      Serial.print(data[i]);
      Serial.print(",");
    }
    Serial.println();
  }

}



I'm pretty sure the chips themselves work; the RF24 library was able to get the status register of the transceivers, so it must be a problem with the ATtiny and/or Uno code

Thank you again
Logged

Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 41
Go Banana!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm also having an issue getting this working on an ATtiny84. I've had success with the ATtiny85 however. Perhaps there's an error in the library?

Edit: Oh, and of course thanks winner10920 for your code.
« Last Edit: December 18, 2012, 12:48:39 pm by skootles » Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It works well on the 85? I think I'll go ahead and get some of those, then. I assume I'll have to change the pin assignments in the library? From PORTA to PORTB, that is.
Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the library I included a define for the 84, perhaps depending on your method of enabling attiny use on arduino because I based it on the third party source that I used, I believe there are 2-3 different ones, perhaps that's the fault, ill try on an 84 when I get the chance, tho I think someone else said it worked on an 84
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh ya, I forgot to specify that I had to manually comment out the ATTiny "if defined" part in SPI85 because it wasn't recognizing the core as an __AVR_ATtinyX4__. That's probably the problem. So would I use a different ATTiny core or what?

Yea, somebody above got it working on an 84.
Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just change the core name to whichever yours is, youll find the name within the attiny core itself, I found it I think by pin definitions, then it will automatically recognize it
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Right, right. Wait, since I manually commented it out and forced the pin definitions to be for the 84, wouldn't it work already?
I changed
Code:
#if defined( __AVR_ATtinyX4__ )
const static uint8_t SS   = PA7;
const static uint8_t MOSI = PA5;
const static uint8_t MISO = PA6;
const static uint8_t SCK  = PA4;
#endif
To:
Code:
//#if defined( __AVR_ATtinyX4__ )
const static uint8_t SS   = PA7;
const static uint8_t MOSI = PA5;
const static uint8_t MISO = PA6;
const static uint8_t SCK  = PA4;
//#endif
So the pins are definitely correct, I think.
Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anything change when you force the definitions?
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It stops giving me the "SS/MOSI/MISO/SCK is undefined in this context" or whatever messages and compiles perfectly. I had done that previously, so now I don't think that it's related to my problems now. Thanks for helping, by the way.
Logged

Offline Offline
Edison Member
*
Karma: 5
Posts: 1730
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Np, let me know if u figure it out, feels good to know something I made works for other people too lol
Logged

Pages: 1 2 3 [4] 5 6 ... 10   Go Up
Jump to: