View previous topic :: View next topic |
Author |
Message |
olhexy
Joined: 03 Apr 2011 Posts: 192 Location: Tilburg, Netherlands
|
Posted: Tue Mar 08, 2016 12:44 am Post subject: Printbin with Config Base =0 adds weird data at end. |
|
|
Printbin problem.
It makes 1 element too much with Config Base = 0.
I get 8 elements, whereas 7 are defined. One weird data element is added at end in all circumstances. (With Word elements: the end element was shown twice, 1 too much.)
Officially with Dim(7) there are ALLWAYS 7 elements (index 0 to 6 with Config Base=0, or index 1 to 7 with Config Base =1)
Makes A B C D E F G <BEL> if N=0...6, so it adds <BEL> at end.
Makes A B C D E F G I if N=0...>6 (over supply in For..next) so it allways adds same I at end for every N>6.
Makes A B C <NUL> <NUL> <NUL> <NUL> <ETX> if N=0..2 (under supply in For...next) so it adds <ETX> at end.
It all works perfect with Config Base =1. For example: it makes 7 correct elements
B C <NUL> <NUL> <NUL> <NUL> <NUL> if N=0..2 (over supply left side and under supply right side) with ConfigBase=1.
Code: | Rem :7mrt2016
$regfile = "m1284Pdef.dat"
$hwstack = 40
$swstack = 40
$framesize = 40
$crystal = 17100000 'Std 4Mhz ext.clock, but with internal OSCCAL=255=~17,1Mhz
'$lib "Mylcd4busy_anypin.LIB"
Config Clockdiv = 1 'in stead of default CLKDIV=8
Osccal = 255 'is max:~17.1Mhz. Factory default &H58 (decimal 8Cool~8MHz
Rem STK200geel conflict MOSI/SCK... met LCD op PortB;
'By specifying Wr the library lcd4busy_anypin (based on LUCIANO) will be used
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.0 , Wr = Portc.1
'Config Portc.1 = Output : Portc.1 = 0 'Wr to GND if not used
Config Lcd = 16x2 'Bascom does Initlcd to 4bit interface, but no Cls
Config Portc.3 = Output 'C.3 is for Lcdled initially =0 =OFF
Lcdled Alias Portc.3 'at start led=OFF (transistor base=0)
Cls : Lcdled = 1 : Wait 2 : Lcd "PrintbnCfB=0" : Wait 2 : Cls 'Lcdled =1 =ON
Config Base = 0 'Non standard! But adviced for new projects.
Config Printbin = Extended 'For arrays >256 bytes
Dim Teken(7) As Byte 'ALLWAYS 7 elements!!! Independant of ConfigBase=0 or =1
Dim N As Byte 'You cannot combine Array() and Variable in one Dim
For N = 0 To 6 'Tested also with over/under supply of data
Teken(n) = N + 65 'chr(65) = "A" First valid chr = "A"
Next N
Countdown:
Dim Secs As Byte
For Secs = 10 To 0 Step -1
Wait 1
Cls : Lcd "PrintbnCfB=0.LOG"
Lowerline : Lcd "starts in " ; Secs ; " s"
Next
Lowerline : Lcd "is running......"
Printbin Teken(0) 'Print to YAT or Bascom Terminal
'Adds <BEL>, or I in case of over supply in For...Next, or <ETX> in case of under supply.
Lowerline : Cls : Lcd "Ready"
End |
(BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 ) |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Tue Mar 08, 2016 9:33 am Post subject: |
|
|
Use as workaround
Code: | Printbin Teken(0) ; 7 |
The compiler miscalculates the size parameter handed over to the printbin routine.
Btw., do you have any EEProm-access in your code?
As with this kludge
you won't get many happy EEProm bytes. |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Tue Mar 08, 2016 11:51 pm Post subject: |
|
|
As MWS points out, manually setting the osccal value to an arbitrary number may have unexpected consequences.
But worse still, this will only work as expected on the one processor you happen to have which runs at 17.1 Mhz with this setting. Every processor ( including ones from the same batch ) may run at a different speed, totally confusing Bascom with your hard-coded $crystal setting.
That osccal setting is not intended to be used like this, and will cause all sorts of weird effects. Suggest you read carefully the Atmel documentation on what the osccal setting does, and what it is used for. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
olhexy
Joined: 03 Apr 2011 Posts: 192 Location: Tilburg, Netherlands
|
Posted: Wed Mar 09, 2016 12:28 am Post subject: |
|
|
Why do I get this warning over and over again? Do you see me writing to EEPROM? And if I would, couldn't I change speed for that purpose?
The M1284P is specified for 20Mhz. Atmel nowhere said that I should not use that.
I have measured what the actual speed is with Osccal = 255, and calculated $crystal from that. You can see that I use the COM successfully.
It is not a 'kludge'.
This is my development board STK200 where there is only 4Mhz crystal. For the application under development I need maximum speed, and this is the easiest way how to achieve that.
I am using this setup for almost a year now. It runs like a charm! I think I know what I am doing. I intend to solve the problems that I encounter. Like I did with the 16x2 LCD (initLCD), where I ironed out a few things where others wanted me to revert to the safe/easy road (to avoid, not solve the problems).
May be people have problem that they cannot allways copy my code 1:1 to their boards, because they have standard crystals?
I am not responsable for that.
I want the Printbin to be fixed.
(Edit to Adrian, here under. I considered the crystal socket, but then it appeared that every crystal also needs different matching capacitors.)
Last edited by olhexy on Wed Mar 09, 2016 1:14 am; edited 3 times in total |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Wed Mar 09, 2016 12:56 am Post subject: |
|
|
Ok, as long as you recognise the potential problems.
I too have an ancient development system. My solution was to put a couple of machine pin sockets on the crystal pads, and plug in whatever crystal I like. At least then the behaviour is reproducible and transferable to a production board.
Certainly I have no interest whatever in using your code, only in giving advice when you ask for help. If that results in advising on stuff which I can see in the code, but not necessarily directly related to your problem, then you can choose to ignore it. _________________ Adrian Jansen
Computer language is a framework for creativity |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Mar 09, 2016 7:47 am Post subject: |
|
|
olhexy wrote: | Why do I get this warning over and over again? |
Because it's the same kludge over again.
Quote: | Do you see me writing to EEPROM? |
As the shown code was only for demo, I don't need to notice something like that for giving my advice.
Are you able to understand a condition like: "If you do abc, take care about xyz?"
Quote: | The M1284P is specified for 20Mhz. Atmel nowhere said that I should not use that. |
Atmel tells you to be careful, as the EEPROM part runs out of specs in such case.
Quote: | It is not a 'kludge'. |
Sure it is.
Quote: | For the application under development I need maximum speed, and this is the easiest way how to achieve that. |
If you do professional development, then I'd say the kludge meets the botcher.
Hope you don't develop pacemakers or anything security related.
Quote: | I think I know what I am doing. |
What I saw from you till today, I wouldn't be that sure.
Quote: | May be people have problem that they cannot allways copy my code 1:1 to their boards, because they have standard crystals? |
Why anybody should do that? For testing your problem it was sufficient for me to clean up the superfluous code mess and do a simulation for exact the part of printbin. And for anybody else: I haven't seen any of your code, which I would advise to copy.
Quote: | I want the Printbin to be fixed. |
Mark will likely notice this thread, but you better write additionally to support. |
|
Back to top |
|
|
olhexy
Joined: 03 Apr 2011 Posts: 192 Location: Tilburg, Netherlands
|
Posted: Tue Mar 15, 2016 11:44 am Post subject: |
|
|
Dear MWS, your 'workaround' totally obfuscates the point that I wanted to make: that it contradicts the Help.
The word "kludge" sprouted from your brain. But you preferred "workaround".
Using a totally irrelevant reason you put that flag on my code. That was not nice.
Please read: http://avrhelp.mcselec.com/index.html?config_base.htm (and notice the yellow warning sign)
To Mark: As 200 hours wait for Support have passed please comment here. Are you aware of the problem? |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Tue Mar 15, 2016 8:38 pm Post subject: |
|
|
A workaround is something usefull till there's an official fix, nothing more.
It does not obfuscate anything, it only helps you to proceed with your code, till the problem is solved by a future compiler version.
In case you have an SLA, I suspect you'll have the fix early.
Do you pay for SLA?
In case of "no", you may have to wait like the rest of us.
I wrote the compiler miscalculates the array size, could you possibly have understood that this is anything but NOT a bug?
Your post is finally missing one serious grammatical element, after the second to last sentence, you should have added ", or else!" |
|
Back to top |
|
|
|
|
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
|
|