In my controller, sensor addresses are stored in the EEPROM. Unfortunately, after a storm, when the power supply is interrupted, not for the first time, I have to learn it again. What is the way to protect data in the EEPROM. Wait for the stabilization of the voltage?
Thank you and have a nice day
[b:95295b34a4][color=red:95295b34a4](BASCOM-AVR version : 2.0.7.7 )[/b:95295b34a4][/color:95295b34a4]
↧
BASCOM-AVR : What is the way to protect data in EEPROM on bad power suppl : NEWTOPIC
↧
BASCOM-AVR : What is the way to protect data in EEPROM on bad power suppl : REPLY
[quote:e8ac9f4816="EDC"]What is the way to protect data in the EEPROM.[/quote:e8ac9f4816]
Depends whether EEProm data is only read or if it's written too. In the first case enable Brownout, it prevents the controller going crazy just before passing out.
In the second case a buffer capacity will help. Monitor the buffer via ADC and do only EEProm-writes, as enough capacity is left to finish the write process.
In case the complete circuit draws fluctuating amounts of current, and this way it can't be sure how long the buffer lasts, provide the controller with its own decoupled buffer capacity.
↧
↧
Share your working BASCOM-AVR code here : OLED Display using SSD1306 with i2c. Char Mode 16x4 : REPLY
Hello,
As you say, is a pure controller (SSD1306), in it there are no additional features (no fonts, word processing).
The Display is a UG-2864 0.96 / WN-096 (Up Display Board)
[img:45f7fe0710]http://i59.tinypic.com/ojqt5w.jpg[/img:45f7fe0710]
[code:1:45f7fe0710]
const OLED_Address = &H78
Const Write_cmd = &H80
Declare Sub INI_DISPLAY
Declare Sub Resetdisplay
Declare Sub WriteDisplay(byval Text As String * 10 , Byval Col As Integer , Byval Page As Integer
Rset Alias Portb.0 'PIN B0 Reset
Call ResetDisplay
Call INI_DISPLAY
Waitms 300
Do
Call WriteDisplay( "1 2 3 HELLO" , 8 , 4)
Loop
Sub WriteDisplay(byval Text As String * 10 , Byval Col As Integer , Byval Page As Integer)
Dim Word As String * 1
Dim Q As Integer
Dim H As Integer
Dim Temp As Integer
Dim Oled_Data As Byte
I2cstart
I2cwbyte Oled_address
I2cwbyte Page
I2cwbyte Col
For Q = 0 To 9
Temp = 0
Word = Mid(text , Q , 1)
Temp = Asc(word)
Temp = Temp - 32 'Space position
Temp = Temp * 9
For H = 0 To 9
Oled_Data = Lookup(temp , BIG_FONT)
I2cwbyte Oled_Data
Incr Temp
Next H
Next Q
I2cstop
End Sub
Sub INI_DISPLAY
i2cstart
i2cwbyte OLED_Address
i2cwbyte &HAE 'DISPLAY OFF
i2cwbyte &HD5 'SET DISPLAY CLOCKDIV
i2cwbyte &H80 'DISPLAY RATIO '80
i2cwbyte &H1F 'DISPLAY 1/32 DUTY
i2cwbyte &H20 'HORIZONTAL MODE 20
i2cwbyte &H00 'SET DISPLAY STARTLINE
i2cwbyte &H40 'DISPLAY START AT 0
i2cwbyte &HA1 'REMAP 0-127
'i2cwbyte &HA2 'Display up/Down A0 o Down A8
i2cwbyte &HC8 'SCAN DIRECTION C8 or C0
i2cwbyte &HDA 'COM PINS
i2cwbyte &H12 'COM PINS 10
i2cwbyte &HA4 ' DISPLAY ON
i2cwbyte &HA6 '$A6=NORMAL MODE;$A7=INVERSE MODE
i2cwbyte &HD9 'set precharge period D9
i2cwbyte &HF1 '$22 - External, $F1 - Internal
i2cwbyte &HDB 'vcomh deselect level
i2cwbyte &H20 'rtfm 20 o 40
i2cwbyte &H8D 'enable charge pump
i2cwbyte &H14 'at 14h = 20d
i2cwbyte &HAF ' DISPLAY ON
Waitms 50
i2cstop
End Sub
Sub Resetdisplay
Waitms 200
Set Rset 'Reset diplay
Waitms 1
Reset Rset
Waitms 10
Set Rset
Waitms 5
End Sub
---------------------------------------------------
BIG_FONT:
Data &H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00,&H00 ' space
Data &H30,&H78,&HCC,&HDC,&HEC,&HCC,&HCC,&H78,&H30,&H00 ' 0
Data &H18,&H38,&H78,&H18,&H18,&H18,&H18,&H18,&H7E,&H00 ' 1
Data &H7C,&HC6,&H06,&H0C,&H18,&H30,&H60,&HC2,&HFE,&H00 ' 2
Data &H7C,&HC6,&H06,&H06,&H3C,&H06,&H06,&HC6,&H7C,&H00 ' 3
Data &H0C,&H1C,&H3C,&H6C,&HCC,&HCC,&HFE,&H0C,&H0C,&H00 ' 4
Data &HFE,&HC0,&HC0,&HC0,&HFC,&H06,&H06,&HC6,&H7C,&H00 ' 5
Data &H3C,&H60,&HC0,&HC0,&HFC,&HC6,&HC6,&HC6,&H7C,&H00 ' 6
Data &HFE,&HC6,&H06,&H0C,&H18,&H30,&H60,&H60,&H60,&H00 ' 7
Data &H7C,&HC6,&HC6,&HC6,&H7C,&HC6,&HC6,&HC6,&H7C,&H00 ' 8
Data &H7C,&HC6,&HC6,&HC6,&H7E,&H06,&H06,&H0C,&H78,&H00 ' 9
Data &H10,&H38,&H6C,&HC6,&HC6,&HFE,&HC6,&HC6,&HC6,&H00 ' A
Data &HFC,&H66,&H66,&H66,&H7C,&H66,&H66,&H66,&HFC,&H00 ' B
Data &H3C,&H66,&HC2,&HC0,&HC0,&HC0,&HC2,&H66,&H3C,&H00 ' C
Data &HF8,&H6C,&H66,&H66,&H66,&H66,&H66,&H6C,&HF8,&H00 ' D
Data &HFE,&H66,&H62,&H68,&H78,&H68,&H62,&H66,&HFE,&H00 ' E
Data &HFE,&H66,&H62,&H68,&H78,&H68,&H60,&H60,&HF0,&H00 ' F
Data &H3C,&H66,&HC0,&HC0,&HDE,&HC6,&HC6,&H6E,&H3C,&H00 ' G
Data &HC6,&HC6,&HC6,&HC6,&HFE,&HC6,&HC6,&HC6,&HC6,&H00 ' H
Data &H78,&H30,&H30,&H30,&H30,&H30,&H30,&H30,&H78,&H00 ' I
Data &H1E,&H0C,&H0C,&H0C,&H0C,&H0C,&H0C,&HCC,&H78,&H00 ' J
Data &HE6,&H66,&H6C,&H6C,&H78,&H6C,&H6C,&H66,&HE6,&H00 ' K
Data &HF0,&H60,&H60,&H60,&H60,&H60,&H60,&H66,&HFE,&H00 ' M
Data &HC6,&HEE,&HFE,&HD6,&HD6,&HD6,&HC6,&HC6,&HC6,&H00 ' M
Data &HC6,&HC6,&HE6,&HF6,&HDE,&HCE,&HC6,&HC6,&HC6,&H00 ' N
Data &H7C,&HC6,&HC6,&HC6,&HC6,&HC6,&HC6,&HC6,&H7C,&H00 ' O
Data &HFC,&H66,&H66,&H66,&H7C,&H60,&H60,&H60,&HF0,&H00 ' P
Data &H7C,&HC6,&HC6,&HC6,&HC6,&HD6,&HDC,&HFC,&H6E,&H00 ' Q
Data &HFC,&H66,&H66,&H66,&H7C,&H78,&H6C,&H66,&HF6,&H00 ' R
Data &H7C,&HC6,&HE0,&H70,&H1C,&H06,&HC6,&HCC,&H7C,&H00 ' S
Data &HFE,&HB2,&H30,&H30,&H30,&H30,&H30,&H30,&H78,&H00 ' T
Data &HC6,&HC6,&HC6,&HC6,&HC6,&HC6,&HC6,&HC6,&H7C,&H00 ' U
Data &HC6,&HC6,&HC6,&HC6,&HC6,&HC6,&H6C,&H38,&H10,&H00 ' V
Data &HC6,&HC6,&HC6,&HD6,&HD6,&HD6,&HFE,&H6C,&H6C,&H00 ' W
Data &HC6,&HC6,&H6C,&H38,&H38,&H38,&H6C,&HC6,&HC6,&H00 ' X
Data &HC6,&HC6,&HC6,&H6C,&H38,&H30,&H30,&H30,&H78,&H00 ' Y
Data &HFE,&HC6,&H0C,&H18,&H30,&H60,&HC0,&HC6,&HFE,&H00 ' Z
Data &HE0,&H60,&H60,&H78,&H6C,&H66,&H66,&H66,&HDC,&H00 ' b
Data &H00,&H00,&H00,&H7C,&HC6,&HC0,&HC0,&HC6,&H7C,&H00 ' c
Data &H0E,&H0C,&H0C,&H3C,&H6C,&HCC,&HCC,&HCC,&H76,&H00 ' d
Data &H00,&H00,&H00,&H7C,&HC6,&HFC,&HC0,&HC6,&H7C,&H00 ' e
Data &H38,&H6C,&H64,&H60,&HF8,&H60,&H60,&H60,&HF0,&H00 ' f
Data &H00,&H00,&H00,&H76,&HCC,&HCC,&H7C,&H0C,&HCC,&H78 ' g
Data &HE0,&H60,&H60,&H6C,&H76,&H66,&H66,&H66,&HE6,&H00 ' h
Data &H18,&H18,&H00,&H38,&H18,&H18,&H18,&H18,&H3C,&H00 ' i
Data &H0C,&H0C,&H00,&H1C,&H0C,&H0C,&H0C,&H0C,&HCC,&H78 ' j
Data &HE0,&H60,&H60,&H66,&H6C,&H78,&H6C,&H66,&HE6,&H00 ' k
Data &H38,&H18,&H18,&H18,&H18,&H18,&H18,&H18,&H3C,&H00 ' l
Data &H00,&H00,&H00,&HDC,&HFE,&HD6,&HD6,&HD6,&HD6,&H00 ' m
Data &H00,&H00,&H00,&HDC,&H66,&H66,&H66,&H66,&H66,&H00 ' n
Data &H00,&H00,&H00,&H7C,&HC6,&HC6,&HC6,&HC6,&H7C,&H00 ' o
Data &H00,&H00,&H00,&HDC,&H66,&H66,&H7C,&H60,&H60,&HF0 ' p
Data &H00,&H00,&H00,&H76,&HCC,&HCC,&H7C,&H0C,&H0C,&H1E ' q
Data &H00,&H00,&H00,&HDC,&H76,&H66,&H60,&H60,&HF0,&H00 ' r
Data &H00,&H7C,&HC6,&H70,&H1C,&HC6,&H7C,&H00,&H00,&H00 ' s
Data &H10,&H30,&H30,&HFC,&H30,&H30,&H30,&H30,&H1C,&H00 ' t
Data &H00,&H00,&H00,&HCC,&HCC,&HCC,&HCC,&HCC,&H76,&H00 ' u
Data &H00,&H00,&H00,&HC6,&HC6,&HC6,&H6C,&H38,&H10,&H00 ' v
Data &H00,&H00,&H00,&HC6,&HC6,&HD6,&HD6,&HFE,&H6C,&H00 ' w
Data &H00,&H00,&H00,&HC6,&H6C,&H38,&H38,&H6C,&HC6,&H00 ' x
Data &H00,&H00,&H00,&HC6,&HC6,&HC6,&H7E,&H06,&H0C,&H78 ' y
Data &H00,&H00,&H00,&HFE,&HCC,&H18,&H30,&H66,&HFE,&H00 ' z
[/code:1:45f7fe0710]
THX.[/quote]
↧
BASCOM-AVR : What is the way to protect data in EEPROM on bad power suppl : REPLY
Thank You. I forgot that possibility. Nothing is written without user, but all strings are read from EEPROM and after storm one of them have letter "R" changed...
I set BODLEVEL and BODEN to zero and waiting for another storm :D
If this not help I try to re-design like You sugest.
Thank You
PS.In my spare time I build home-page. Yesterday I started working on coloring syntax highlighting Bascom. You can take a look. It's not PHP. This style and Java. If anyone knows a better way let me know. [url=http://bart-projects.cba.pl/sejf.html]Link[/url]
↧
Share your working BASCOM-AVR code here : OLED Display using SSD1306 with i2c. Char Mode 16x4 : REPLY
Hi.
There is a small bug in your code.
"1 2 3 HELLO" - 11 characters (not 10 - "String * 11").
The screen has a plurality of display modes of the graphics memory.
Coincidentally, just your algorithm become a horizontal orientation (instead of vertically).
I experimented with different input modes, and stopped at the nearest convenient.
You can also try them and see what kind of algorithm output will be more convenient. To do this, write a simple filling cycle of graphics memory (GDDRAM).
The cycle can also add a long delay in order to understand how the image is displayed.
↧
↧
Share your working BASCOM-AVR code here : OLED Display using SSD1306 with i2c. Char Mode 16x4 : REPLY
Hello friends
I have this type of display but it works in the[b:2cd5787f45] "spi"[/b:2cd5787f45] mode.
does anybody have a library or an example for this kind of display using the [b:2cd5787f45]"SPI"[/b:2cd5787f45] ?
thanks.
↧
BASCOM-AVR : Wakeup from powerdown : REPLY
Doing the edge detect in software will allow you to select either rising or falling edge, and because its much slower than the hardware edge detect, it much better ignores fast jitter on the hardware line.
Within the ISR, just read the level on the appropriate pin. If its high now, than you must have had a rising edge, so do whatever you want. If its low, you have had a falling edge, so ignore it, just exit from the ISR.
↧
Share your working BASCOM-AVR code here : OLED Display using SSD1306 with i2c. Char Mode 16x4 : REPLY
Hi,
As I change the graphic display mode, It's ok??.
I´ve changed:
[code:1:f1f2ab6bba]
'Set Memory Addressing Mode
'00b, Horizontal Addressing Mode
'01b, Vertical Addressing Mode
i2cwbyte &H20 'HORIZONTAL MODE 20
i2cwbyte &H01 'Vertical Addressing
[/code:1:f1f2ab6bba]
Butt nothing, nothing...
I don't understand, when I put 5x7 on the screen are correct and use the same code. (changing some parameters).
what sequence should I change in the code so that the characters go vertical?.
I´m sorry but did you mean, "I experimented with different input modes". I have tried many things changing the initialization code.
THX.
↧
BASCOM-AVR : What is the way to protect data in EEPROM on bad power suppl : REPLY
Nice to see your using (parts of) my code :D
I can't read Polish but your site looks cool, hope you guys in Poland have fun with RC2 Sound.
↧
↧
BASCOM-ARDUINO : Windows 8.1 Arduino en Bascom : NEWTOPIC
Geacht Forum, (English below)
Ik had problemen met de communicatie tussen Bascom en Arduino.
Nadat ik WINAVR had geinstalleerd werkte het wel.
Volgens Mark heeft dat er niets mee te maken, dus zou het zonder ook moeten werken.
Niet geschoten is zeker mis.
WINAVR kan je downloaden van http://sourceforge.net/projects/winavr/files/latest/download?source=files
Na installeren hoef je er niet meer naar om te kijken, wel even de PC opnieuw starten.
Suc6, groeten, Dré
=============---============
Dear forum,
I had problems with the communication between Arduino and Bascom.
After I installed WINAVR the problem was solved.
Mark says it has nothing to do with WINAVR, it has to work without it.
But in my case, it works now and I am happy.
If you like to try it, you can download from http://sourceforge.net/projects/winavr/files/latest/download?source=files
After installation, restart your PC and you have never to look at WINAVR again.
Greetings, Dré
↧
BASCOM-ARDUINO : Windows 8.1 Arduino en Bascom : REPLY
I use Windows 7 and Windows XP.
I only needed install AVRDUDE to work with Bascom, as told in the WIKI.
But I tried many programmers options, like ARDUINO, and it don't works. My only working solution was using AVRDUDE.
Paulo
↧
BASCOM-ARDUINO : Windows 8.1 Arduino en Bascom : REPLY
I am using windows 8 and the arduino mega2560 using just bascom ARDUINO STK500 V2
But I need a normal spi programmer to change fuses and eeprom
Regards Paul
↧
BASCOM-AVR Old versions : does makemodbus work with UART0? : NEWTOPIC
Hi
i'm testing makemodbus , but i think that doesn't work with uart0. i refer to bascom help. "[color=red:508f1e4abe]It can only be used with the hardware UART(1-4).[/color:508f1e4abe]"
so we have to use from AVR chips that have more than one uart , is it right?
↧
↧
BASCOM-AVR Old versions : does makemodbus work with UART0? : REPLY
yes it works. the fist AVR chips had 1 uart. And they were named uart. no uart0 or uart1.
When adding more uarts the second was named uart1. Later on, the first uart was named uart0.
But ... the OPEN statement uses COM1. This to make it similar to the PC naming since OPEN was copied from the PC/QB, where devices start with number 1.
↧
BASCOM-AVR Old versions : does makemodbus work with UART0? : REPLY
oooohhh... :lol:
thanks albertsm. full answer.
Best Regards
↧
BASCOM-AVR : Serial communication isr : NEWTOPIC
Hello,
Expected receive serial port 9 bytes like this
123 45 24 16 56 214 251 147 56 = 9 bytes 22 char
123 45 24 1 56 214 251 147 56 = 9 bytes 21 char
123 45 24 1 56 214 251 147 5 = 9 bytes 20 char
On Urxc Rec_isr 'define serial receive ISR
Enable Urxc 'enable receive isr
const cmaxchar = 21 ??????
Rec_isr:
D = Udr 'read UDR only once i think 1 char
D = inkey 'what we receive, a byte or just one char?????
If Bc < Cmaxchar Then 'does it fit into the buffer?
Incr Bc 'increase buffer counter
If D = 13 Then 'return?
Buf = Buf + Chr(0)
Bc = Cmaxchar 'at the end
Else
Buf = Buf + Chr(d) 'add to buffer
End If
End If
B = 1 'set flag
Return
How to modify the isr to indentify and get the 9 bytes to a byte array?
I not want use Ischarwaiting and Inputbin
Can i use this way in the Rec_isr to get everytime one byte with inkey, with d = inkey
Tahnks in advance
Best regards
toto
[b:43a3bc8e60][color=red:43a3bc8e60](BASCOM-AVR version : 2.0.7.7 )[/b:43a3bc8e60][/color:43a3bc8e60]
↧
BASCOM-AVR : TWI slave address as variable? : NEWTOPIC
Hello dear reader,
I'm using the following line to define the parameters of an M8-slave.
Config Twislave = &H78 , Btr = 4 , Bitrate = 100000
My question: Is it possible to define the slave-address &H78 by using a variable or a port value.
I have several units which only differ in their slave-address. I would like to use dip-switches to assign an individual address on each unit.
Thank you
Ernst
[b:029fc87f1c][color=red:029fc87f1c](BASCOM-AVR version : 2.0.7.7 )[/b:029fc87f1c][/color:029fc87f1c]
↧
↧
BASCOM-AVR : TWI slave address as variable? : REPLY
no you can not but you can simply re-assign the slave address writing to the TWAR register just after the config.
Only take in mind that the LS bit is used to set the general call address option.
↧
BASCOM-AVR : TWI slave address as variable? : REPLY
Thank you very much Mark for your prompt response.
Best regards
Ernst
↧
BASCOM-AVR : Serial communication isr : REPLY
Hi,
I'm using the following code to grab a RFID number from the Serial port. The Serial communications consist of:
First character 2 (dec)
Next 10 charcters RFID number
Next character checksum
Next character end of message character
Note the RFID_array is at the same address as the rfid_string so writing to rfid_arry changes rfid_string as well- You just Need to make sure that the end of string character (0) is at the end of the string.
[code:1:79bcbaa094]
Dim Rfid_ptr As Byte 'RFID input pointer
Dim Rfid_have_buffer As Byte 'RFID data ready for decode
Dim Rfid_char As Byte 'Char from RFID
Dim Rfid_array(15) As Byte 'RFID checksum array
Dim Rfid_string As String * 12 At Rfid_array(1) + 1 Overlay 'String RFID Nr.
Serial_isr:
Rfid_char = Inkey(#1)
If Rfid_char = 2 Then 'Chr 2 - Start of MSG
Rfid_ptr = 0 'Reset pointer
End If
Incr Rfid_ptr 'Move to next byte
Rfid_array(rfid_ptr) = Rfid_char 'Save char to array
If Rfid_ptr = 13 Then 'and correct length
Rfid_have_buffer = 1 'tell user space
Rfid_ptr = 0 'Reset buffer
End If
return
[/code:1:79bcbaa094]
Regards
Ian Dobson
↧