Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Attiny841 strange behaviour in Bascom
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5093
Location: Holland

blank.gif
PostPosted: Mon Apr 28, 2014 3:51 pm    Post subject: Reply with quote

that code writes to other regs as well;
00000031 OUT 0x13,R30 Out to I/O location
00000032 OUT 0x14,R30 Out to I/O location
00000033 OUT 0x15,R30 Out to I/O location
which are :
GPIOR2 = $15
GPIOR1 = $14
GPIOR0 = $13

beside that, it clears regs, also clears the memory and EECR and MCUCR
you could try to reset these. it should not make any difference.
bascom also disables the WD and WD flag (after saving this flag). but besides that, i see nothing that explains any difference.

_________________
Mark
Back to top
View user's profile Visit poster's website
Meister

Bascom Member



Joined: 27 May 2010
Posts: 314

PostPosted: Mon Apr 28, 2014 4:50 pm    Post subject: Reply with quote

Same. Here additionally I set the PortsA.3,4 to high. Always 29Hz square wave output.
The level depends on connecting the LA or not - but always oscillating.
Code:
$regfile = "attiny841.dat"
$crystal = 8000000
$hwstack = 40
$swstack = 16
$framesize = 32
 $noramclear
Disable Interrupts
Eecr = 0
Mcucr = 0
GPIOR2 = $15
GPIOR1 = $14
Gpior0 = $13
'Puea = 0
Ddra = &B1111_1111
Porta.3 = 1
Porta.4 = 1
  End

Something fundamental must be wrong.
I just realized that the 29Hz chopping obtained with the Bascom code persists after programming the functioning C-program.
Recycling power to the chip restores the correct functioning of the C-Code after having flashed the Bascom code before.
That is not the case for the Bascom Code. There recycling power has no effect at all.
Resetting from the Studio does not help!!!!Power must be recycled.
So this observation must lead to find the problem?

Regards, Meister
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5093
Location: Holland

blank.gif
PostPosted: Mon Apr 28, 2014 7:10 pm    Post subject: Reply with quote

it is not :
GPIOR2 = $15
GPIOR1 = $14
Gpior0 = $13

but

GPIOR2 = 0
GPIOR1 = 0
Gpior0 = 0

the $13-$15 are the addresses.

you can best post a complete small project with the obj file included. if you compile the project in c:\temp or something like that i can watch/simulate it with studio too.

_________________
Mark
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5093
Location: Holland

blank.gif
PostPosted: Mon Apr 28, 2014 7:15 pm    Post subject: Reply with quote

you could simply write some code that outputs all IO registers and their value. that should show the difference !
_________________
Mark
Back to top
View user's profile Visit poster's website
Meister

Bascom Member



Joined: 27 May 2010
Posts: 314

PostPosted: Mon Apr 28, 2014 7:35 pm    Post subject: Reply with quote

I have changed the Gpior settings according to your post. Doesn't make any difference. 29Hz square wave on PA3,4.

That very short Bascom program from my previous post is that ok? It's just setting registers.
The obj. file is attached.
If you would prefer a different program, please propose some changes. It's easy for me to test.

Since this behaviour is that odd, I was thinking chip is kaputt. But I always can flash a C-program
that sets two timers with five outputs for complemetary pulse and that works as it should after cycling power if a Bascom program had been flashed before.

I did one more check: I changed the clkdiv fuse to run at 1Mhz. The frequency of the strange 29Hz pulses stays the same.

If I unplug both the programmer and the LA, there is still the 29Hz square wave (seen on osci), but as said before, the amplitudes are affected by the load due the LA.

Regards, Meister
Back to top
View user's profile
Meister

Bascom Member



Joined: 27 May 2010
Posts: 314

PostPosted: Mon Apr 28, 2014 7:42 pm    Post subject: Reply with quote

Quote:
outputs all IO registers

What do you mean by "all"? Just the used ones?
Output to where? Printing?
Regards, Meister
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5093
Location: Holland

blank.gif
PostPosted: Mon Apr 28, 2014 7:45 pm    Post subject: Reply with quote

it was not to be expected that the gpior regs would be the problem.
I need an obj of the c program. with the c code as well.
but when the problem arises after you load the bascom program, simply wrote a dump program that dumps all io regs address with content.
do the same for the c and compare the result. some will be different like SPL SPH and others would be more interesting.

_________________
Mark
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5093
Location: Holland

blank.gif
PostPosted: Mon Apr 28, 2014 7:54 pm    Post subject: Reply with quote

dim b as Byte

for b = 32 to 255 '32 will return IO register 0 address
print hex(b) ; " " ; inp(b)
next

_________________
Mark
Back to top
View user's profile Visit poster's website
Meister

Bascom Member



Joined: 27 May 2010
Posts: 314

PostPosted: Mon Apr 28, 2014 8:05 pm    Post subject: Reply with quote

Put the print on top and after setting registers. Hope it's right.
Code:
$regfile = "attiny841.dat"
$crystal = 8000000
$hwstack = 40
$swstack = 16
$framesize = 32
 $noramclear
 Dim B As Byte

 For B = 32 To 255                                          '32 will return IO register 0 address
Print Hex(b) ; " " ; Inp(b)
Next

Disable Interrupts
Eecr = 0
Mcucr = 0
Gpior2 = $0
Gpior1 = $0
Gpior0 = $0
'Puea = 0
Ddra = &B1111_1111
Porta.3 = 1
Porta.4 = 1

For B = 32 To 255                                           '32 will return IO register 0 address
Print Hex(b) ; " " ; Inp(b)
Next

End

Regards, Meister
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5093
Location: Holland

blank.gif
PostPosted: Mon Apr 28, 2014 8:09 pm    Post subject: Reply with quote

you need to run it and store the output.
then do the same for the C code. then compare the differences.

_________________
Mark
Back to top
View user's profile Visit poster's website
Meister

Bascom Member



Joined: 27 May 2010
Posts: 314

PostPosted: Mon Apr 28, 2014 8:48 pm    Post subject: Reply with quote

Hello,
Doesn't work.
Output:
....
24 ?UUU<\r><\n>
20 0<\r><\n>
21 0<\r><\n>
22 0<\r><\n>
23 0<\r><\n>
24 ?UUU<\r><\n>
....

Code:
$regfile = "attiny841.dat"
$crystal = 8000000
$hwstack = 40
$swstack = 16
$framesize = 32
 '$noramclear
 $baud = 19200
 Dim B As Byte
 Open "com1:" For Binary As #1
 'waitms 5000
 Print #1 , "UUU"
 For B = 32 To 255                                          '32 will return IO register 0 address
Print #1 , Hex(b) ; " " ; Inp(b)
Next
 End

Regards, Meister
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5093
Location: Holland

blank.gif
PostPosted: Mon Apr 28, 2014 8:53 pm    Post subject: Reply with quote

seems the baud is off. try to adjust with OSCCAL0, or adjust $crystal value.
_________________
Mark
Back to top
View user's profile Visit poster's website
Meister

Bascom Member



Joined: 27 May 2010
Posts: 314

PostPosted: Mon Apr 28, 2014 9:30 pm    Post subject: Reply with quote

The Baudrate is 19540 instead of 19200. Hterm reads 20 UU..Us without error.
Setting Hterm and LA to 19540 does not make a difference. Reading is the same.
How far it counts up the B (prints it) depends on the number of U's. The more U's, the less increments.
The main point ist that print does never end although there is no loop (it's exactly code above).
Regards, Meister
P.S. Maybe they made this chip to be programmable only in C Shocked.
//Atmel says: ATtiny441/841 is a
complex microcontroller with more peripheral units than can be addressed with the IN and OUT instructions....
Back to top
View user's profile
protoncek

Bascom Member



Joined: 16 May 2011
Posts: 43
Location: Slovenia

slovenia.gif
PostPosted: Wed Jul 02, 2014 1:25 pm    Post subject: Reply with quote

Hello!


I wonder...is it possible to get dat file for tiny841 ? Or maybe any info about when this chip Will be officially supported?
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5093
Location: Holland

blank.gif
PostPosted: Wed Jul 02, 2014 2:20 pm    Post subject: Reply with quote

the dat file alone is not enough. otherwise i would have posted it here. the tiny441/841 is a great new chip. packed with hardware for a small price.
we do not give dates but it will be fully supported in the next update. I never got my samples from atmel, but i could buy them from farnell.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum