tgy icon indicating copy to clipboard operation
tgy copied to clipboard

Firmware not running on selfmade esc. but blink asm test code works

Open gamerpaddy opened this issue 3 years ago • 0 comments

Hello i built my own design esc its got two leds on PC2 and PC3 and runs on a 16mhz crystal, aswell as a dedicated n-fet gate drive ic.

after flashing tgy.asm (compiled obviously) with a slightly modified afro_nfet.inc it doesnt do anything. no fet driving, no leds blinking. no output on uart TX pin.. nothing

i compile with avrasm2 -fI tgy.asm and flash via avrdude -p m8 -c arduino -P COM35 -b 19200 -U flash:w:tgy.hex (using arduino uno as ISP).

ive attached a RC receiver giving out a stable 1000-2000µS signal, still nothing. pin rcp_in on PB0 is receiving the signal.

the crystal is oscillating just fine (16mhz) but i also tried lowering F_CPU to 8M and set fuses to use the internal 8Mhz osc.. no success. theres also no output on UART TX with DEBUG_TX and USE_UART enabled

i tried commented out mux_temperature and mux_voltage in case ive put wrong resistors in there and its going in overtemp or undervoltage protection, but nothing....

i tried changing from RED_on RED_off to BLUE_on BLUE_off led's and swapped green aswell.. also tried turning off CHECK_HARDWARE, turning off the BOOT_LOADER and BOOT_JUMP.. nothing.

Then i tried using my own code to test the actual board if its even working and yes, the board itself is working, i tested it with the same fuses (lfuse 0x3F hfuse=0xCA) aswell as the fuses for the internal 8mhz oscillator, with a bare minimum assembler code thats just toggling all used pins on and off. leds work, fet drive pins work aswell and the driver is switching the fets (at 460khz ... just to see if it works)

i also tried the blueesc fork of sim-/tgy which didnt work either.

any ideas?

this is the test code:


.NOLIST 
.INCLUDE "m8def.inc" 
.LIST 


	sbi DDRC,DDC2 ; Port pins as outputs
	sbi DDRC,DDC3 
	sbi DDRB,DDB1
	sbi DDRB,DDB2
	sbi DDRD,DDD2
	sbi DDRD,DDD3
	sbi DDRD,DDD4
	sbi DDRD,DDD5
	

Loop:
	sbi PORTC,PORTC2 ; led red on
	sbi PORTC,PORTC3 ; led blue on
	;test code to turn fets on/off as fast as possible no motor commutation intended just for testing pins & ports.
	cbi PORTB,PORTB1 ; CH gate driver phase C high off
	sbi PORTD,PORTD2 ; AH gate driver phase A High on
	sbi PORTD,PORTD5 ; CL gate driver phase C low on..
	cbi PORTD,PORTD4 ; BL
	sbi PORTB,PORTB2 ; BH
	cbi PORTD,PORTD2 ; AH
	cbi PORTD,PORTD5 ; CL
	sbi PORTD,PORTD3 ; AL
	cbi PORTB,PORTB2 ; BH
	sbi PORTB,PORTB1 ; CH
	cbi PORTD,PORTD3 ; AL
	sbi PORTD,PORTD4 ; BL
	

	
	cbi PORTC,PORTC2 ; led red  off
	cbi PORTC,PORTC3 ; led blue off
	
	rjmp Loop ; repeat

my afro_nfet.inc looks like this

;*****************************************
;* AfroESC 3                             *
;* 2012-12-02                            *
;* Fuses should be lfuse=0x3f hfuse=0xca *
;*****************************************

.equ	F_CPU		= 16000000
.equ	USE_INT0	= 0
.equ	USE_I2C		= 1
.equ	USE_UART	= 1
.equ	USE_ICP		= 1

.equ	DEAD_LOW_NS	= 300
.equ	DEAD_HIGH_NS	= 300
.equ	MOTOR_ADVANCE	= 15
.equ	CHECK_HARDWARE	= 1

;*********************
; PORT B definitions *
;*********************
;.equ			= 7
;.equ			= 6
;.equ			= 5	(sck)
;.equ			= 4	(miso)
;.equ			= 3	(mosi)
.equ	BpFET		= 2	;o
.equ	CpFET		= 1	;o
.equ	rcp_in		= 0	;i r/c pulse input

.equ	INIT_PB		= (1<<BpFET)+(1<<CpFET)
.equ	DIR_PB		= (1<<BpFET)+(1<<CpFET)

.equ	BpFET_port	= PORTB
.equ	CpFET_port	= PORTB

;*********************
; PORT C definitions *
;*********************
.equ	mux_voltage	= 7	; ADC7 voltage input (18k from Vbat, 3.3k to gnd, 10.10V -> 1.565V at ADC7)
.equ	mux_temperature	= 6	; ADC6 temperature input (3.3k from +5V, 10k NTC to gnd)
.equ	i2c_clk		= 5	; ADC5/SCL
.equ	i2c_data	= 4	; ADC4/SDA
.equ	red_led		= 3	; o
.equ	green_led	= 2	; o
.equ	mux_b		= 1	; ADC1 phase input
.equ	mux_a		= 0	; ADC0 phase input

.equ	O_POWER		= 180
.equ	O_GROUND	= 33

.equ	INIT_PC		= (1<<i2c_clk)+(1<<i2c_data)
.equ	DIR_PC		= 0

.MACRO RED_on
	;sbi	DDRC, red_led
.ENDMACRO
.MACRO RED_off
	;cbi	DDRC, red_led
.ENDMACRO
.MACRO GRN_on
	;sbi	DDRC, green_led
.ENDMACRO
.MACRO GRN_off
	;cbi	DDRC, green_led
.ENDMACRO

;*********************
; PORT D definitions *
;*********************
.equ	mux_c		= 7 ;(comparator AN1)
.equ	sense_star	= 6 ;(comparator AN0)
.equ	CnFET		= 5
.equ	BnFET		= 4
.equ	AnFET		= 3
.equ	ApFET		= 2
.equ	txd		= 1
.equ	rxd		= 0

.equ	INIT_PD		= (1<<ApFET)+(1<<txd)
.equ	DIR_PD		= (1<<AnFET)+(1<<BnFET)+(1<<CnFET)+(1<<ApFET)+(1<<txd)

.equ	AnFET_port	= PORTD
.equ	BnFET_port	= PORTD
.equ	CnFET_port	= PORTD
.equ	ApFET_port	= PORTD

gamerpaddy avatar Aug 06 '21 11:08 gamerpaddy