Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Migrating from Pic Basic Pro to Bascom AVR

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
BITSANDPIECES

Bascom Member



Joined: 05 Feb 2013
Posts: 3

PostPosted: Mon Mar 10, 2014 12:39 pm    Post subject: Migrating from Pic Basic Pro to Bascom AVR Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Mon Mar 10, 2014 1:55 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
DoctorBob

Bascom Member



Joined: 05 Jul 2006
Posts: 12
Location: Nederland

netherlands.gif
PostPosted: Mon Mar 10, 2014 2:14 pm    Post subject: Re: Migrating from Pic Basic Pro to Bascom AVR Reply with quote

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 Wink
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\Cool

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. Wink
Back to top
View user's profile
BITSANDPIECES

Bascom Member



Joined: 05 Feb 2013
Posts: 3

PostPosted: Mon Mar 10, 2014 2:54 pm    Post subject: Reply with quote

Thank you very much i will try out your suggestions
Back to top
View user's profile
Arera

Bascom Member



Joined: 23 Sep 2007
Posts: 386
Location: Wuppertal, Germany

germany.gif
PostPosted: Wed Mar 12, 2014 11:01 pm    Post subject: Reply with quote

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
View user's profile
Tubeampman

Bascom Member



Joined: 27 Feb 2006
Posts: 100
Location: Bodo

norway.gif
PostPosted: Thu Mar 13, 2014 12:50 am    Post subject: Reply with quote

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
View user's profile
BITSANDPIECES

Bascom Member



Joined: 05 Feb 2013
Posts: 3

PostPosted: Thu Mar 13, 2014 2:58 pm    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
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