Hi Guys,
I am hoping someone can help me.
I am programming a very small file into an atmega328pb.
The program is only to test each pin to ensure the board connections are good after
soldering the atmega328pb (QFN) to the board with a modded toaster oven.
The board is a very small castellated board with an atmega328pb in a QFN package.
I built a castellated board adapter to plug in the small board before it is installed on the main board.
Just for the record, I am not programming the fuses and this is not a fuse problem.
Before any soldering has taken place, I take a virgin m328pb (with factory fuses)
and insert it into a QFN adapter board with an ISP connector and it's own crystal
or without the crystal, depending on the fuses.
I can program the fuses or leave them factory, this isn't the problem.
If I want to use the crystal on my test board, the fuses values I am using are:
FuseL: 0xF7, FuseH: 0xDF, FuseExt: 0xF7.
I can program any code into the atmega328pb and it works.
If I program this code (see below) into the atmega328pb, the ISP programming no longer works.
I then have to put the QFN adapter in my parallel programmer to erase the atmega328pb
(because the code is doing something to prevent ISP from working).
I am using the adapter to ensure something doesn't go wrong before I solder the QFN device to the board,
because then it's impossible to fix when you can't use ISP programming!
Reading the chip with the parallel programmer i can see that the fuses have not changed,
however the chip is undetectable in ISP mode with this code installed which is why I have to erase it in parallel mode.
ISP is restored once the chip is erased.
Any other code I have programmed is working, and does not prevent ISP from working.
I can erase and program the device numerous times without problems.
I am not using PB6 & PB7 (xtal1 & xtal2) nor am I using PC6 in my code.
(RSTDISBL is not programmed.)
this is the code I am using:
; ;Simple program to test castellated board connections ;after m328pb QFN installation ; .nolist .include "m328pbdef.inc" .list ; ;*********************************************************** ;for long delays .def dcount =r5 .def dcount2 =r6 .def dcount3 =r7 .def dcount4 = r8 ; .def count = r15 .def temp = r16 ; ;program fuses atmega328pb: ;low: 0xF7 ;high: 0xDF ;ext: 0xF7 ;--------------------------------------------------------- .org 0 jmp Start ; Start: ldi temp,LOW(RAMEND) ;set up stack pointer out SPL,temp ldi temp,HIGH(RAMEND) out SPH,temp ldi temp,0b00111111 ;PORTB LED's OFF. out PORTB, temp ; ldi temp,0b00111111 ;PB0 - PB5 = output out DDRB,temp ldi temp,0b00111111 ;PORTC LED's OFF. out PORTC, temp ; ldi temp,0b00111111 ;PC0 - PC5 = output out DDRC,temp ldi temp, 0b01111111 ;PORTD LED's OFF out PORTD, temp ;PD5, PD7 not used ldi temp, 0b01111111 ;PD0 - PD6 = output out DDRD,temp ldi temp, 0b00001100 ;PE2, PE3 LED's OFF out PORTE, temp ; ldi temp, 0b00001100 ;PE2, PE3 = output out DDRE,temp ldi temp,2 ;do it twice mov count,temp Main: ;First do PORTD cbi PORTD,PORTD0 ;PD0 LED ON ;1 rcall Delay1S sbi PORTD,PORTD0 ;PD0 LED OFF cbi PORTD,PORTD1 ;PD1 LED ON ;2 rcall Delay1S sbi PORTD,PORTD1 ;PD1 LED OFF cbi PORTD,PORTD2 ;PD2 LED ON ;4 rcall Delay1S sbi PORTD,PORTD2 ;PD2 LED OFF cbi PORTD,PORTD3 ;PD3 LED ON ;6 rcall Delay1S sbi PORTD,PORTD3 ;PD3 LED OFF cbi PORTD,PORTD4 ;PD4 LED ON ;8 rcall Delay1S sbi PORTD,PORTD4 ;PD4 LED OFF ;skip PD5 (unused PIN) cbi PORTD,PORTD6 ;PD6 LED ON ;10 rcall Delay1S sbi PORTD,PORTD6 ;PD6 LED OFF Main1: ;Now do PORTB cbi PORTB,PORTB0 ;PB0 LED ON ;12 rcall Delay1S sbi PORTB,PORTB0 ;PB0 LED OFF cbi PORTB,PORTB1 ;PB1 LED ON ;14 rcall Delay1S sbi PORTB,PORTB1 ;PB1 LED OFF cbi PORTB,PORTB2 ;PB2 LED ON ;16 rcall Delay1S sbi PORTB,PORTB2 ;PB2 LED OFF cbi PORTB,PORTB3 ;PB3 LED ON ;18 rcall Delay1S sbi PORTB,PORTB3 ;PB3 LED OFF cbi PORTB,PORTB4 ;PB4 LED ON ;20 rcall Delay1S sbi PORTB,PORTB4 ;PB4 LED OFF cbi PORTB,PORTB5 ;PB5 LED ON ;22 rcall Delay1S sbi PORTB,PORTB5 ;PB5 LED OFF Main2: ;Now do PORTE cbi PORTE,PORTE2 ;PE2 LED ON ;24 rcall Delay1S sbi PORTE,PORTE2 ;PE2 LED OFF cbi PORTE,PORTE3 ;PE3 LED ON ;26 rcall Delay1S sbi PORTE,PORTE3 ;PE3 LED OFF Main3: ;Now do PORTC cbi PORTC,PORTC0 ;PC0 LED ON ;28 rcall Delay1S sbi PORTC,PORTC0 ;PC0 LED OFF cbi PORTC,PORTC1 ;PC1 LED ON ;30 rcall Delay1S sbi PORTC,PORTC1 ;PC1 LED OFF cbi PORTC,PORTC2 ;PC2 LED ON ;32 rcall Delay1S sbi PORTC,PORTC2 ;PC2 LED OFF cbi PORTC,PORTC3 ;PC3 LED ON ;34 rcall Delay1S sbi PORTC,PORTC3 ;PC3 LED OFF cbi PORTC,PORTC4 ;PC4 LED ON ;36 rcall Delay1S sbi PORTC,PORTC4 ;PC4 LED OFF cbi PORTC,PORTC5 ;PC5 LED ON ;38 rcall Delay1S sbi PORTC,PORTC5 ;PC5 LED OFF dec count brne loop stop: rjmp stop loop: rjmp main ;*************************************************************** .equ XTAL = 1000 ;use internal clock & stock fuses ;.equ XTAL = 4000 ;use 4MHz crystal with above fuse settings ; delay: ldi temp,40 mov dcount3,temp dl2: ldi temp,(XTAL/120) ;XTAL is found in uart.inc mov dcount2,temp dl1: dec dcount2 brne dl1 dec dcount3 brne dl2 dec dcount brne delay ret ;*************************************************************** Delay250ms: ldi temp,250 ; delay 250mS mov dcount,temp call delay ret ;*************************************************************** Delay1S: ldi temp,4 ; delay 1 Second mov dcount4,temp Del1S: call Delay250ms dec dcount4 brne Del1S ret ;*************************************************************** .exit