Hello all,
Can anyone tell me if the Asm code, "sleep" is the same as MCS BASCOM "Powerdown"?
If not, can anyone tell me how to modify Everts asm code to emulate the Powerdown command of MCS BASCOM?
[code:1:1899b6ab9a]
' Powerdown
'The asm code below by Evert Dekker disables the Brownout Detect, And puts the device to sleep.
$asm
lds r25,MCUCR 'get current MCUcR
sbr r25,&B01100000 'Set bit 5 & 6 (BODSE & BODS) (1 Clks)
sts MCUcR,r25 'save to MCUcR (2 Clks)
sbr r25,&B01000000 'Set bit 6 (BODS) (1 Clks)
cbr r25,&B00100000 'Clear bit 5 (BODSE) (1 Clks)
sts MCUCR,r25 'save to MCUcR (2 Clks)
Sleep 'good night (1 Clks)
$end Asm
[/code:1:1899b6ab9a]
Thank you,
Tim
[b:1899b6ab9a][color=red:1899b6ab9a](BASCOM-AVR version : 2.0.7.8 )[/b:1899b6ab9a][/color:1899b6ab9a]
↧
BASCOM-AVR : Is the Assembler 'sleep' command the same as BASCOM Powerdo : NEWTOPIC
↧
BASCOM-AVR : Is the Assembler 'sleep' command the same as BASCOM Powerdo : REPLY
sleep is an assembler mnemonic.
powerdown uses sleep too. All sleep modes require to set some bits in a register in a special sequence and end with the sleep instruction.
it differs from chip to chip.
↧
↧
BASCOM-AVR : Is the Assembler 'sleep' command the same as BASCOM Powerdo : REPLY
Hi Mark,
I am using an Atmega 168PA. I was using the BASCOM command "powerdown". But I wanted to also turn off the BOD. I found a thread wherein Evert wrote the asm code I included in the original post. I wanted to be sure that the effect of using the assembler mnemonic command 'sleep' was the same as the powerdown command built into BASCOM.
Tim
↧
BASCOM-AVR : Is the Assembler 'sleep' command the same as BASCOM Powerdo : REPLY
please stick to bascoms config power= . it is really the best for you to do.
or take time to read the data sheet. the MCUCR register in the mentioned chip is totally different. as far as i can see the bod can only be turned off by the fuse bits in the m168.
Table 10-1 in the pdf lists the various power modes.
↧
BASCOM-AVR : Include file format for latest compiler update : NEWTOPIC
I found that using earlier compiler versions that the include file I used worked fine without having to add the $regfile = "M128def.dat".
When I went to version 2.07.8,my include files had memory error messages until I added the $regfile = "M128def.dat" statement.
Has anyone else experience this?
Thanks and keep up the good work!
[b:a41b51b54e][color=red:a41b51b54e](BASCOM-AVR version : 2.0.7.8 )[/b:a41b51b54e][/color:a41b51b54e]
↧
↧
BASCOM-AVR : Include file format for latest compiler update : REPLY
include files should not have this info. maybe you can post some example of the problem.
when using include files, it is best to work in project mode. otherwise each file you edit is seen as a stand alone file. in project mode, the inc files are seen as part of the main file.
i am not sure if that is what you mean. but as always, without sample to check it is hard to tell.
↧
BASCOM-AVR : Include file format for latest compiler update : REPLY
Thank you for responding so quickly.
I'm not working in project mode. However I did not have this problem with earlier versions.
I will work in project mode from now on.
↧
BASCOM-AVR : Include file format for latest compiler update : REPLY
[quote:c29d3001ea]I used worked fine without having to add the $regfile = "M128def.dat".[/quote:c29d3001ea]
Maybe you had set the chip M128 in "Menu-Options-Compiler-Chip".
Then you did not need to include .dat file.
↧
Share your working BASCOM-AVR code here : ILI9341 with SW/HW SPI, 8/16 Bit parallel mode : REPLY
Hi, Netzman,
I tried the suggestions, but two errors remains that I can't resolve :
Error : 12 Line : 455 Unknown CONFIG parameter [COMPARE_PWM] , in File : ILI9341.inc
Error : 46 Line : 435 Assignment error, unknown variable (DIM) [COMPARE2: 0 VALUE: 2] , in File : ILI9341.inc
There are nothing with the line numbers 455 and 435...
Maybe some problem with the $regfile ?
Thanks !
Paulo
↧
↧
BASCOM-AVR : Include file format for latest compiler update : REPLY
Thank you sir for the suggestion . It worked!!!
↧
BASCOM-AVR : Szukam kodu do Xmega ADC wewnętrznej temperatury. : NEWTOPIC
As the topic I am looking for sample code to read the internal temperature of ATXMega128A4U. Free Run mode 12Bit. someone help
[b:1849a3b318][color=red:1849a3b318](BASCOM-AVR version : 2.0.7.8 )[/b:1849a3b318][/color:1849a3b318]
↧
BASCOM-AVR : Is the Assembler 'sleep' command the same as BASCOM Powerdo : REPLY
Hi.
The M168PA is a picoPower device and supports BOD software disable. The mechanism for enabling is identical to the chip Evert was using.
The sleep mode which is executed by the [b:94a42feb9d]sleep[/b:94a42feb9d] instruction depends on SMCR (sleep mode control register). See datasheet chapter 10 for details.
For your specific mode and chip the assemble instructions could be as follow:
[code:1:94a42feb9d]
'Power down on M168PA with BOD disable
$asm
ldi r25,&B00000101 'set sleep mode to power down (SM2:0 = 010) and enable sleep (SE = 1)
sts SMCR,r25 'save to SMCR
lds r25,MCUCR 'get current MCUCR
sbr r25,&B01100000 'Set bit 5 & 6 (BODSE & BODS) (1 Clks)
sts MCUCR,r25 'save to MCUCR (2 Clks)
'sbr r25,&B01000000 'Set bit 6 (BODS) (1 Clks) (this line is redundant and don't need to execute)
cbr r25,&B00100000 'Clear bit 5 (BODSE) (1 Clks)
sts MCUCR,r25 'save to MCUCR (2 Clks)
Sleep 'good night (1 Clks)
clr r25 'it is recommend to disable sleep after wake up (see datasheet)
sts SMCR,r25 'save to SMCR
$end Asm
[/code:1:94a42feb9d]
Keep in mind that this sequence is chip specific and may not work on other chips. That is why Mark recommend to use [b:94a42feb9d]config power[/b:94a42feb9d]...
↧
BASCOM-8051 : need help with counter : NEWTOPIC
a friend asked me to make a control circuit to his winding machine
the circuit is a simple counter with lcd , 5 buttons to enter 5 digits numbers , like this
0 0 0 0 0
b1 b2 b3 b4 b5
you press p1 it change first digit from 0 to 9 and if it reched to 9 the next press will reset it
it should ask you to enter the number of winds first ,
then you press enter , relay will start the motor ( pin output connected to relay ) and limit switch will create pulses to microcontroller
im using Bascom 2.0.13 , i have no problem with hardware i can handle it , my problem is in code , i dont know how to start ,,
[img:f222b2b4ef]http://store1.up-00.com/2015-04/1430146498071.png[/img:f222b2b4ef]
↧
↧
BASCOM-AVR : Is the Assembler 'sleep' command the same as BASCOM Powerdo : REPLY
Hi labboratte,
Yes, I know it was the same family and supports this feature. I just wanted to be sure that the sleep command is the same as the BASCOM sleep. Previously, I was using only the built in commands. I started looking into turning off BOD as saw the thread on the forum - discussing the timing issues and the necessity to use asm - which I have not a clue about coding.
I see the differences you made and thank you. I had not tested either yet but plan to today.
One thing, can you tell me what R25 means?
Thank you again,
Tim
↧
Share your working BASCOM-AVR code here : LinkSprite UART Camera and a TinySine SIM900 GSM/GPRS Module : NEWTOPIC
The attached program instructs a LinkSprite color camera to take a picture and send the resulting JPEG file to a TinySine SIM900 GSM/GPRS module. The SIM900 module is then instructed to send the picture to mobile phone and/or email address as a MMS file.
The electronic design uses the single hardware UART of the ATMega168PU to communicate with the SIM900 and LinkSprite camera. The UARTs of the three devices are connected in a loop (i.e. ATmega to the SIM900, SIM900 to the LinkSprite and LinkSprite back to the ATMega). Located in each of the three legs of this loop is a tri-state gated buffer/driver (parts of a 74LS125). When a buffer is disabled its output transistor is turned off which blocks data flow and presents a high impedance state to the data line.
The process for taking the picture and sending it out via the SIM900 as an MMS file is the following:
1. Enable the ATMega-to-LinkSprite UART link and disable the LinkSprite-to-SIM900 and SIM900-to-AtMega links. Send commands to the LinkSprite to take a picture.
2, Disable the ATMega-to-LinkSprite link and enable the ATMega-to-SIM900 link (leave the LinkSprite-to-SIM900 link disabled). Send AT commands to the SIM900 to establish a phone connection and prepare to download a MMS file. The SIM900 is left waiting for the MMS data to arrive.
3. Disable the ATMega-to-SIM900 link and enable the ATMega-to-LinkSprite and LinkSprite-to-SIM900 links and give the LinkSprite the command to download the JPEG file in one batch. Once the file is received by the SIM900 it will transmit the file without any further commands from the ATMega.
There is probably also a way to achieve this operation using the multiple hardware UARTs of the Arduino Mega 2560 and transmitting the JPEG files in small batches using the greater memory capacity of the Mega 2560.
I prefer using the ATMega168 as it comes in a through-hole DIP which makes it easy to incorporate into custom PCBs. Nonetheless, later I may try using the Mega 2560 and a 3G SIM module.
In late 2015 I will be updating this program to use the WDT and other features to improve the systems ability to recover from anomalies. Use of the DS3232M RTC and TMP102 temperature sensor and the reading of SMS messages will also be added.
I have a pdf file showing the electrical design but it doesn't seem that we can attach such files.
↧
BASCOM-AVR : Is the Assembler 'sleep' command the same as BASCOM Powerdo : REPLY
r25 is one of 32 general purpose registers of the CPU. Nearly every data transfer and caluculation has to be done with these registers. For details see Chapter 7 of 168PA's datasheet.
↧
BASCOM-AVR : Is the Assembler 'sleep' command the same as BASCOM Powerdo : REPLY
Thanks will do!
Tim
↧
↧
BASCOM-AVR : Need debounce help : REPLY
Thank you , mark for the reply. The more I think about it though, my solution my not be so effective. Are my revised comments maybe what is really happening?
The routine I wrote checks the switch a second time after 25ms, but what I think would be better is to make sure the
switch was actually held low for AT LEAST 25ms. I am looking for an approach that would mandate that the button be pressed for a minimum time. Any advice how to code for that? Thanks so much
do
if pinb.4 = 0 then 'check pinb.4
waitms 25 'wait 25ms IF EVEN THE SLIGHTEST BUMP CAUSED PINB.4 TO EQUAL ZERO
if pinb.4 = 0 then 'check pinb.4 again
led = 1 ' if button was held down at least 25 continuous ms then turn led on
end if
end if
loop
↧
Share your working BASCOM-AVR code here : LinkSprite UART Camera and a TinySine SIM900 GSM/GPRS Module : REPLY
I am posting this separately as I didn't want my confessions to get lost in the long summary of my initial posting. There are two issues that I am working on relative to the use of the LinkSprite IR camera.
1. The camera response to a request to download a jpeg file begins with an unsolicited response code (URC) of five bytes followed by the jpeg header of FF D8. Fortunately one can specify a interval time between the URC and the FF D8. I specify a delay of 20 ms and then delay establishing the connection between the camera and the SIM900 by 12 ms to block the URCbytes. But even with this Windows Photo Viewer can not open the file. To view the photo I use XnView. (In this regard, the wait period for Image = 3 following the AT+CMMSSEND command in my code needs to be increased to 60 seconds).
2. For all of my photos I have wide bands that extend upward from the bottom of the picture. I have spent hours searching the Internet and have found that this is a common problem with this camera but I have found no solution. I have a different LinkSprite camera on order which I believe is somewhat newer. I will see how it works.
I will post anything I learn on these two issues on the forum.
↧
BASCOM-AVR : TSA5511 PLL High and Low Byte calculation : NEWTOPIC
Hi all
My issue:
1. Not knowing how to calculate the precise value to write to the TSA5511
2. Not know how to get the High and Low byte to send to the TSA5511.
1.
------------
I am using the TSA5511 PL ic that is controlled via i2c.
The PLL is used in a 23cm(1250mhz) oscillator..
the Crystal connected to the TSA5511 is 3.2Mhz.
For example I want to lock the PLL at 1240mhz.
(I have captured the data from an existing code that locks the PLL at 1240.. see attachment.)
If I look at the block diagram I see the following on page 4
(link to datasheet: http://www.pselectronic.cz/pdf/1124/11241425.pdf )
The RF signal, In my case is dived by 8.
1240/8 = 155mhz
My crystal is 3.2mhz
3200/512 = 6.25khz
What do I have to do further to get to get the correct value?
2.
-----------------------
After getting the correct value..
It must be splitted in 4 bytes..
I presume the value is a long.
So the long has to be splitted into 4 bytes..
In The bascom example I can only find the example to split a long into 2 words.
And an example of splitting a word into 2 bytes
(http://mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=10787&postdays=0&postorder=asc&highlight=tsa5511&start=0&sid=c7a8e09eb49d376d6dfc1f0e75c3ec6a)
I don quite understand how this works.
Hope someone can give my some advice how to look further.[/code]
[b:466fa92cec][color=red:466fa92cec](BASCOM-AVR version : 2.0.7.7 , Latest : 2.0.7.8 )[/b:466fa92cec][/color:466fa92cec]
↧