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

BASCOM-AVR : Set all bytes in an array to a value - is there a way? : REPLY

$
0
0
Hi, Try making a small "simple" program and run it in the Simulator looking at the Memory. Regards Ian Dobson

BASCOM-AVR : Set all bytes in an array to a value - is there a way? : REPLY

$
0
0
Hi Ian Have done just that and also found var = STRING(m ,n) This seems to work [code:1:181392017b] $regfile = "m2560def.dat" ' specify the used micro $crystal = 16000000 ' used crystal frequency $baud = 56700 ' use baud rate $hwstack = 180 $swstack = 250 $framesize = 200 Dim Tests As String * 10 Dim Bytes(11) As Byte At Tests Overlay Dim X As Byte Tests = "1234567890" For X = 1 To 10 Cls Locate 1 , 1 Lcd Bytes(x) Wait 2 Next Cls Locate 1 , 1 Lcd "next" Tests = String(10 , 0) Wait 5 For X = 1 To 10 Cls Locate 1 , 1 Lcd Bytes(x) Locate 2 , 1 Lcd X Wait 2 Next End [/code:1:181392017b] Regards Paul

BASCOM-AVR : Set all bytes in an array to a value - is there a way? : REPLY

$
0
0
Hi, There are many ways to Skin a cat. Looks as if String command does the same thing as memcopy with Option 2. But looking in the help text I see: Since a string is terminated by a 0 byte, you can't use 0 for n. where n is the ASCII char to use. Regards Ian Dobson

BASCOM-AVR : RTC Running During PowerSave on XMEGA : NEWTOPIC

$
0
0
Hello Forum, The code below does keep proper clock time during power reduction periods and I see power consumption going from about 19 mA to about 50 uA on my setup (which is OK but would prefer a little less). However, the code seems not very smart. The micro is woken up every second by the RTC Interrupt, increments the time variable and goes back to PowerSave mode. This continues until the user pushes a button on PORTE.5. Is there a better way to do this? Possibly reduce power consumption a little more? [code:1:feb6dabeab]$regfile = "xm128a3def.dat" $hwstack = 1200 $swstack = 1200 $framesize = 1200 $crystal = 32000000 Config Osc = Enabled , 32mhzosc = Enabled 'internal 2 MHz and 32 MHz enabled Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1 'use 32 MHz Stop Watchdog Config Power_reduction = Dummy , Aes = Off , Dma = Off , Ebi = Off , Evsys = Off , _ Daca = Off , Dacb = Off , Adcb = Off , Aca = Off , Acb = Off , Rtc = On , _ Twic = Off , Twid = Off , Twie = Off , _ Usartc0 = Off , Usartc1 = Off , Usartd0 = Off , _ Usartd1 = Off , Usarte0 = On , Usarte1 = Off , Usartf0 = Off , _ Tcc0 = Off , Tcc1 = Off , _ Tcd0 = Off , Tcd1 = Off , _ Tce0 = Off , Tce1 = Off , _ Tcf0 = Off Config Submode = New '============================================ 'Config SOFT Clock '============================================ Config Clock = Soft , Rtc = 1khz_int32khz_ulp , Gosub = Sectic 'select internal 1 KHz clock from the 32KHz internal oscillator Dim Calc_ave As Byte , Long_time As Long , No_power As Byte Date$ = "09/20/14" : Time$ = "09:58:01" 'Hard time dummy date Long_time = Syssec() Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled '==================================================== 'Wake Up '==================================================== ' 7654_3210 Const Port_conf = &B0010_0000 'Define Pins on PORT Wake_pin Alias Pine Config Wake_pin.5 = Input Config Xpin = Porte.5 , Outpull = Pullup , Sense = Low_level 'enable Pull up Porte_int0mask = Port_conf 'include PINs in INT0 Mask for Port Porte_intctrl = &B0000_00_01 ' ^ 'Low Level INT0 Interrupt for Port On Porte_int0 Wake_detect_isr 'ISR Enable Porte_int0 , Lo Enable Interrupts Wakeup_start: Config Com5 = 57600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 Open "COM5:" For Binary As #1 ' ===== M A I N ===== Do If Calc_ave <> _sec Then Calc_ave = _sec Print #1 , Time(long_time) End If If _sec = 0 Then 'time to shutdown Config Power_reduction = Dummy , Usarte0 = Off Usarte0_ctrlb.6 = 0 : Usarte0_ctrlb.4 = 0 : Usarte0_ctrlb.3 = 0 Porta = 0 : Portb = 0 : Portc = 0 : Portd = 0 : Porte = 0 : Portf = 0 : Portr = 0 No_power = 1 Waitms 100 Enable Porte_int0 , Lo 'make sure can wake up Do Config Powermode = Powersave Loop Until No_power = 0 Exit Do End If Loop Goto Wakeup_start End 'end program Close #1 Wake_detect_isr: No_power = 0 Return Sectic: Incr Long_time Return [/code:1:feb6dabeab] [b:feb6dabeab][color=red:feb6dabeab](BASCOM-AVR version : 2.0.7.7 )[/b:feb6dabeab][/color:feb6dabeab]

BASCOM-AVR : RTC Running During PowerSave on XMEGA : REPLY

$
0
0
Some suggestions: a) An outer Do/loop instead of the Goto would look nicer. b) In Powersave mode, clock to peripherals is already stopped, so Config Power_reduction won't achieve anything in Powersave mode. In active mode it may help a bit, but I think there you revert the effect, as you issue a second Config Power_reduction coomand, which according to the help, does not work selectively, instead absolutely. Means you re-enable everything, which you did previously disable. c) I'd disable Porte_int0 within the int0-ISR, to avoid continuous interrupts, if the use keeps the button pressed. d) The XM128 should use at ambient temperature a bit around 0.5µA, which means 50µA is way too much. Either your measuring instrument gives you wrong values, or you have something on your PCB that draws this current. I'd write some simple code, which sends the controller to Powersave, nothing else. Then disconnect everything and measure the current.

BASCOM-AVR : RTC Running During PowerSave on XMEGA : REPLY

$
0
0
[quote:7f6bf9a34d]b) In Powersave mode, clock to peripherals is already stopped, so Config Power_reduction won't achieve anything in Powersave mode. [/quote:7f6bf9a34d] I did not know this. Will change it accordingly. [quote:7f6bf9a34d] In active mode it may help a bit, but I think there you revert the effect, as you issue a second Config Power_reduction command, which according to the help, does not work selectively, instead absolutely. Means you re-enable everything, which you did previously disable. [/quote:7f6bf9a34d] This is interesting. I will remove the statement. [quote:7f6bf9a34d] c) I'd disable Porte_int0 within the int0-ISR, to avoid continuous interrupts, if the user keeps the button pressed. [/quote:7f6bf9a34d] You're right MWS. This was a snippet and the full code does handle it as you suggested. [quote:7f6bf9a34d] d) According the data sheet the XM128 should use at ambient temperature a bit around 0.5µA, which means 50µA is way too much. Either your measuring instrument gives you wrong values, or you have something on your PCB that draws this current. I'd write some simple code, which sends the controller to Powersave, nothing else. Then disconnect everything and measure the current.[/quote:7f6bf9a34d] Yes, I know I have poor instruments to measure current, and, the 50 uA was measured on a board with some other circuits - including resistor dividers to ground for ADC. So overall, the "ugly" part of the code that includes waking up the micro every second to increment the time variable, is the only way to do this. Thanks for your help.

BASCOM-AVR : Set all bytes in an array to a value - is there a way? : REPLY

$
0
0
Hi and thank you for all your replies everyone! I did not expect such activity on this thread but am thankful for your responses and help. Tim

BASCOM-AVR : Bug when using more than 64k Flash on ATMega 1284P : REPLY

$
0
0
[quote:182d63fd64="albertsm"]that was already solved. i gave access to the beta but did not heard back?. that problem was very simple. the code contained an lpm where it should call a special lpm routine which increases rampz at a page boundary. for some reason search on my project did not find all lpm code when i changed it many years ago. but like i wrote before , this is different. it is likely the rampz gets a wrong value at some stage but i do not like guessing. i like some code to look at.[/quote:182d63fd64] Hi Mark, I actually come back with this problem. After reorganizing my programm I never exceed the 50% Flashrange of my XMega128A4-AU. But right now I am getting over the 50% Flash usage. My LCD will show bad graphics if I step over this limit. If I remove some code, a included picture or an font file (doesn´t matter WHAT will be removed) and the 50% will not exceed, everything works fine again. I really have no idea any more. As the Project is very big and contains some sensible data, I would like to send it to you instead pf posting. Will it be ok? BR, Jens

Share your working BASCOM-AVR code here : OLED Display using SSD1306 with i2c. Char Mode 16x4 : REPLY

$
0
0
Hello, I inserted the code, and unfortunately remains the same. see photo On the display you can see "1 2 3 HELLO" horizontally. I believe that when exceed fonts 5x7 something happens. I do not understand this variable "Oled_8x16str = & H10" [img:7cfddda6de]http://imagizer.imageshack.us/v2/150x100q90/901/flhzZB.jpg[/img:7cfddda6de] THX.

Share your working BASCOM-AVR code here : OLED Display using SSD1306 with i2c. Char Mode 16x4 : REPLY

$
0
0
Hi. The picture is very small, anything is unclear (the problem). On the market there are at least two types SSD1306 controllers. One (described at the beginning of the theme) with its additional controller functions (output text, fonts, memory structure). Second (described further in the end) - is a pure controller (SSD1306), in it there are no additional features (no fonts, word processing). To get it all, you need to write the code yourself output. Ie theme of several types of SSD1306 Controller. It is not clear which model you have the controller. ps: "Oled_8x16str = & H10" - apparently this is one of the modes of text output (for the first type).

BASCOM-AVR : Crystal calibration via SNTP : REPLY

$
0
0
Update I have been experimenting with my slow way of finding the crystal frequency I have been comparing the system seconds with the NTP seconds and adjusting the variable that represents the crystal frequency. If the system seconds are less then the crystal is less than the variable so I reduce the variable re-sync to NTP then after 1 hour compare again. Note the frequency measured was 159000075Hz but as the clock out pin of the Arduino 2560 is not connected I have to measure at the crystal this loads it slightly. From observations so far this is working. The value is coming closer and closer to the measure crystal frequency Setting the variable to the measured crystal frequency shows a gain of one second over 10 Hours The code so far is simple It needs some fast then slow adjustments to the value also needs to ignore a wild value when NTP is not valid Once the value is stable it then needs to be written to eeprom Regards Paul [code:1:f25bc3fa8e] If L4 = 3600 Then '1 hour is up we will use NTP to determin the crystal frequency L4 = 0 Call Sntp_compare 'L5 will have NTP seconds 'L2 will have the system seconds Select Case L5 Case Is > L2 Print "sys" ; L2 Print "ntp" ; L5 L6 = L5 - L2 Print "slow>" ; L6 If L6 > 3 Then Xtal = Xtal - 600 'reduce variable by 600Hz Print "Less 600" Print "Freq=" ; Xtal Call Sntp_get End If Case Is < L2 L6 = L2 - L5 Print "sys" ; L2 Print "ntp" ; L5 Print "fast>" ; L6 Case Else Print "Same" End Select End If [/code:1:f25bc3fa8e]

BASCOM-AVR : Currect handling og RAMPZ in ISR : NEWTOPIC

$
0
0
Hi All, I'm currently working a a Project and I have the Feeling that the code will end up > 64Kb (using a atmega1284). Up until now I've never really worried about the RAMPZ Register as most of my Projects are small'ish (<32Kb). I've created a small program with an ISR/PUSHALL-POPALL to just look at what code bascom creates and using objdump I'm seeing this for pushall:- 1460: Pushall [code:1:a393f3dd47]0000280C: 920F PUSH R0 Push Register on Stack 0000280E: 921F PUSH R1 Push Register on Stack --snip 00002836: 93CF PUSH R28 Push Register on Stack 00002838: 93DF PUSH R29 Push Register on Stack 0000283A: 93EF PUSH R30 Push Register on Stack 0000283C: 93FF PUSH R31 Push Register on Stack 0000283E: B78F IN R24, $3F Load an I/O Location to Register 00002840: 938F PUSH R24 Push Register on Stack 00002842: B78B IN R24, $3B Load an I/O Location to Register 00002844: 938F PUSH R24 Push Register on Stack 00002846: 2788 EOR R24, R24 Exclusive OR 00002848: BF8B OUT $3B, R24 Store Register to I/O Location [/code:1:a393f3dd47] popall Looks normal: 1487: Popall [code:1:a393f3dd47] 00002930: 918F POP R24 Pop Register from Stack 00002932: BF8B OUT $3B, R24 Store Register to I/O Location 00002934: 918F POP R24 Pop Register from Stack 00002936: BF8F OUT $3F, R24 Store Register to I/O Location 00002938: 91FF POP R31 Pop Register from Stack 0000293A: 91EF POP R30 Pop Register from Stack 0000293C: 91DF POP R29 Pop Register from Stack 0000293E: 91CF POP R28 Pop Register from Stack [/code:1:a393f3dd47] $3f Looks like SREG, and $3B is RAMPZ. So whats Bascom doing with the RAMPZ register (copy to R24, push to stack, Exclusive OR r24 with r24, copy r24 to RAMPZ). So simply put what the hell is bascom doing with RAMPZ, the EOR Looks totally unnecessary, unless it's doing something clever that I don't understand. Regards Ian Dobson [b:a393f3dd47][color=red:a393f3dd47](BASCOM-AVR version : 2.0.7.7 )[/b:a393f3dd47][/color:a393f3dd47]

BASCOM-AVR : Currect handling og RAMPZ in ISR : REPLY

$
0
0
i am not going to make a habit of explaining code from objdump so this is the first and last time. If you want to know you can write to support since you have an SLA. Second it has nothing to do with hell. The problem of these dump tools: they have multiple choices. what actually happens is CLR r24. and eor reg,reg is the same. the rampz is cleared. this way it points to the default assumed page. depending on the platform, rampz has multiple usage. normally is it only for elpm, spm , but it also form an extended 24 bit address for sram access on xmega. if you write your own lib/isr you should save/restore rampz when the processor >64KB.

BASCOM-AVR : Bug when using more than 64k Flash on ATMega 1284P : REPLY

$
0
0
you can best write to support. but i do expect you have tested with the latest version. include app files (zipped) and mention version and serial. the Xmega is special since it uses rampz for both elpm and memory access. this means that rampz need to be set to the proper value for normal ram access too. So this is some other problem.

BASCOM-AVR : Currect handling og RAMPZ in ISR : REPLY

$
0
0
[quote:387e1bae3c="i.dobson"][code:1:387e1bae3c]00002842: B78B IN R24, $3B 00002844: 938F PUSH R24 00002846: 2788 EOR R24, R24 00002848: BF8B OUT $3B, R24[/code:1:387e1bae3c][/quote:387e1bae3c] An EOR on the same register clears it, an equivalent to a CLR. The shown code sets RAMPZ to zero for the ISR, the first page for LPM, or whatever intended use it will have.

BASCOM-AVR : Currect handling og RAMPZ in ISR : REPLY

$
0
0
Hi Mark, I didn't what to tread on any toes, sorry. "What the hell" ist just an english saying for "I don't understand whats going on here". I need to spend as little time as possible in the ISR, so just pushing/poping the required registers is the only way to go, and using objdump is the easiest way to see what registers are required. so EOR AA,AA = CLR AA (Clear register AA - Makes sense to me) Regards Ian Dobson

BASCOM-AVR : Currect handling og RAMPZ in ISR : REPLY

$
0
0
[quote:8ec405e6ba="i.dobson"]"What the hell" ist just an english saying for "I don't understand whats going on here".[/quote:8ec405e6ba] It can be used in different ways, but in a context like this, I'd say "what the hell" is more an expression like: "what is this f...g thing doing" "I don't understand whats going on here" is more a: "I have no clue". Maybe you have to work a bit on your English slang vocabulary. Here in the forum it's uncritical, but if you meet the real world, you may experience interesting results. [quote:8ec405e6ba]I need to spend as little time as possible in the ISR, so just pushing/poping the required registers is the only way to go, and using objdump is the easiest way to see what registers are required.[/quote:8ec405e6ba] An option would be to write the whole ISR in assembler, but as you didn't know the purpose of EOR, I'd say you'd still have some way to go. And it would help, if you download the AVR Instruction Set manual, under EOR you'll find then: [quote:8ec405e6ba]Example: eor r4,r4 ; Clear r4[/quote:8ec405e6ba]

BASCOM-AVR : Wakeup from powerdown : NEWTOPIC

$
0
0
How do i select rising edge interrupt for waking up from powerdown? It is the tiny1634 chip, i use the pcint0 interrupt (vector 3), GIMSK and PCMSK0 registers are set correct for using the pcint0, pcint1, pcint2 and pcint3 as external interrups trigger pins. I do select ISC0 and ISC1 bits in the MCUCR reg for rising edge, but interrupts seems to occur while level changes from lowhigh or highlow. Any good sugestions? [b:1a1f60bb5f][color=red:1a1f60bb5f](BASCOM-AVR version : 2.0.7.7 )[/b:1a1f60bb5f][/color:1a1f60bb5f]

BASCOM-AVR : Wakeup from powerdown : REPLY

$
0
0
[quote:5404beb705="2mhelges1"]How do i select rising edge interrupt for waking up from powerdown? [/quote:5404beb705] The data sheet is very clear about it. [quote:5404beb705]It is the tiny1634 chip, i use the pcint0 interrupt (vector 3), GIMSK and PCMSK0 registers are set correct for using the pcint0, pcint1, pcint2 and pcint3 as external interrups trigger pins. I do select ISC0 and ISC1 bits in the MCUCR reg for rising edge, but interrupts seems to occur while level changes from lowhigh or highlow. Any good sugestions?[/quote:5404beb705] If you'd have done everything right in your code, it would work as intended. As it does not, your code is likely wrong. As the code is likely wrong, it makes no sense to prosaically describe it. Much better would be, to post a minimized code sample, which shows the problem.

BASCOM-AVR : Wakeup from powerdown : REPLY

$
0
0
At PCINT interrupt you cannot choose rising or falling edge. Both cause the interrupt. [quote:04650dc97d] I do select ISC0 and ISC1 bits [/quote:04650dc97d]These bits are for external interrupt INT0. Set them for low level interrupt if you want to use INT0 for wake up.
Viewing all 20688 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>