View previous topic :: View next topic |
Author |
Message |
BITSANDPIECES
Joined: 05 Feb 2013 Posts: 3
|
Posted: Mon Mar 10, 2014 12:39 pm Post subject: Migrating from Pic Basic Pro to Bascom AVR |
|
|
Hi
I have managed to confuse myself completely or i don't understand Bascom AVR syntax yet as i am new to Bascom AVR i used the following code below in PIC Basic Pro which worked perfectly. I migrated from Microchip PIC to Atmel AVR micro controllers for various reasons can someone please convert the following code in to Bascom AVR format for me PLEASE!!!! I am sure I will understand the syntax better.
TempA var Word
TempB var Word
TempC var Long
MyData Var Long
Shiftin Portb.3,Portb.2,MSBPRE,(TempA\16,TempB\8)
TempC.HighWord = TempA
TempC.LowWord = TempB << 8
Mydata = TempC >> 8
(BASCOM-AVR version : 2.0.7.7 ) |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Mon Mar 10, 2014 1:55 pm Post subject: |
|
|
i do not know pic but i guess the code you used clocks in 24 bits.
dim l as long 'or dword
Shiftin pinb.2 ,portb.3 , L , 2 ,24
notice that avr uses the PIN register for reading logical input
the code above will shift in 24 bits for mode 2. _________________ Mark |
|
Back to top |
|
|
DoctorBob
Joined: 05 Jul 2006 Posts: 12 Location: Nederland
|
Posted: Mon Mar 10, 2014 2:14 pm Post subject: Re: Migrating from Pic Basic Pro to Bascom AVR |
|
|
BITSANDPIECES wrote: |
TempA var Word
TempB var Word
TempC var Long
MyData Var Long
|
Vars are set as followed as decribed in manual like real BASIC
In help just type Long and you will get all var types.
DIM TempA as Word ; 16bit
DIM TempB as Word
DIM TempC as Long ; 32 bit
DIM MyData as Long
Why is TempC Long? You use it below as Word only. What is bit sizes of Word & Long in PIC? I made lots of big projects in BASCOM (Based on M328 and M664 full memory use), but I used Long rarely. Only needed it in orbit around the sun calculations. (Sunrise, Sunset). Temperatures from sensors are fine by use of Word type. What can hold temperatures in 0.1 degree (calculate without float).
BITSANDPIECES wrote: |
Shiftin Portb.3,Portb.2,MSBPRE,(TempA\16,TempB\
|
Do not know what you want to do here?
BASCOM is great and easy to work with, but remember one action on one line.
BITSANDPIECES wrote: |
TempC.HighWord = TempA
TempC.LowWord = TempB << 8
|
Dot is only used for bit manipulation. As word is 16 bit, just do this. Not sure why you want to shift TempB.
Do not know why you shift left 8, just multiple it by 256 does the same.
In case TempC = word. If you want really use Long (Needs more memory use) TempA * 65536, TempB * 256
TempC = TempA * 256
TempC = TempC + TempB
BITSANDPIECES wrote: |
Mydata = TempC >> 8
|
Above is not real Basic, but more like C.
SHIFT TempC , RIGHT, 8
Mydata = TempC
Just see examples and use Help. Its very clear about howto do all and look for syntax differences between you old PIC not really Basic and real Basic sysntax. |
|
Back to top |
|
|
BITSANDPIECES
Joined: 05 Feb 2013 Posts: 3
|
Posted: Mon Mar 10, 2014 2:54 pm Post subject: |
|
|
Thank you very much i will try out your suggestions |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Wed Mar 12, 2014 11:01 pm Post subject: |
|
|
Hi,
I used Pic Basic 10 years ago. It is easy to use, but you cannot do a lot with it. It might be useful to by used at scool to show what a micro is and how a language works, that is it. But at least it gives you an introduction. Bascom is far far more powerful. You might need some guidance to switch from Pic to Bascom. Have a look at Roland Walther AVR. This book used to be my ticket to the Bascom-World. This book puts you on the right track to use Bascom. |
|
Back to top |
|
|
Tubeampman
Joined: 27 Feb 2006 Posts: 100 Location: Bodo
|
Posted: Thu Mar 13, 2014 12:50 am Post subject: |
|
|
Hi
i was going to give a tip about a web book that contained some bascom, but it is moore like a
beginners bokk for Electronics.
i dont think this is what you might need, but here it is anyway
http://www.techideas.co.nz/
Øyvind |
|
Back to top |
|
|
BITSANDPIECES
Joined: 05 Feb 2013 Posts: 3
|
Posted: Thu Mar 13, 2014 2:58 pm Post subject: |
|
|
Finally SUCCESS !!! after I "Brick" 2 x Atmega8A processors and then had to build a 1MhZ PCB to access the fuse bits again and reconfigure the fuse bits right i got my first board running flashing a led on a external 16mhz crystal using programmer USBASP
Thanks for the help |
|
Back to top |
|
|
|