View previous topic :: View next topic |
Author |
Message |
tevenlogic
Joined: 04 Aug 2005 Posts: 18 Location: Brisbane
|
Posted: Fri May 13, 2016 4:32 am Post subject: Problem with moving eeprom value to a register |
|
|
See this line in the following code
Osccal = Osccal_e ' This line does not work correctly
$regfile = "m328def.dat"
' 8Mhz can not give 115200 Baud but 7372800 can exactly. So we need to use the internal RC calibration to force the internal RC to run at this speed.
' The sub Cal_internal_rc() does this calibration
' by telling the compiler that this is the clock speed then all other bascom approx timers will be resonably accurate.
' The eeprom write timing may be out though according to data sheet
$crystal = 7372800
$baud = 115200
$hwstack = 50
$swstack = 50
$framesize = 50
Dim Tempbyte As Byte
Dim Osccal_e As Eram Byte
If Osccal_e <> &HFF Then ' Has been calibrated before
Osccal = Osccal_e ' This line does not work correctly
Tempbyte = Osccal_e ' These two lines do work correctly
Osccal = Tempbyte
Print "No cal, used " ; Osccal ; " " ; Tempbyte
Else
Cal_internal_rc ' do calibration
Osccal_e = Osccal
End If
If the compiler can not copy eeprom to a register then there should be a error at compile time.
Is it possible that this error is cause by the non standard clock speed that I am using?
I am using Bascom Build 2.0.0.8.001 on a 64bit Win7 machine
By the way. Mark Albers I love your work. The bascom compiler is my favourite environment to do rapid development in.
The editor is good and the simulator is very handy for counting cycles when optimising timing etc.
Bascom is a great product.
Thanks
Trevor
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
|
Back to top |
|
|
tevenlogic
Joined: 04 Aug 2005 Posts: 18 Location: Brisbane
|
Posted: Fri May 13, 2016 9:21 am Post subject: |
|
|
Why would the compiler allow you to make such a mistake.
Its like trying to assign a string to a integer.
The compiler tells you that you are attempting something that it can not do. And so gives an error message.
Assigning an Eeprom to a register is something that the compiler can not do and therefore it should give an error.
In fact there is no obvious reason for a basic programmer to suspect that a eeprom byte can not be assigned to a register.
They would need to know more about the architecture of the chip to suspect that this is different. Basic is designed to hide these details from the programmer.
And Bascom is great that it hides all this and still lets you configure the chip exactly as you wish, and do things like in line assembler.
I reckon the only reason that the compiler can not do this assignment is because of a restriction in the addressing of registers within the asm code that it is using.
All Im saying is, please display an error, or, fix the compile so it can do this assignment. Then the programmer can get on with his job and not spend hours finding out that the assignment did not happen as it looks like it should have.
Trevor |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri May 13, 2016 11:47 am Post subject: |
|
|
I will have a look at it. _________________ Mark |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Fri May 13, 2016 6:28 pm Post subject: |
|
|
tevenlogic wrote: | Why would the compiler allow you to make such a mistake. |
I think this is borderline. On one hand, yes, this should be quite simple to change within the compiler to rise an error.
On the other hand:
Quote: | Then the programmer can get on with his job and not spend hours finding out that the assignment did not happen ... |
If this takes you hours while you have the help, therein topic "Dim" in front of you, you do something seriously wrong.
In case this would have happened to me, I'd rather mind about myself having a slow mind, before spilling the blame on the compiler.
Of course this doesn't necessarily apply to you |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri May 13, 2016 8:23 pm Post subject: |
|
|
I had a look and changed it so it will write to the register. _________________ Mark |
|
Back to top |
|
|
tevenlogic
Joined: 04 Aug 2005 Posts: 18 Location: Brisbane
|
Posted: Sat May 14, 2016 5:30 am Post subject: |
|
|
Thank you Mark for taking the time.
Im sure you are very busy.. I am only trying to give constructive feedback.
Regards
Trevor |
|
Back to top |
|
|
|