Quantcast
Channel: MCS Electronics Forum
Viewing all 20717 articles
Browse latest View live

BASCOM-AVR : Help in translate from C to Bascom : NEWTOPIC

$
0
0
Hello friendly Forum, please help me in translating this C Code to Bascom: void DRY_set_wait(){ do{ readIDE(ComSReg); }while((dataLval & ~(1<<6)) == true); } I did this: [code:1:b5b5547c65] Sub DRY_set_wait() Do Call readIDE(ComSReg) Loop Until dataLval.6 = 1 End Sub [/code:1:b5b5547c65] I think this is wrong. It loops forever. Michael [b:b5b5547c65][color=red:b5b5547c65](BASCOM-AVR version : 2.0.7.8 )[/b:b5b5547c65][/color:b5b5547c65]

BASCOM-AVR : Help while((dataLval & ~(1

$
0
0
[quote:3f351b4b32="bifi"]I konw there is a Post from MWS somewhere about translating from C to Basic[/quote:3f351b4b32] Don't remember that. [code:1:3f351b4b32](DataLval & ~(1<<6)) == true;[/code:1:3f351b4b32] The 1 <<6 is shifting an 1 6 times left, that's 01000000, the tilde bitwise NOT's this, resulting in 10111111, the & is a bitwise AND of the value and this constant. Any result other than 0 is considered TRUE in C. Now you should be able to make out the rest yourself.

BASCOM-AVR : The big difference between AVR simulator and Real hardware : NEWTOPIC

$
0
0
Please help, I work on some time critical project and I found that time (cycl.) need for GETADC is not like in AVR simulator. With DSO I measured [b:165339408d]80 times bigger value ![/b:165339408d] This is simple code for measure purpose: [color=red:165339408d]$Regfile="m328pdef.dat" $Crystal=16000000 $hwstack=32 $swstack=8 $framesize=50 Config PortD.2 = Output Config Adc = Single , Prescaler = Auto , Reference = Avcc Start Adc Dim W As Word portd.2=1 Do portd.2=0 W = Getadc(0) ' in AVR Simulator need 0.00125ms, BUT IN REAL HARDWARE WITH DSO I measured ~ 0.2ms !!! portd.2=1 waitms 2 Loop End[/color:165339408d] Where is the problem ? Best regards Z.D [b:165339408d][color=red:165339408d](BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 )[/b:165339408d][/color:165339408d]

BASCOM-AVR : The big difference between AVR simulator and Real hardware : REPLY

$
0
0
Simulation time is likely pure execution time of ASM code and does not reflect actual conversion time. If it's time critical, then the auto setting of config adc and the co mand GetADC is probably not the right thing anyway. Reading the data sheet and manually setting the prescaler is self-evident. The "auto" setting chooses the greatest ADC-prescaler and such the slowest conversion rate, also the GetADC always takes a dummy sample, thus needs two times a sampling cycle. And btw., your problem whatsoever is in no way more important than others. Coloring the code in red instead of using proper code tags doesn't show most clever behavior.

BASCOM-AVR : The big difference between AVR simulator and Real hardware : REPLY

$
0
0
Thank you MWS for clear and quick answer, also is clear for coloring code...

BASCOM-AVR : Help while((dataLval & ~(1

BASCOM-AVR : Variabel list : REPLY

$
0
0
(After some time...) Hi! Since i'm always a bit puzzled with stack settings, too, and always set them...random, i guess... i wonder... after compiling report says that certain amount of RAM is left "unused". Does this mean that it's totally unused, like it isn't there at all? Wasted space? With other words: when my program is finished and compiled, can i increase swstack, hwstack and framesize up until that "RAM space left" is almost zero? If that RAM is unused and wasted, it's better to be unused in stack than nowhere... Am i thinking in a right way? Thanks! Regards, Paul

BASCOM-AVR : Variabel list : REPLY

$
0
0
it is philosophical... unused Stack or unused variables .... what can be the difference between? I can tell you, what they have both: the word "unused" :lol:

BASCOM-AVR : Variabel list : REPLY

$
0
0
I agree, sure. But, if i have extra unused space is then still better to increase those three things too much and be sure that they won't overflow at any moment... I just wanted to be sure that 'unused' space is really not used and i can safely use it to the end...

BASCOM-AVR : Howto get an AVR calculated array transferred to Bascom DATA : REPLY

$
0
0
[quote:d87451b41a="olhexy"] I feel the need to have some WriteProtect for the files that I would like to keep unchanged. Just saving them in a separate User directory ('FinishedProgram') does not work for me: if I open them in Editor even the slightest touch leads to save/change. May be I should simply set the WriteProtect check...? (I never tried that) [/quote:d87451b41a] Well, today I did try WriteProtect! And I think it will help me a lot to keep my working my working creations safe. And I discovered something else. I rarely used "examples" from Bascom because I allways was afraid to mess them up. Looking at the WriteProtect the Bascom/Examples directory in User [i:d87451b41a]shows[/i:d87451b41a] as Writeprotected (The checkbox is blue). All subdirectories [i:d87451b41a]show[/i:d87451b41a] as WriteProtected too, but strange enough: the files inside are [b:d87451b41a][u:d87451b41a]N O T[/u:d87451b41a] [/b:d87451b41a] WriteProtected :roll: :arrow: Mark: I think this could be an install error... (I did a total fresh install of Bascom a few months ago). Please have a look at it? I could solve it easily: setting the WriteProtect again (off-on) of the Examples directory Windows offered to WriteProtect all files there and in subdirectories and I eccepted. And then the files show as WriteProtected. Opnening examples does't harm anymore. :D

BASCOM-AVR : Variabel list : REPLY

$
0
0
local variables use the "Frame" they use dynamic memory, when you leave the procedure, memory is again available. I use a lot of sub and function in my programs and I never use " gosub " anymore. and of course ! is so nice : Config Submode = New and Goto ? only for a soft reset Goto 0 do you know an other way ? :roll: jp

BASCOM-AVR : Variabel list : REPLY

$
0
0
Well, i'm not very experienced programmer, so "goto" is still on my list, unfortunately. I know, it's not professional, but...i'm learning... so far i've only had projects with enough RAM space, so i was be able to "waste" it...

BASCOM-AVR : Looking for an updated m32U4def.dat : NEWTOPIC

$
0
0
I wanted to build something using the Mega32U4. However, even sample code fails to compile when using the m32U4def.dat file. For instance, loading the clock sample gives compiler errors about AS2 Bit Definition Not Found. I added the line AS2 = 1 into the dat file, but still get the same error. Using the m32def.dat file works. So, does anyone have an updated/tweaked dat file for the M32U4? Thanks! [b:3d29319405][color=red:3d29319405](BASCOM-AVR version : 2.0.7.8 )[/b:3d29319405][/color:3d29319405]

BASCOM-AVR : Print lower case bug !!! : REPLY

$
0
0
Hi! nothing has been said about what program is used as terminal on PC side? I've had problems with bray terminal, who CAN corrupt characters for no reason, so i rarely use it. Funny thing is that when i used it on xmega128 @46MHz it corrupted data at 9600 baud, but worked perfect at 256000 :shock: So, maybe changing terminal program is a start...

BASCOM-AVR : Print lower case bug !!! : REPLY

$
0
0
Since I happened to be playing with serial comms on another project, I ran this: [code:1:b6e67c7380] $regfile = "m644pdef.dat" $crystal = 3686400 'clock speed $hwstack = 130 $swstack = 50 $framesize = 80 Enable Interrupts Config Clockdiv = 1 $baud1 = 9600 Config Com2 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 Config Serialin1 = Buffered , Size = 250 Config Serialout1 = Buffered , Size = 250 open "com2:" for binary as #1 'Print with Uppercase characters works always but Lowercase character is still not reliable. do Print #1, "mworld.be" 'give random result !!!! waitms 100 loop [/code:1:b6e67c7380] Yes its a different processor, clock speed, serial port, etc Result on Teraterm was "mworld.be" for as long as I let it run, about 10 mins. No errors. Seems to me its a hardware problem.

BASCOM-AVR : Looking for an updated m32U4def.dat : REPLY

$
0
0
[quote:9d93cbdcf8="CBailey"]I wanted to build something using the Mega32U4.[/quote:9d93cbdcf8] That's ok. [quote:9d93cbdcf8]However, even sample code fails to compile when using the m32U4def.dat file. For instance, loading the clock sample gives compiler errors about AS2 Bit Definition Not Found.[/quote:9d93cbdcf8] It's a world of wonders. One of them is, there's not AS2 bit within ATN32U4, the same as there's no asynchronous RTC clocked by an external 32kHz crystal, which would be needed by the clock sample. [quote:9d93cbdcf8]I added the line AS2 = 1 into the dat file, but still get the same error.[/quote:9d93cbdcf8] No wonder here. [quote:9d93cbdcf8]Using the m32def.dat file works.[/quote:9d93cbdcf8] Sure, if you also use an ATMega32 then, the code will even run on the hardware and won't crash immediately. [quote:9d93cbdcf8]So, does anyone have an updated/tweaked dat file for the M32U4?[/quote:9d93cbdcf8] Why?

BASCOM-AVR : I2C sequential reading and address change : NEWTOPIC

$
0
0
Hi! I have this situation: I'd like to read 7 bytes from address A, then 7 bytes from address B and another 12 bytes from address C. Since bytes are read into array, i use for-next loop. Now, do i HAVE to read last (seventh) byte with "Nack" option and use i2cstop, wait a while and start second reading with i2cstart or can i simply send another i2cstart, following new read address? i mean, can i do like exapmle below or MUST i insert one read with "Nack" and stop betewwn each read? [code:1:2e18904896] I2Cstart I2Cwbyte addr_read I2Cwbyte 0 I2Cwbyte 1 I2Cstart For n=1 to 7 I2Crbyte A(n), Ack next I2Cstart I2Cwbyte addr_read I2Cwbyte 1 I2Cwbyte 1 I2Cstart For n=1 to 7 I2Crbyte B(n), Ack next I2Cstart I2Cwbyte addr_read I2Cwbyte 2 I2Cwbyte 1 I2Cstart For n=1 to 12 I2Crbyte C(n), Ack next I2Cstop [/code:1:2e18904896] [b:2e18904896][color=red:2e18904896](BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 )[/b:2e18904896][/color:2e18904896]

BASCOM-AVR : Looking for an updated m32U4def.dat : REPLY

$
0
0
Well THERE'S my problem. Thanks.

BASCOM-AVR : Serialin and data corruption : REPLY

$
0
0
[quote:7c6ca49fc2="Plons"]Hi laborratte ! Double buffer in Ram of the Mega8 is a good idea :!: Nested interrupts are not required in this Tile-design, IMO. I did the math. Even with SPI as low as 4Mhz and Buffered Serial in @ 115kbaud, the two don't interfere. Intensity variation caused by Buffered Serial In on the Scan task is less than 1%. At 150Hz refresh for the tile, thus 300Hz for the Scantask, the 3.3ms is 300 times higher than the let's say 10us for the Buffered Serial In int handler. I am convinced that's not visible. :) Techknight, was the program I posted here: [url]http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&p=70826#70826[/url] usefull to you ? edit: fixed the link[/quote:7c6ca49fc2] I had to button the project up and get it out the door... I got it working enough to finish the job, So no, I havent tried it yet HOWEVER... I am working on another design with some of your suggestions, and I am going to try this framework at that point. Thatll be implemented in my team name captions.

BASCOM-AVR : Serialin and data corruption : REPLY

$
0
0
[quote:ba0da67ee7="JC"]I noticed that transistors Q8, 10, and 17 are in parallel, presumably for increased current drive capability. My brain is old and tired, and I understand that some FETs don't experience thermal run away like older bi-polar transistors, (their S-D current decreases as their temperature increases, instead of the other way). That said, I didn't see the model number for the transistors in use. It would be worth verifying their thermal run away characteristics in the data sheet. Even a very low series resistor can help significantly with low leveling between the three. With the wide variety of power FETs available these days I wonder if there is some advantage to using the paralleled configuration instead of a single device rated for the current required? JC[/quote:ba0da67ee7] AO4441 I used 3 in parallel to decrease the RDS-On, But the downside, it increases the total overall gate capacitance. This is why I chose to use the push-pull driver. Sure, the transistor voltage drops are a little harsh bringing the gate voltage lower than 5V, However, the purpose was to switch the MOSFETS on faster than if I were to use a single transistor with a pull-up. The thought process was to decrease the transition skew caused by the gate capacitance and the discharge/charge rate. Using the transistors, it would allow the transition to become faster, reducing the potential for ghosting, and allowing me to increase the scanning speed a bit. But, The initial design was for a 12V tile. That got reduced to 5V, So i think simple logic-level FETS with low gate capacitance would work just as well. Maybe even using an inverter gate by itself to drive the MOSFETs, open-drain or open-collector inverter IC with a pullup.
Viewing all 20717 articles
Browse latest View live


Latest Images