Shop OBEX P1 Docs P2 Docs Learn Events
Programming the ATtiny84 with the Propeller (working) — Parallax Forums

Programming the ATtiny84 with the Propeller (working)

Cluso99Cluso99 Posts: 18,069
edited 2013-11-15 21:57 in Propeller 1
I have a tiny (pun intended) Avr board to plug into a propeller board as an add-on. I intend it to communicate with the propeller by either serial or I2C. Jazzed has already proved I2C works to the Propeller, having placed a PS2 Keyboard and Mouse on the other end of the ATtiny.

My board (Cluso's AvrBlade) is 1"x1" and has provision for an ATtiny85 (8pin) and/or an ATtiny84 (14pin) and a 3V3 regulator.

Both AVRs have 4pin headers for programming them and I intend to ultimately program them with the Propeller. Communications to the propeller is intended to be via the SDA & SCL pins on each ATtiny.

The ATtiny85 brings out 2 ADCs to header pins and the ATtiny84 brings out 4 ADCs to header pins and a further 4 I/Os to header pins.

From research, the PropPlug and FT232RL may or may not work. The Propeller will certainly be able to program the ATtiny in ISP SPI mode.

Just before I start on my programming attempts, and not wishing to reinvent the wheel...

1. Has anyone programmed an ATtiny (or any AVR in ISP mode) with the Propeller?

2. Has anyone programmed an ATtiny with a PropPlug or FT232RL based board?

Postedit: I have now programmed the ATTiny84 successfully with the Propeller chip. Code is attached to post #14.

Comments

  • jazzedjazzed Posts: 11,803
    edited 2011-09-25 09:26
    I would like to help, but I'm buried in other projects. Programming with ISP would be good. ... didn't Phil Pilgrim have an atTiny16 programmer on one of the BasicStamp boards?
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-09-25 19:26
    jazzed: I am in the chicken-and-egg situation. I need a hex file known to work to flash a led on one of the pins other than the ISP programming pins for the attiny84. Could you do me one please??? Then I will know that the code at least works and it will be my prop code at fault. i.e. I do not have a programer to begin with.
  • LeonLeon Posts: 7,620
    edited 2011-09-25 19:41
    Here's a test program of mine for the similar Tiny45 that you can assemble with AVR Studio:
    ;test.asm
    ;test program for ATtiny45
    ;
    ;Clock: internal 8 MHz RC oscillator
    
    
      	#include "tn45def.inc"
    
        .def	temp=r16
    	.def	counter=r17
    
    	#define LED PB3				; pin 2
    	#define Delay_count 6
    
    	.cseg
    	.org	0x0000
    	rjmp 	RESET ; Reset Handler
    	rjmp 	EXT_INT0 ; IRQ0 Handler
    	rjmp 	PCINT0 ; PCINT0 Handler
    	rjmp 	TIM1_COMPA ; Timer1 CompareA Handler
    	rjmp 	TIM1_OVF ; Timer1 Overflow Handler
    	rjmp 	TIM0_OVF ; Timer0 Overflow Handler
    	rjmp 	EE_RDY ; EEPROM Ready Handler
    	rjmp 	ANA_COMP ; Analog Comparator Handler
    	rjmp 	ADC_CONV ; ADC Conversion Handler
    	rjmp 	TIM1_COMPB ; Timer1 CompareB Handler
    	rjmp 	TIM0_COMPA ;
    	rjmp 	TIM0_COMPB ;
    	rjmp 	WDT ;
    	rjmp 	USI_START ;
    	rjmp 	USI_OVF ;	
    
    RESET:
    	ldi		temp,low(RAMEND)	;initialise stack
    	out		spl,temp
    	ldi		temp,high(RAMEND)
    	out		sph,temp
    	sbi		DDRB,LED		;PB3 output (LED)
    	sbi		PORTB,PB2		;PB2 input with pullup
    	cbi		DDRB,PB2
    
    	; set up Timer/Counter 0
    	ldi 	Temp,0x05		;1/1024 prescale
    	out 	TCCR0B,Temp 
    	ldi 	Temp,1<<TOV0	;Clear TOV0/ clear pending interrupts
    	out 	TIFR,Temp 		
    	ldi 	Temp,1<<TOIE0	;Enable Timer/Counter0 Overflow Interrupt
    	out 	TIMSK,Temp 		
    	ldi		Temp,Delay_count;init. delay count
    	out		TCNT0,Temp
    	ldi		r19, 1<<LED
    	clr		r18
    	sei						; global enable interrupts	
    	
    
    loop:
    	cpi		counter, 5
    	brne	loop1
    	clr		counter
    	eor		r18,r19
    	out		portb,r18
    loop1:
    	rjmp	loop
    
    ; Timer0 Overflow Handler
    TIM0_OVF:
    	push	temp
    	in		temp,SREG
    	push	temp 
    	inc		counter	
    	ldi		temp,Delay_count
    	out		TCNT0,temp
    	pop		temp
    	out		SREG, temp
    	pop		temp
    	reti
    
    
    EXT_INT0: 		; IRQ0 Handler
    TIM1_COMPA:
    TIM1_OVF:
    EE_RDY:
    ANA_COMP:
    ADC_CONV:
    TIM1_COMPB:
    TIM0_COMPA:
    TIM0_COMPB:
    WDT:
    USI_START:
    USI_OVF:
    	reti
    
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-09-26 01:12
    thanks Leon. I will try when I return home. Interstate. Atm.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-10-16 07:02
    Today I have the prop identifying the attiny84 signature and reading the fuses, cal, lock bits using the spi style ISP. It does not seem to be true spi.

    Next is to program a simple led flash program to verify the actual programming works from the prop.
  • jazzedjazzed Posts: 11,803
    edited 2011-10-16 11:47
    Cluso99 wrote: »
    Today I have the prop identifying the attiny84 signature and reading the fuses, cal, lock bits using the spi style ISP. It does not seem to be true spi.

    Next is to program a simple led flash program to verify the actual programming works from the prop.
    Congratulations. Good luck with the next step.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-10-16 14:28
    If you have a parallel port available then a few resistors and caps can prop the AVRs, but there is a problem with signal spikes etc that can cause double clocking,and othe horrors, and so fails. The addition of a couple of hundred of pF after the resistors reduces the cable interface ringing effect.

    I use Pony Prog and a serial interface or USBASP, http://www.fischl.de/usbasp/ (But there are those chickens and pre-chickens again).
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-10-16 17:29
    toby: What are these "old" things called parallel ports??? (hehe) Unfortunately, no parallel or serial ports on any of my current laptops :( And I would have to dig out my trusty very old and archived pcs to get at these.

    I have a simple led flash program (in C) and I have a small hex file for this... Well 160B just to make an output and alternate with a delay! Hope it works because I am just going to hardcode the programming (cut & paste) of the hex file to prove the programming works. Report back shortly ;)
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-10-16 23:02
    That just about sums up my level of technology, I do not own a computer, laptop (P3 Dell, my old favourite) or desk, that doesn't have a parallel port!

    It is a pity that the one port that was one of the first requisites on a home computer is now dropped, it prevents so many little interface kludges. On our works laptop I had to argue for one that had a real serial port and not rely on those USB adaptors that have a 50/50 chance of working with propriatry/older software.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-10-17 00:08
    Well here is code that programs the ATTiny84 (all in spin). I just have fixed timing larger than what is required. Its a kludge and just copies the hex file which I inserted as a DAT set of bytes. The program erases the chip first. Output info is via the serial port and FDX & PST.

    Unfortunately, while the programming is correctly verified, the attiny program does not work properly. The led is on permanently. I have also attached the C code too in case someone can see what is wrong.
    AVRtest001.c
    ATTinyISP_011.spin
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2011-10-17 01:09
    Presumably it's for the Attiny84, which does have a PortA.

    I have never played with the t84 though, t45s were "costless" to me a while back, so I have had a few of those.
  • LeonLeon Posts: 7,620
    edited 2011-10-17 01:16
    I can't see anything wrong with it, and it simulates OK.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-10-17 02:31
    SUCCESS ;)

    Not sure what was wrong with the AVR C code. I rewrote using just a register instead of the delay calls and it works!

    Here is the full code to read the various config bytes, flash and eeprom from the ATTiny84, erase, and program it. The hex file is in the DAT section, along with the AVR C source code.

    Since I have a 3V3 regulator on my little avr pcb, no resistors are required on the 4 interface pins.

    And here is a pic of my AvrBlade pcb. It is 1"sq and stacks onto my other boards. While you cannot see the ATTiny84 (14 pin SOIC), you can see provision for the ATTiny25/45/85. Next to program the ATTiny85.
    cluso's AvrBlade 002.JPG

    ATTinyISP_012 - Archive [Date 2011.10.17 Time 20.15].zip
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-11-15 15:42
    Not sure but I don't seems to get mine working. I reckon you copied avr.hex into the Hex section in DAT, right?
  • jmgjmg Posts: 15,173
    edited 2013-11-15 16:30
    I see Atmel now have a new ATtiny841 (AVR core, 14 pins SO), and SiLabs have a C8051F860 (51 core), in SO16 with 12b ADC
    The F860 is slightly cheaper, ~80c 1+ at Mouser, and can be programmed over the 2 wire C2D interface, but would need a code change from the SPI-AVR pgm.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2013-11-15 17:34
    jmg wrote: »
    I see Atmel now have a new ATtiny841 (AVR core, 14 pins SO), and SiLabs have a C8051F860 (51 core), in SO16 with 12b ADC
    The F860 is slightly cheaper, ~80c 1+ at Mouser, and can be programmed over the 2 wire C2D interface, but would need a code change from the SPI-AVR pgm.

    I have Tachyon code that programs the Silabs parts on the C2 interface. I normally communicate with these chips over I2C so what I do is tie the C2D line to the SDA line and then I only need one dedicated Prop I/O for the C2RST line. The trouble I find with Silabs parts is that there is never any real stock anywhere, I mean Digikey has a whopping great stack of 48 chips, you heard it boys and girls, 48 chips, come and get it.
  • jmgjmg Posts: 15,173
    edited 2013-11-15 20:15
    I have Tachyon code that programs the Silabs parts on the C2 interface. I normally communicate with these chips over I2C so what I do is tie the C2D line to the SDA line and then I only need one dedicated Prop I/O for the C2RST line.

    Useful info.
    The trouble I find with Silabs parts is that there is never any real stock anywhere, I mean Digikey has a whopping great stack of 48 chips, you heard it boys and girls, 48 chips, come and get it.

    that's for the B revision, the C revision most would prefer is showing (wait for it) 42 at Mouser.
    Mouser says 3 weeks FLT and Digikey gave me a date of 27 Dec when I entered 1008 units.

    Mouser do show for the

    C8051F850-C-GU 8kB/512B RAM, ADC, QSOP24
    23 Can Ship Immediately 168 On Order Estimated Ship Date 168 11/29/2013
    - but you are right, all toe-in-the-water volumes.

    Given this makes a nice 12b ADC, the micro almost comes for free..
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-11-15 21:57
    MacTuxLin wrote: »
    Not sure but I don't seems to get mine working. I reckon you copied avr.hex into the Hex section in DAT, right?
    Yes, that is what I did.
Sign In or Register to comment.