Working on building latest realease of FlashForth for AVR, ATmega16a. Made all the usual changes to the source file, to add ATmega16a, using ATmega32a as a guide, (Selected Uart0, correct clock frequency, 8.00 mhz. in this case, etc.) burned it OK, fired up my terminal with the correct paramters.
No repsonse.
My fuses are hf, 99 and lf, 9F, and lockbits FF
Note JTAG is active.
Anybody been down this road, and over a suggestion or two?
Best,
Randy
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The 32A has never worked, iit has the same problem like the 16A seems to have, something in the UART code is wrong.
FF starts up fine in the simulator but on a real chip the UART does not work.
There is some quirk on these chips that two UART control registers are located on the same address. There may some wrong handling in that area.
Since I dont have any of those chips I cannot test it fully either...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
that alludes to precisely the suggestion you made.
"IMPORTANT : The UCSRC and the UBRRH (discussed below) register shares same address so to determine which register user want to write is decided with the 7th(last) bit of data if its 1 then the data is written to UCSRC else it goes to UBRRH. This seventh bit is called the
URSEL: USART register select."
I do have good step by step debugging on the ATMega16a (precisely why I choose this chip, JTAG so much easier, and cheaper than DebugWire), I'm wondering where exactly in the code should I look to modify it for this exception?
Best,
Randy
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is this piece of code that in WARM inits the UART.
In viewed in the simulator the UCSRC in initialized with 0x98
Check also the writing to UDR in TX0. The FF boot string should come out there.
; Init UART 0
.ifdef UBRR0L
rcall DOLIT
.dw RX0_ISR
rcall DOLIT
.ifdef URXC0addr
.dw URXC0addr+ivec
.else
.dw URXCaddr+ivec
.endif
rcall STORE
;;; Set baud rate
; out_ UBRR0H, zero
ldi t0, ubrr0val
out_ UBRR0L, t0
; Enable receiver and transmitter, rx1 interrupts
ldi t0, (1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0)
out_ UCSR0B,t0
; Set frame format: 8data, 1stop bit
ldi t0, (3<<UCSZ00)|URSEL_
out_ UCSR0C,t0
.if U0FC_TYPE == 1
sbr FLAGS2, (1<<ixoff_tx0)
.endif
.if U0FC_TYPE == 2
sbi_ U0RTS_DDR, U0RTS_BIT
.endif
.endif
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just checked your fuses.
At least they are wrong.
The BOOTSZ should be 1024 words start address at 0x1c00
BOOTRESET must be active.
With JTAG enabled the HF becomes 0xB8 for the atmega 16a
The LF can be left at 0xFF.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
However the out instructions don't seem to be hitting the target registers. That is I'm not seeing the state change in the I/0 view. (JTAG not simulation). Excuse my ignorance, I need to brush up on macros, and hit the data sheet hard tomorrow.
R.
Last edit: Randall Young 2015-09-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Randall, did you get any further on this problem ?
You could try to replace the out____ macros with out instructions.
At least in the simulator and the assembler listing file the macros seem to work just fine, and the register adresses seem correct.
So it is really strange that you dont even get the startup message, or do you ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello!,
Working on building latest realease of FlashForth for AVR, ATmega16a. Made all the usual changes to the source file, to add ATmega16a, using ATmega32a as a guide, (Selected Uart0, correct clock frequency, 8.00 mhz. in this case, etc.) burned it OK, fired up my terminal with the correct paramters.
No repsonse.
My fuses are hf, 99 and lf, 9F, and lockbits FF
Note JTAG is active.
Anybody been down this road, and over a suggestion or two?
Best,
Randy
The 32A has never worked, iit has the same problem like the 16A seems to have, something in the UART code is wrong.
FF starts up fine in the simulator but on a real chip the UART does not work.
There is some quirk on these chips that two UART control registers are located on the same address. There may some wrong handling in that area.
Since I dont have any of those chips I cannot test it fully either...
Thank you, that gives me some direction...
I did find this code as a fix for AMForth on the ATmega 16/32, which I did get running on the board this evening.
; additional .equs for "old fashioned" mcu with usart, not usart0
.equ TXEN0 = TXEN
.equ RXEN0 = RXEN
.equ RXCIE0 = RXCIE
.equ UCSZ00 = UCSZ0
.equ TXCIE0 = TXCIE
; define which usart to use.
.include "usart.asm"
; not include "usart_0.asm"
Could this be relevent?
Last edit: Randall Young 2015-09-18
Mikael,
I did find this resource online...
http://extremeelectronics.co.in/avr-tutorials/using-the-usart-of-avr-microcontrollers/
that alludes to precisely the suggestion you made.
"IMPORTANT : The UCSRC and the UBRRH (discussed below) register shares same address so to determine which register user want to write is decided with the 7th(last) bit of data if its 1 then the data is written to UCSRC else it goes to UBRRH. This seventh bit is called the
URSEL: USART register select."
I do have good step by step debugging on the ATMega16a (precisely why I choose this chip, JTAG so much easier, and cheaper than DebugWire), I'm wondering where exactly in the code should I look to modify it for this exception?
Best,
Randy
It is this piece of code that in WARM inits the UART.
In viewed in the simulator the UCSRC in initialized with 0x98
Check also the writing to UDR in TX0. The FF boot string should come out there.
; Init UART 0
.ifdef UBRR0L
rcall DOLIT
.dw RX0_ISR
rcall DOLIT
.ifdef URXC0addr
.dw URXC0addr+ivec
.else
.dw URXCaddr+ivec
.endif
rcall STORE
;;; Set baud rate
; out_ UBRR0H, zero
ldi t0, ubrr0val
out_ UBRR0L, t0
; Enable receiver and transmitter, rx1 interrupts
ldi t0, (1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0)
out_ UCSR0B,t0
; Set frame format: 8data, 1stop bit
ldi t0, (3<<UCSZ00)|URSEL_
out_ UCSR0C,t0
.if U0FC_TYPE == 1
sbr FLAGS2, (1<<ixoff_tx0)
.endif
.if U0FC_TYPE == 2
sbi_ U0RTS_DDR, U0RTS_BIT
.endif
.endif
Just checked your fuses.
At least they are wrong.
The BOOTSZ should be 1024 words start address at 0x1c00
BOOTRESET must be active.
With JTAG enabled the HF becomes 0xB8 for the atmega 16a
The LF can be left at 0xFF.
Mikael,
Fuses changed as requested.
Just took a moment to trace the code, I can see it executing here in the debugger ...
; Init UART 0
.ifdef UBRR0L
rcall DOLIT
.dw RX0_ISR
rcall DOLIT
.ifdef URXC0addr
.dw URXC0addr+ivec
.else
.dw URXCaddr+ivec
.endif
rcall STORE
;;; Set baud rate
;out_ UBRR0H, zero
ldi t0, ubrr0val
out_ UBRR0L, t0
; Enable receiver and transmitter, rx1 interrupts
ldi t0, (1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0)
out_ UCSR0B,t0
; Set frame format: 8data, 1stop bit
ldi t0, (3<<UCSZ00)|URSEL_
out_ UCSR0C,t0
.if U0FC_TYPE == 1
sbr FLAGS2, (1<<ixoff_tx0)
.endif
.if U0FC_TYPE == 2
sbi_ U0RTS_DDR, U0RTS_BIT
.endif
.endif
However the out instructions don't seem to be hitting the target registers. That is I'm not seeing the state change in the I/0 view. (JTAG not simulation). Excuse my ignorance, I need to brush up on macros, and hit the data sheet hard tomorrow.
R.
Last edit: Randall Young 2015-09-19
Randall, did you get any further on this problem ?
You could try to replace the out____ macros with out instructions.
At least in the simulator and the assembler listing file the macros seem to work just fine, and the register adresses seem correct.
So it is really strange that you dont even get the startup message, or do you ?
No I haven't made any progress on this problem, I'm pretty much confounded actually. No I did not see the startup message...