Hello
tanks for last code
It's working for atmega128 with port A,port B,port C,port D and port E , but when I use the port F for lcd , this error seen :
backward jump out of range[_Clear_Graph1[101]]
backward jump out of range[_Clear_Graph2[104]]
can you help me ?
↧
Share your working BASCOM-AVR code here : Library for Nokia1616 display : REPLY
↧
BASCOM-AVR : CanOpen : NEWTOPIC
Hello,
Has anyone done any projects with CanOpen?
Regards
P_Santos
[b:ae89b77ada][color=red:ae89b77ada](BASCOM-AVR version : 2.0.7.8 , Latest : 2.0.7.8 )[/b:ae89b77ada][/color:ae89b77ada]
↧
↧
Share your working BASCOM-AVR code here : manchester code : NEWTOPIC
when programming attiny13 any byte saved helps. I written this code to encode or decode a radiolink in Manchester code. Perhaps of use to others. ps programming an attiny13 is not inspired by practical or economical reasons; it's a challenge :)
'variables used for Manchester encoding
Dim B0 As Byte
Dim Man_word As Dword
Dim B4 As Byte At Man_word + 0 Overlay
Dim B3 As Byte At Man_word + 1 Overlay
Dim B2 As Byte At Man_word + 2 Overlay
Dim B1 As Byte At Man_word + 3 Overlay
Manchester_encode:
'B0 has the byte to encode
'b1..b4 overlay over man_word
'when man_word has been shifted left 16 times then B1=0, loop is done
'and B0's complement and B0 have been shifted interleaved into B2 and B3
'later decoding is done in a similar way
' B1 B2 B3 B4
Man_word = &B11111111_11111111_00000000_00000000
B4 = B0 Xor &B11111111 'C's complement
Do
Shift Man_word , Left , 1 'shift in a bit of B0's complement
Swap B0 , B4
Shift Man_word , Left , 1 'shift in a bit of B0
Swap B0 , B4
Loop Until B1 = 0 'Loop Until B1 = 0
Return
Manchester_decode:
'b1..b4 overlay over man_word
'manchester bytes placed in b2 and b3
'when man_word has been shifted right 16 times B1=0,b2=0
'B4 will have the original byte, B0 has it's complement
'After XOR B4 B0, If there were illegal bits, B1 will be <> 255
B1 = &B11111111
'B0 and B4 do not need initialising
Do
Shift Man_word , Right , 1 'shift 1 oiginal bit into B4
Swap B0 , B4
Shift Man_word , Right , 1 'shift 1 complement bit into B0
Swap B0 , B4
Loop Until B1 = 0 And B2 = 0
B1 = B4 Xor B0 'if errorbits, b1<>255
Return
↧
Share your working BASCOM-AVR code here : Library for Nokia1616 display : REPLY
This is not library problem - M1281 with the same pinout works fine.
In M128 due to M103 compatibility PORTF & PORTG will not work.
↧
BASCOM-AVR : UTF-8 to ASCII in a string : REPLY
Lookup table ?
↧
↧
Share your working BASCOM-AVR code here : All-in-one game board "Gamebuino" : NEWTOPIC
I got an all-in-one game board "Gamebuino"!
It has seven push buttons, G-LCD display, speaker, photosensor, I2C interface, serial communication, SD card and battery on board.
AVR is ATmega328P-AU 16MHz.
Gamebuino : [url=http://www.ne.jp/asahi/o-family/extdisk/Gamebuino/GamebuinoB.jpg][img:b6e97ee8a4]http://www.ne.jp/asahi/shared/o-family/ElecRoom/AVRMCOM/Gamebuino/GamebuinoBs.jpg[/img:b6e97ee8a4][/url]
Manufacturer site : http://gamebuino.com/
WIKI site : http://gamebuino.com/wiki/index.php?title=Getting_started
Circuit diagram : http://gamebuino.com/wiki/images/6/6f/Gamebuino_r2_schematics.pdf
However, the development environment is "Arduino". I like BASCOM!
So we prepared libraries, configuration programs, and a simple test program so that they can be run on BASCOM-AVR.
The G-LCD is Nokia 5110.
The library modified "NOKIA-3310/5110 B & W LCD library" of "Mrshilov" for "Gamebuino".
"Line" command can not be used for this G-LCD.
However, I wanted a row separating the lines, so I added an underline to the option of the "Lcdat" command.
[code:1:b6e97ee8a4]Lcdat 1 , 1 , "Gamebuino Test" 'Normal.
Lcdat 1 , 1 , "Gamebuino Test" , 1 'Invert.
Lcdat 1 , 1 , "Gamebuino Test" , 2 'Solid Underline.
Lcdat 1 , 1 , "Gamebuino Test" , 3 'Dotted Underline.[/code:1:b6e97ee8a4]
The attached 6x8 font does not use the underline area (lowest) dot.
Since micro SD card can be used, AVR-DOS can be include.
[code:1:b6e97ee8a4]Const Sdcard_use = 0 'Usage status of SD-Card. (0:not used, 1:used)[/code:1:b6e97ee8a4]
Program can be written in BASCOM's [ARDUINO] using USB cable.
Use BASCOM to expect for sensors, data loggers, and other applications!
↧
BASCOM-AVR : clock cycles per instruction? : REPLY
Regarding the generation of a sinewawe it could help to remember that the first integral of a constant is a ramp,
and a second integration of that ramp will generate a sinewave.
So all you need are two accumulators for integration. The frequency is controlled by the accumulation rate (IRQ driven?)
This is extremely simple, and you will get sawtooth and sine wave at the same time.
I have code to share somwhere if it is of interest
/Per
↧
BASCOM-AVR : clock cycles per instruction? : REPLY
I wrote a BasCom program some years ago that reports the execution time for some common math operations using various data types.
What I wanted to know was when to use floating Point operations and when to avoid them.
That was also the time I realized that shifting a IEEE single variable will work instead of Dividing or multiplying by 2.
Especially division by two using signed rightshift is enormously fast compared to use of the division operator.
Anyway, here are some results, and if you need other operation benchmarked, other tahn those listed here you will also find the sourcode attached.
For example:
B=B+B: 9 0.56us --> Summing a byte to Another byte and assigning it to a byte will consume nine CPU Clocks (=0.56us at 16MHz)
/Per
---------------------------------------------------------------------------------------
BasCom_AVR 2.0.7.8 Compiled:2015-12-11
Math benchmark at 16MHz clock
Operation: Clocks, Time(us)
---------- No_operation overhead -----------
Overhead: 5 0.31us (Time spent on starting and stopping TIMER1)
---------- BYTE -----------
B=B+B: 9 0.56us
B=B*B: 10 0.63us
B=B xor B: 9 0.56us
---------- WORD -----------
W=W+W: 20 1.25us
W=W*W: 42 2.63us
W=W/W: 260 16.25us
W=WW: 260 16.25us
W=W xor W: 20 1.25us
Shift(W,Right,8): 62 3.88us
---------- INTEGER -----------
I=I+I: 20 1.25us
I=I*I: 42 2.63us
I=I/I: 350 21.88us
I=II: 350 21.88us
I=I xor I: 20 1.25us
Shift(I,Right,8,Signed): 82 5.13us
---------- LONG -----------
L=L+L: 44 2.75us
L=L*L: 90 5.63us
L=L/L: 878 54.88us
L=LL: 878 54.88us
L=SQR(L): 1037 64.81us
Shift(L,Right,12): 127 7.94us
Shift(L,Right,12,Signed): 155 9.69us
---------- SINGLE -----------
S=S+S: 229 14.31us
S=S*S: 260 16.25us
S=S/S: 585 36.56us
Shift(S,12): 81 5.06us
S=Log(S): 81 5.06us
S=Sin(S): 1912 119.50us
---------- DOUBLE -----------
D=D+D: 478 29.88us
D=D*D: 702 43.88us
D=D/D: 1970 123.13us
Shift(S,12): 1 0.06us
S=Log(S): 195 12.19us
D=Din(D): 15269 954.31us
-------- ASSIGNMENT ---------
B <= B: 4 0.25us
I <= I: 12 0.75us
L <= L: 20 1.25us
S <= S: 42 2.63us
---- MIXED TYPE OPERATIONS -----
L=I+I: 47 2.94us
I=B+B: 18 1.13us
S=B+B: 392 24.50us
I=I+S: 281 17.56us
I=I*S: 331 20.69us
------- TYPE CONVERSION --------
I<=B: 11 0.69us
B<=lsb(I): 8 0.50us
I<=S: 207 12.94us
S<=I: 125 7.81us
L<=S: 240 15.00us
S<=L: 133 8.31us
D<=L: 176 11.00us
D<=S: 151 9.44us
L<=D: 194 12.13us
S<=D: 183 11.44us
----- MULT Versus SHIFT LEFT ------
S=S*512=-2781337.00: 336 21.00us
Shift S,left,9=-2781337.00: 82 5.13us
D=D*512=-2781337.00: 571 35.69us
Shift D,left,9=-2781337.00: 1 0.06us
----- DIVIDE Versus SHIFT RIGHT ------
S=S/512=-10.61: 666 41.63us
Shift S,right,9,signed=-10.61: 81 5.06us
D=D/512=-10.61: 2036 127.25us
Shift D,right,9,signed=-10.61: 1 0.06us
L=L/512=-10.61: 852 53.25us
Shift L,right,9,signed = -10.61: 128 8.00us
( Observe that shifting a Single or Double )
( really works as a substitute for MULT/DIV !)
Let us push this test a little bit harder
by dividing 123.45679E6 by 2^0...2^31
MULTIPLICATION OF A SINGLE BY 2^N
(Multiply123.45679E6 by 2^0...2^31)
-------------------------------------
123.45679E6 * 1 = 123.45679E6 24.37500us
Shift 123.45679E6,LEFT,0 = 123.45679E6 5.18750us
123.45679E6 * 16 = 1.97531E9 22.37500us
Shift 123.45679E6,LEFT,4 = 1.97531E9 5.18750us
123.45679E6 * 256 = 31.60494E9 23.81250us
Shift 123.45679E6,LEFT,8 = 31.60494E9 5.18750us
123.45679E6 * 4096 = 505.67903E9 21.81250us
Shift 123.45679E6,LEFT,12 = 505.67903E9 5.18750us
123.45679E6 * 65536 = 8.09086E12 23.25000us
Shift 123.45679E6,LEFT,16 = 8.09086E12 5.18750us
123.45679E6 * 1048576 = 129.45383E12 21.25000us
Shift 123.45679E6,LEFT,20 = 129.45383E12 5.18750us
123.45679E6 * 16777216 = 2.07126E15 22.68750us
Shift 123.45679E6,LEFT,24 = 2.07126E15 5.18750us
123.45679E6 * 268435456 = 33.14018E15 20.68750us
Shift 123.45679E6,LEFT,28 = 33.14018E15 5.18750us
DIVISION OF A SINGLE BY 2^N
(Divide 123.45679E6 by 2^0...2^31)
-------------------------------------
123.45679E6 / 1 = 123.45679E6 45.87500us
Shift 123.45679E6,RIGHT,0,SIGNED = 123.45679E6 5.12500us
123.45679E6 / 16 = 7716049.00000 43.87500us
Shift 123.45679E6,RIGHT,4,SIGNED = 7716049.00000 5.12500us
123.45679E6 / 256 = 482253.00000 45.31250us
Shift 123.45679E6,RIGHT,8,SIGNED = 482253.00000 5.12500us
123.45679E6 / 4096 = 30140.81000 43.31250us
Shift 123.45679E6,RIGHT,12,SIGNED = 30140.81000 5.12500us
123.45679E6 / 65536 = 1883.80100 44.75000us
Shift 123.45679E6,RIGHT,16,SIGNED = 1883.80100 5.12500us
123.45679E6 / 1048576 = 117.73756 42.75000us
Shift 123.45679E6,RIGHT,20,SIGNED = 117.73757 5.12500us
123.45679E6 / 16777216 = 7.35860 44.18750us
Shift 123.45679E6,RIGHT,24,SIGNED = 7.35860 5.12500us
123.45679E6 / 268435456 = 0.45991 42.18750us
Shift 123.45679E6,RIGHT,28,SIGNED = 0.45991 5.12500us
↧
BASCOM-AVR : clock cycles per instruction? : REPLY
hi Per,
whooo !
[quote:4a3eb07f63]I have code to share somwhere if it is of interest
[/quote:4a3eb07f63]
Yes please , would you like share it under "Share your working BASCOM-AVR code here" with a specific name : easier to find when you look for a sample.
Many " tak "
JP :wink:
↧
↧
BASCOM-AVR : ATXMEGA does not blink : NEWTOPIC
I have a blinky program that doesnt blink. This is the simplest program I know of, so it should be easy to fix. Right?
The configuration is an ATXMEGA32A4U microcontroller on an MT-DB-X4 breakout board made by Mattairtech. It has an LED and a resistor connected to pin E1. The BASCOM-AVR code is as follows:
$regfile = "xm32A4Udef.dat"
$crystal = 2000000
$hwstack = 64
$swstack = 40
$framesize = 40
$lib "xmega.lib"
$external _xmegafix_clear
$external _xmegafix_rol_r1014
Config Porte.1 = Output
Do
Porte.1 = 0
Waitus 100
Porte.1 = 1
Waitus 100
Loop
End
The board happens to have a USB capable version of the xmega chip onboard, but in a project presently under consideration the chip to be used cannot have access to a USB connector. There will be no USB connector before during or after programming. Instead, I am using an Atmel AVRISP mkII with firmware version 1.18 to support a Program and Debug Interface (PDI).
The code listed above compiles with no errors using BASCOM-AVR 2.0.7.8. The BASCOM IDE finds the mkII, and programs the chip without any error messages. It does a convincing job of showing yellow light activity on the mkII while programming the xmega. Then, the LED on pin E1 does not blink. I'm pretty sure something simple must be missing in the code.
I wondered whether the USB drivers were OK, so I plugged the same mkII programmer into a simpler board's ISP header. From there, I used BASCOM to program an ATtiny85 with no problem. Therefore, we know the USB drivers and filter drivers are OK on my Windows 10 PC.
Next, I wrote a simple blinky program in C using Atmel Studio 7. Studio finds the mkII, and it programs the xmega via PDI. Everything works fine this way. The LED on pin E1 blinks.
The breakout board from Mattairtech has a 16 MHz crystal connected to the xmega. In C, I tried two methods. Both worked. First, I used the internal RC oscillator at 2 MHz. The LED blinked. I changed the C code to use the external crystal based oscillator and the C blinky still worked OK.
So, what is happening in BASCOM?
[b:c1a2fe4c78][color=red:c1a2fe4c78](BASCOM-AVR version : 2.0.7.8 )[/b:c1a2fe4c78][/color:c1a2fe4c78]
↧
Share your working BASCOM-AVR code here : Xmega32 E5 DDS Sine Wave Signal Generator Example : NEWTOPIC
The following is a simple DDS Sine Wave Generator for the Xmega E5 series.
It is not a Direct Digital Synthesis tutorial, but if you are familiar with the concept it should make sense.
Basically one has a signal lookup table, (Sine, Square, Triangle, etc.), and runs an ISR at a fixed, fast, rate.
One calculates the next sample to output based upon the desired output frequency, table size, and DAC update rate.
This program is set up for a 62.5 kHz DDS ISR, (sample update rate).
The number of samples the output signal has is fixed at 62.5 k samples / Second.
A 1 Hz sine wave would have 62.5 K samples for one Period of the sine wave.
A 1 KHz sine wave would have 62.5 samples per one Period of the sine wave.
A 10 KHz sine wave would have 6.25 samples per one Period of the sine wave.
Know that even a simple first or second order Low Pass Filter will significantly clean up the output signal by removing the higher frequency components of the "stair-step" signal.
There is certainly room for improvement, but this demonstrates a working example of the concept.
JC
↧
BASCOM-AVR : ATXMEGA does not blink : REPLY
Does the LED "glow" dimly?
With 100 microSec delay it will flash to fast, obviously, to see the LED flash.
Waitms 100 would give a 100 milliSec dealy, and the flash would be visible.
JC
↧
Share your working BASCOM-AVR code here : Xmega32 E5 DDS Sine Wave Signal Generator Example : REPLY
thanks for sharing :D
↧
↧
BASCOM-AVR : ATXMEGA does not blink : REPLY
I'd have to look at the Help file for more info, but in my current Xmega projects I do NOT have the:
$lib "xmega.lib"
$external _xmegafix_clear
$external _xmegafix_rol_r1014
I thought the ...fix... files were for the initial Xmega release, and are no longer needed.
Additionally, you might try configuring the LED I/O Pin the other way:
Porte_pin1ctrl = &B00000000 'PortE.1 Control Totem Pole Output
Porte_dir.1 = 1 'PortE.1 = Output
I assume you CAN read the micro's Signature Byte correctly, before you program the chip?
JC
↧
BASCOM-AVR : ATXMEGA does not blink : REPLY
you can best have a look at the Xmega samples in the help.
it will become evident that the CONFIG OSC and SYSCLOCK are missing.
Obvious you set them up in your C code but not in bascom so there is no clock. or the default value.
↧
Share your working BASCOM-AVR code here : All-in-one game board "Gamebuino" : REPLY
Hi O-Family,
As always a great project to share :D
Thank you for sharing and the clear info.
↧
Share your working BASCOM-AVR code here : manchester code : REPLY
That is what i call clever programming!
Thank you for sharing.
↧
↧
BASCOM-AVR : ATXMEGA does not blink : REPLY
Hi Mark,
You certainly know Bascom better than anyone!
I would have thought, however, that since the Xmega powers up at 2 MHz, and he set his $crystal to 2 MHz, that he would not have to configure the clock further, (unless he wants to switch to 32 MHz, etc.).
Also, can you comment on the other three Xmega instructions in his code?
Do they still serve a purpose?
$lib "xmega.lib"
$external _xmegafix_clear
$external _xmegafix_rol_r1014
Thank you, as always!
JC
↧
BASCOM-AVR : ATXMEGA does not blink : REPLY
yes these 3 lines can be omitted. you will not see them in the sample either anymore. (i hope)
the clock : when not configured, the defaults are used. it will depend on the chip.
I need to have a look at the pdf.
↧
BASCOM-AVR : ATXMEGA does not blink : REPLY
yes according to the datasheet, it should work at 2 MHz, the default.
↧