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

BASCOM-AVR : I2C slave and master in same chip..? : REPLY

$
0
0
Hear's a flow chart of what I'm trying to achieve: https://docs.google.com/drawings/d/1g25R5pE16PzQ5hEtEEzt6WsKWrP2If-9o0Dfz93cs_g/edit?pli=1 I've spent the better part of 3 days testing and trying to figure out if it's something in the i2c libs that are conflicting. But I haven't been able to figure it out :-( In Atmels AVR311 and AVR315 application notes, that covers their Master and Slave drivers in C, it says: "The master and slave drivers could be merged to one combined master and slave driver." But I haven't found any examples of how that is done :-( Any ideas on how to get this to work would be much appreciated...

BASCOM-AVR : mega128A and 2x16 LCD : REPLY

$
0
0
Ok, Did did switch from the previous fuse setting to another, and the external crystal is now working with the LCD. I then proceeded to kick it up to 14745600 Mhz, it's intended operating Mhz setting at 115200 baud rate. It's working very nicely. So we can chalk this one up to my inability to select the proper fuse setting :( Thanks for the help guys, Robert

BASCOM-AVR : Using SPI on 3.5 display with FTDI FT800 controller. : REPLY

$
0
0
Larry I am in the process of doing the same with Bascom but a little later on. I have spent quite a bit of time porting over FT800_SampleApp_1.0.c to PowerBasic using FTDI's MPSSE interface cable running SPI on the PC and comunicating to a FTDI 5" VM800 LCD. It's a long way around doing it like this but I wanted to learn to do SPI on the PC and I thought is was easier to learn and debug code on the PC before going to a Micro. (still learning how to drive it!) There are a few very nice demos going around displaying the amazing things you can do with the FT800, search on the net for GameDuino2 and a youtube demo of LuanAVR FT800 demo to get a feel of the features (also FTDI have some demos). I will try and have a play with your code and see if I can do anything.

BASCOM-AVR : (Need Help) : How to configure DS3231 RTC with AVR8535? : NEWTOPIC

$
0
0
Dear all... I'm trying to configure DS3231 RTC by simply connect the pins as i have done with DS1307. But the uC haven't work correctly yet. Is there any solution for this problem? I prefer DS3231 because i want to use alarm function next time. The uC will sleep when not active and alarm will wake up the uC on the right date, so i can prolonged lifetime of battery for PSU Thanks for your help [code:1:fe552161fa] ' '====================RTC CLOCK NO ALARM===================== 'By : CahDeso 'avrprojects2014 '=========================================================== $regfile = "m8535.dat" $crystal = 11059200 'LCD Kontrol------------------------------------------------- Config Lcdpin = Pin , Db4 = Portc.5 , Db5 = Portc.4 , Db6 = Portc.3 , Db7 = Portc.2 , E = Portc.6 , Rs = Portc.7 Config Lcd = 16 * 2 'Port C as output for LCD Initlcd Cursor Off Cursor Noblink 'Dimensi variabel-------------------------------------------- Dim _sec As Byte Dim _min As Byte Dim _hour As Byte Dim _weekday As Byte Dim _day As Byte Dim _month As Byte Dim _year As Byte Dim A As Byte Dim B As Long Dim Sa(3) As String * 2 Dim Sb(3) As String * 2 Dim Sc(3) As String * 2 Dim Sd(3) As String * 2 Dim I As Byte 'I2C Control------------------------------------------------- Config Sda = Portc.1 'Pin C.1 sebagai Sda Config Scl = Portc.0 'Pin C.0 sebagai Scl Const Ds1307w = &HD0 'Address of Ds1307 clock (write) Const Ds1307r = &HD1 'Address of Ds1307 clock (read) 'Deklarasi Sub Rutin----------------------------------------- Declare Sub Getdatetime() Declare Sub Settime() Declare Sub Getsec() Declare Sub Disptime() Declare Sub Dispdate() Declare Sub Format_00() Declare Sub Format_01() Declare Sub Setdate() Declare Sub Subset() Declare Sub Ukur() 'RTC Setting-------------------------------------------- _sec = 0 _hour = 17 _min = 14 Call Settime() _day = 2 _month = 2 _year = 14 Call Setdate() '======================= MAIN PROGRAM ======================= '============================================================ Do 'Lakukan perulangan Cls Call Getdatetime() 'ambil data waktu dan tanggal Upperline Call Dispdate() 'Tampilkan tanggal di baris 1 Lowerline Call Disptime() 'Tampilkan jam di baris 2 Waitms 100 Loop '======================= MAIN PROGRAM ======================= '============================================================ 'Sub Rutin ambil data waktu dan tanggal---------------------- Sub Getdatetime() I2cstart ' Generate start code I2cwbyte Ds1307w ' send address I2cwbyte 0 ' starting address in 1307 I2cstart ' Generate start code I2cwbyte Ds1307r ' send address I2crbyte _sec , Ack ' Seconds I2crbyte _min , Ack ' Minutes I2crbyte _hour , Ack ' Hours I2crbyte _weekday , Ack ' Day names I2crbyte _day , Ack ' Day of Month I2crbyte _month , Ack ' Month of Year I2crbyte _year , Nack ' Year I2cstop _sec = Makedec(_sec) : _min = Makedec(_min) : _hour = Makedec(_hour) _day = Makedec(_day) : _month = Makedec(_month) : _year = Makedec(_year) End Sub 'Sub Rutin setting waktu-------------------------------------- Sub Settime() _sec = Makebcd(_sec) : _min = Makebcd(_min) : _hour = Makebcd(_hour) I2cstart ' Generate start code I2cwbyte Ds1307w ' send address I2cwbyte 0 ' starting address in 1307 I2cwbyte _sec ' Send Data to SECONDS I2cwbyte _min ' MINUTES I2cwbyte _hour ' HOURS I2cstop End Sub 'Sub Rutin setting tanggal------------------------------------ Sub Setdate() _day = Makebcd(_day) : _month = Makebcd(_month) : _year = Makebcd(_year) I2cstart ' Generate start code I2cwbyte Ds1307w ' send address I2cwbyte 4 ' starting address in 1307 I2cwbyte _day ' Send Data to DAYS I2cwbyte _month ' MONTHS I2cwbyte _year ' YEARS I2cstop End Sub 'Sub Rutin tampilkan tanggal--------------------------------- Sub Dispdate() Sa(1) = Str(_day) Sa(2) = Str(_month) Sa(3) = Str(_year) Call Format_01() 'Panggil Sub Rutin Format 2 digit Lcd "Date: " ; Sb(1) ; "-" ; Sb(2) ; "-" ; Sb(3) End Sub 'Sub Rutin tampilkan waktu----------------------------------- Sub Disptime() Sc(1) = Str(_hour) Sc(2) = Str(_min) Sc(3) = Str(_sec) Call Format_00() 'Panggil Sub Rutin Format 2 digit Lcd "Time: " ; Sd(1) ; ":" ; Sd(2) ; ":" ; Sd(3) End Sub 'Sub Rutin format 2 digit------------------------------------ Sub Format_00() For I = 1 To 3 'Step 1 Sd(i) = Format(sc(i) , "00") Next I End Sub Sub Format_01() For I = 1 To 3 Step 1 Sb(i) = Format(sa(i) , "00") Next I End Sub[/code:1:fe552161fa] [b:fe552161fa][color=red:fe552161fa](BASCOM-AVR version : 1.11.9.0 , Latest : 2.0.7.7 )[/b:fe552161fa][/color:fe552161fa]

BASCOM-AVR : Problem with serial data transfer : NEWTOPIC

$
0
0
Hi , I made a circuit with a ATMega8 to measure temperatur and oxygen , then I show the data on a lcd , this works . Now I want to send the data via serial uart to an other ATMega8 and show the data then on a lcd . The LCD shows the comments but then data's are scrap . Does someone see my mistake ? I found some post about serial receiving but I do not understand them . Transmit unit [code:1:2a4ae4de13] ' $sim ' Auskommentieren für das echte Programm $regfile = "m8def.dat" $crystal = 1000000 $hwstack = 32 $swstack = 32 $framesize = 40 $Baud = 4800 Config Watchdog = 2048 Start Watchdog 'config input / output Ddrc = &B11000000 Ddrb = &B00000110 Config Portd.6 = Input Config Portd.7 = Input Jumper1 Alias Pind.6 Jumper2 Alias Pind.7 Taster2 Alias Pinc.2 Taster3 Alias Pinc.3 Taster4 Alias Pinc.4 Taster5 Alias Pinc.5 'Pullup Portd.7 = 1 Portd.6 = 1 Portc.2 = 1 Portc.3 = 1 Portc.4 = 1 Portc.5 = 1 Config Adc = Single , Prescaler = Auto , Reference = Internal Dim X As Word , Unt As Byte , Ob As Byte , Y As Word Dim Temp As Byte Dim Ee_unt As Eram Byte , Ee_ob As Eram Byte Dim Xstr as String * 4 , Ystr as String * 4 Unt = Ee_unt Ob = Ee_ob Start Adc Do ' Anzeige Abgastemperatur Y = Getadc(1) Waitms 100 ' Normalbetrieb Sauerstoffmessung X = Getadc(0) X = X / 4 If X < Unt Then Portb.2 = 1 Else Portb.2 = 0 End If If X < Ob Then Portb.1 = 1 Else Portb.1 = 0 End If 'Übergabe an serielles Display Ystr = STR(Y) Xstr = STR(X) Ystr = Format(Ystr , "000") Xstr = Format(Xstr , "00,0") Print Y ,"............." ,X 'enter setup Sauerstoffgrenzwert If Jumper1 = 0 Then Locate 1 , 1 Lcd "Schaltpkt1=" ; Unt ; " " Locate 2 , 1 Lcd "Schaltpkt2=" ; Ob ; " " Do Reset Watchdog 'Taster Schaltpunkt 1 aufwärts If Taster2 = 0 Then Waitms 30 Unt = Unt + 1 Waitms 100 End If If Unt > 150 Then Unt = 150 'Taster Schaltpunkt 1 abwärts If Taster3 = 0 Then Waitms 30 Unt = Unt - 1 Waitms 100 End If If Unt < 1 Then Unt = 1 'Taster Schaltpunkt 2 aufwärts If Taster4 = 0 Then Waitms 30 Ob = Ob + 1 Waitms 100 End If If Ob > 150 Then Ob = 150 'Taster Schaltpunkt2 abwärts If Taster5 = 0 Then Waitms 30 Ob = Ob - 1 Waitms 100 End If If Ob < 1 Then Ob = 1 Print Ob ,"........" , Unt Waitms 100 ' exit setup and save to eeprom Loop Until Jumper1 = 1 Ee_unt = Unt Ee_ob = Ob End If Reset Watchdog ' Ende Einstellung Sauerstoffgrenzwert ' ************************************ Loop End [/code:1:2a4ae4de13] Receiving unit [code:1:2a4ae4de13] ' $sim ' Auskommentieren für das echte Programm $regfile = "m8def.dat" $crystal = 1000000 $hwstack = 32 $swstack = 32 $framesize = 40 $Baud = 4800 Config Watchdog = 2048 Start Watchdog On URXC OnRxD Enable URXC Enable Interrupts DDRB = &B11111111 DDRC = &B11111110 DDRD = &B11111111 Config Lcdpin = Pin , Rs = PortC.3 , E = PortC.1 , Db4 = PortB.5 , Db5 = PortB.4 , Db6 = PortB.3 , Db7 = PortB.2 Config Lcd = 20 * 4 Cursor Off Noblink Dim Wert as String * 20 Dim Neustart as Byte Locate 1,1 LCD "ANZEIGE ABGASWERTE" Waitms 1000 CLS Do Locate 1,1 Lcd "ABGAS- SAUER-" Locate 2,1 Lcd "TEMPERATUR STOFF" Locate 4,1 Lcd "GRAD PROZENT" Locate 3,1 If Len(Wert) > 19 Then Lcd Wert End If Neustart = Neustart + 1 If Neustart > 10 Then Goto Neustarten End If Reset Watchdog Neustarten: Waitms 1000 Loop OnRxD: Wert = Wert + Chr(UDR) Return End [/code:1:2a4ae4de13] Many thanks for every answer Hans [b:2a4ae4de13][color=red:2a4ae4de13](BASCOM-AVR version : 2.0.7.7 )[/b:2a4ae4de13][/color:2a4ae4de13]

BASCOM-AVR : I2C slave and master in same chip..? : REPLY

$
0
0
if you switch from slave to master twi, you need to enable the interrupts : twcr.0=1 and if you switch from slave to master you can best disable interrupts with twcr.0=0 that should make it work.

Share your working BASCOM-AVR code here : MCP4361 digital potentiometer with SPI : REPLY

$
0
0
thank you for sharing your code.

BASCOM-8051 : Automatic covertion to ASCII problem : REPLY

$
0
0
you say on PC but you mean the terminal emulator? when you enter a key on the keyboard of your PC, how will it end up at the micro? you use some serial connection ? in that case this would work : dim x as byte, s as string * 3 do x=waitkey() s=s + chr(x) if len(s)=3 then x=val(s) 'now the value is stored in byte value into x print "got " ; x s="" ' reset for next time end if loop

BASCOM-AVR : Problem with serial data transfer : REPLY

$
0
0
Print Y ,"............." ,X [code:1:223d9438b4]use Print Y ; "............." ;X ; the last ; for suppressing chr(13) + chr(10) [/code:1:223d9438b4]

BASCOM-AVR : Problem with serial data transfer : REPLY

$
0
0
you should add some synchronization as well. print "#";"............." ;X In the receiver : b=udr ' read value if b="#" then 'sync wert="" else wert=wert+ chr(b) end if b is a byte which is needed since once you read UDR you can not read it again without being sure it has the same value.

Share your working BASCOM-AVR code here : Fast library for ILI9325 LCD : REPLY

$
0
0
Great work, that you for sharing and the demo videos. Also thanks to Mr. Hkipnik's. A lot of display code lately, it is hard to keep up :-)

BASCOM-AVR : printbin array length of a variable? : NEWTOPIC

$
0
0
I am trying to run this code: Print "Reading: " ; Peersize Temp = Udpread(idx , S(1) , Peersize) ' read the result Printbin S(1) ; Peersize Given a correct size byte, peersize, it still prints the entire array. any ideas? [b:6145b59369][color=red:6145b59369](BASCOM-AVR version : 2.0.7.7 )[/b:6145b59369][/color:6145b59369]

BASCOM-AVR : printbin array length of a variable? : REPLY

$
0
0
printbin does not accept a variable to specify the amount of bytes to print. it accepts only an optional constant. this reason is that otherwise the compiler would just dump the content of this variable as well.

Share your working BASCOM-AVR code here : Fast library for SSD1289 LCD : NEWTOPIC

$
0
0
Library for [b:4b719c2e6e]SSD1289[/b:4b719c2e6e] LCD with [b:4b719c2e6e]16-bit interface[/b:4b719c2e6e]: [URL=http://radikal.ru/fp/95d7db75430647eba408521cb8271f9f][img:4b719c2e6e]http://s020.radikal.ru/i714/1402/5b/5bbf92a2cdc6t.jpg[/img:4b719c2e6e][/URL] LCD is 3/5V compliant. Library works in [b:4b719c2e6e]Submode = New[/b:4b719c2e6e], so its very easy to include in project and unused Subs are not compiled to save memory space. Also to save space you may use reduced Fonts, like Font36x56 in example. It has only digits, placed at position 33...42. To correct this shift simply use Digit_font = 1. Any Fons may be included via $[b:4b719c2e6e]include[/b:4b719c2e6e]. Supports both types of BASCOM Fonts - "[b:4b719c2e6e]Color[/b:4b719c2e6e]" and "[b:4b719c2e6e]B&W[/b:4b719c2e6e]". You can display 8-bit (BGC) and 16 bit (BIN) pictures. Also 16 bit pictures can be loaded from SPI-Flash ROM. To prepare bin-file from [b:4b719c2e6e]bmp, gif, jpg, wmf, emf, ico [/b:4b719c2e6e]I wrote special program [b:4b719c2e6e]Pic2Bin[/b:4b719c2e6e]. Library is fast. I specially made it to work quickly. In this video test program working at 8MHz. Video : http://youtu.be/90Mshgb6I3U Based on Mr.Hkipnik's sources.

BASCOM-AVR : printbin array length of a variable? : REPLY

$
0
0
Ouch. rather limiting..... Why cant we add a new printbin operator to the compiler, to indicate we are passing a variable as a size? like a colon to indicate the variable as a size, while the semi-colon is used for a number as a size currently.

BASCOM-AVR : AtTiny85 as I2C slave : REPLY

$
0
0
yes xmega, attiny(USI) are also supported in 2077. you also need to update the i2c slave add on package. download it from register.mcselec.com

Share your working BASCOM-AVR code here : Fast library for SSD1289 LCD : REPLY

$
0
0
that is what i meant, can't keep up with all these displays :-) But seriously : great work ! thank you for sharing. I know it is a lot of work to write and test as i am writing a driver too at the moment.

BASCOM-AVR : Using SPI on 3.5 display with FTDI FT800 controller. : REPLY

$
0
0
Thanks Peter for the reply and suggestions. I have sent an E-mail to FTDICHIP asking for a list of Hex commands to use with spiout. Regards Larry

Share your working BASCOM-AVR code here : Fast library for SSD1963 LCD : NEWTOPIC

$
0
0
Library for [b:89c4d2fadd]SSD1963[/b:89c4d2fadd] LCD with [b:89c4d2fadd]16-bit interface[/b:89c4d2fadd]: [URL=http://radikal.ru/fp/75e0a8c50ec14920ae779f9c49b98edb][img:89c4d2fadd]http://s018.radikal.ru/i516/1402/f6/889feb9d6c11t.jpg[/img:89c4d2fadd][/URL] LCD is 3/5V compliant. Library works in [b:89c4d2fadd]Submode = New[/b:89c4d2fadd], so its very easy to include in project and unused Subs are not compiled to save memory space. Also to save space you may use reduced Fonts, like Font36x56 in example. It has only digits, placed at position 33...42. To correct this shift simply use Digit_font = 1. Any Fons may be included via [b:89c4d2fadd]$include[/b:89c4d2fadd]. Supports both types of BASCOM Fonts - "[b:89c4d2fadd]Color[/b:89c4d2fadd]" and "[b:89c4d2fadd]B&W[/b:89c4d2fadd]". You can display 8-bit (BGC) and 16 bit (BIN) pictures. Also 16 bit pictures can be loaded from SPI-Flash ROM. To prepare bin-file from [b:89c4d2fadd]bmp, gif, jpg, wmf, emf, ico[/b:89c4d2fadd] I wrote special program [b:89c4d2fadd]Pic2Bin[/b:89c4d2fadd]. Library is fast. I specially made it to work quickly. In this video test program working at 8MHz. However, display resolution is [b:89c4d2fadd]800x480[/b:89c4d2fadd] and its better to use 16MHz or 32MHz (Atxmega). Video - http://youtu.be/U9kgDOa79MY Based on Mr.Six1 sources.

BASCOM-AVR : Using SPI on 3.5 display with FTDI FT800 controller. : REPLY

$
0
0
Larry They are all in the FTDI's Software Examples. Here is a file which has most of the stuff you need but its in PowerBasic, just change some of the '%' to 'Const'. It's a real pain to try and convert some of this C/C++ over to Bascom (though I dislike C/C++). I am just havng a look at your example code now.
Viewing all 20625 articles
Browse latest View live


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