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

BASCOM-AVR : How to turn my code into a sub routine/function : NEWTOPIC

$
0
0
Hi could someone please explain how a subroutine or function works. My teacher told me to change the repetitive codes ie. If Hours < 10 Then Locate 1 , 1 Lcd "0" Locate 1 , 2 Lcd Hours Else Locate 1 , 1 Lcd Hours End If into a subroutine. I have tried reading the help on Bascom but don't get anything lol. Thanks very much if you can help me write up a function. :D 'SETUP for the ports $crystal = 1000000 'sets the frequency of the M/P $regfile = "m48def.dat" 'tells BASCOM which M/P I am using Config Portd = Output 'Outputs for the ports D Config Portb = Output 'Outputs for the ports B Config Pinb.7 = Input 'Set inputs for switch 1 Config Pinb.0 = Input Config Pinc.0 = Input 'Sets inputs for Lm35 '*************************************************************************************************** 'Config for LCD Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portb.1 , Rs = Portb.6 Config Lcd = 16 * 2 Set Portd.5 'sets backlight Piezo Alias Portd.7 'Sets another name for PORTD.7 to be called Piezo Cls Cursor Off Config Adc = Single , Prescaler = Auto , Reference = Internal_1.1 'Configs the analogue to digital converter with a reference to as internal_1.1 as it is more accurate. Start Adc 'Starts the analogue to digital converter Dim Lm35 As Word 'Sets Lm35 as a variable Dim Templevel As Word 'Sets Templevel as a variable Deflcdchar 1 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32 ' replace [x] with number (0-7) Dim Alarm As Byte Dim Seconds As Integer Dim Minutes As Integer Dim Hours As Integer '*************************************************************************************************** 'Config for time Hours = 20 Minutes = 39 '*************************************************************************************************** Do '*************************************************************************************************** 'Config for Alarm 'If Hours = 0 And Minutes = 0 And Seconds = 5 Then '*************************************************************************************************** Locate 2 , 13 'locating position Gosub Read_lm35 'temperature routine If Hours < 10 Then Locate 1 , 1 Lcd "0" Locate 1 , 2 Lcd Hours Else Locate 1 , 1 Lcd Hours End If If Minutes < 10 Then Locate 1 , 4 Lcd "0" Locate 1 , 5 Lcd Minutes Else Locate 1 , 4 Lcd Minutes End If If Seconds < 10 Then Locate 1 , 7 Lcd "0" Locate 1 , 8 Lcd Seconds Else Locate 1 , 7 Lcd Seconds End If Locate 1 , 3 Lcd ":" Locate 1 , 6 Lcd ":" Seconds = Seconds + 1 Wait 1 If Seconds = 60 Then Minutes = Minutes + 1 Seconds = 0 End If If Minutes = 60 Then Hours = Hours + 1 Minutes = 0 End If If Hours = 24 Then Hours = 0 End If Loop End Read_lm35: 'Temperature routine Lm35 = Getadc(0) 'Gets the value from the Analogue to Digital converter on port C.0 Templevel = Lm35 / 9.3 ' Sets the templevel by dividing the ADC value by 9.3 which is the ratio between the Internal_1.1 reference and lm35 Lcd Templevel ; Chr(1) ; "C" 'Displays the converted temp Return 'Sub routine finished, back to Do [b:3f6077c678][color=red:3f6077c678](BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.8 )[/b:3f6077c678][/color:3f6077c678]

BASCOM-AVR : How to turn my code into a sub routine/function : REPLY

$
0
0
Hi Zefty I've done some mods for you to follow, I haven't done all of them but from the mods you can see how it works and change the rest. You can also chech whats going on in the simulator. Decalre sub 3 x Subs Doo Loop [code:1:4aa32684e1] 'SETUP for the ports $crystal = 1000000 'sets the frequency of the M/P $regfile = "m48def.dat" 'tells BASCOM which M/P I am using Config Portd = Output 'Outputs for the ports D Config Portb = Output 'Outputs for the ports B Config Pinb.7 = Input 'Set inputs for switch 1 Config Pinb.0 = Input Config Pinc.0 = Input 'Sets inputs for Lm35 $hwstack = 100 $swstack = 100 $framesize = 100 '*************************************************************************************************** 'Config for LCD Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portb.1 , Rs = Portb.6 Config Lcd = 16 * 2 'Subs defined like this Declare Sub Do_hours() '<<<<<<<<<<<ADDED<<<<<<<<<<<<<<<<<<< Declare Sub Do_minutes() '<<<<<<<<<<<ADDED<<<<<<<<<<<<<<<<<<< Declare Sub Lm35_read() '<<<<<<<<<<<ADDED<<<<<<<<<<<<<<<<<<< Set Portd.5 'sets backlight Piezo Alias Portd.7 'Sets another name for PORTD.7 to be called Piezo Cls Cursor Off Config Adc = Single , Prescaler = Auto , Reference = Internal_1.1 'Configs the analogue to digital converter with a reference to as internal_1.1 as it is more accurate. Start Adc 'Starts the analogue to digital converter Dim Lm35 As Word 'Sets Lm35 as a variable Dim Templevel As Word 'Sets Templevel as a variable Deflcdchar 1 , 7 , 5 , 7 , 32 , 32 , 32 , 32 , 32 ' replace [x] with number (0-7) Dim Alarm As Byte Dim Seconds As Integer Dim Minutes As Integer Dim Hours As Integer '*************************************************************************************************** 'Config for time Hours = 20 Minutes = 39 '*************************************************************************************************** Do'<<<<<<<THis is the main loop and you only need to type in the name of the sub for it to call it." Call Subname" is another way. '*************************************************************************************************** 'Config for Alarm 'If Hours = 0 And Minutes = 0 And Seconds = 5 Then '*************************************************************************************************** Locate 2 , 13 'locating position Lm35_read 'temperature routine <<<<<<<<<<<<<<<<<<< MODIFIED<<<<<<<<<<<<<< Do_hours Do_minutes 'Or "call Do_minutes" Loop Sub Do_hours() 'Sub Start If Hours < 10 Then Locate 1 , 1 Lcd "0" Locate 1 , 2 Lcd Hours Else Locate 1 , 1 Lcd Hours End If End Sub 'Sub end Sub Do_minutes If Minutes < 10 Then Locate 1 , 4 Lcd "0" Locate 1 , 5 Lcd Minutes Else Locate 1 , 4 Lcd Minutes End If End Sub ' If Seconds < 10 Then ' Locate 1 , 7 ' Lcd "0" ' Locate 1 , 8 ' Lcd Seconds ' Else ' Locate 1 , 7 ' Lcd Seconds ' End If ' Locate 1 , 3 ' Lcd ":" ' Locate 1 , 6 ' Lcd ":" ' Seconds = Seconds + 1 ' Wait 1 ' If Seconds = 60 Then ' Minutes = Minutes + 1 ' Seconds = 0 ' End If ' If Minutes = 60 Then ' Hours = Hours + 1 ' Minutes = 0 ' End If ' If Hours = 24 Then ' Hours = 0 ' End If Sub Lm35_read() 'This sub could be done as a function since you could return a value Read_lm35: 'Temperature routine Lm35 = Getadc(0) 'Gets the value from the Analogue to Digital converter on port C.0 Templevel = Lm35 / 9.3 ' Sets the templevel by dividing the ADC value by 9.3 which is the ratio between the Internal_1.1 reference and lm35 Lcd Templevel ; Chr(1) ; "C" 'Displays the converted temp End Sub [/code:1:4aa32684e1]

BASCOM-AVR : Help with bootloader please... : REPLY

$
0
0
[quote:a21c5e4242="TSEYFARTH"]If anyone has any suggestions, I would really appreciate the feedback![/quote:a21c5e4242] Is this a modified bootloader? As often said and I may sound like a prayer mill: don't expect someone to find a bug in your code, without actually having your code, i.e. bootloader. :evil: [quote:a21c5e4242]The bootloader does work, it does accept the upload from the MCS bootloader windows application but the main app never starts. [/quote:a21c5e4242] If it would work, your application would run. How the reset is achieved? A jump to &h0000, or via watchdog timeout? Only a watchdog reset brings the µC into pristine condition, a jump to &h0000 leaves registers in the condition, as they were written by the bootloader. If you have written unclean code in your application, which relies on the µC to be in pristine condition, it may fail. A first test is to have the bootloader upload the application code and after uncheck BOOTRST. If your application works after re-powering, you have a reset issue, if it still does not work, the bootloader did not correctly load up the application code.

BASCOM-AVR : Help with bootloader please... : REPLY

$
0
0
Hi TSEYFARTH, One thing to check is: from MCS bootloader[code:1:198fa5e306]$baud = 128000 'this loader uses serial com 'It is VERY IMPORTANT that the baud rate matches the one of the boot loader 'do not try to use buffered com as we can not use interrupts[/code:1:198fa5e306] I use 128k baudrate and in the: [code:1:198fa5e306]#if Loaderchip = 1280 ' Mega1280 $loader = &HFC00 ' 1024 words Const Maxwordbit = 7 'Z7 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #endif[/code:1:198fa5e306] This is all for com1 and you have to use 128k baud in your code as well.

BASCOM-AVR : Help with bootloader please... : REPLY

$
0
0
Hi and thanks for the replies! The Baud rate is 9600, on COM2 as shown in the original post. The bootloader does talk to the Windows MCS bootloader app, both within the IDE and the stand alone. @MWS - [quote:5cb9b2849c]Is this a modified bootloader? [/quote:5cb9b2849c] It is modified to the extent that the M1281 was added, and the Baud rate was changed to 9600. I also tried 38400. Nothing else has been changed. The bootloader code replies to the MCS Bootloader IDE and standone with a completed successfully code. I have not been able to call the bootloader from within the application code, since the app code never seems to be launched. What I have done is using the AVRISPII: 1. Erase the chip 2. Set fuses for size and reset vector as shown in the original post 3. Program the compiled bootloader.hex app 4. Use either the MCS IDE Bootloader, or the MCS Standalone bootloader to communicate with the bootloader.hex code programmed on chip in step 3 above. 5. Power cycle the board. If LED indicators from the bootloader blink. App code never runs. **There are no bootloader errors** I will try your test procedure to see what that shows. BTW, the reset code from the bootloader, when it is completed receiving the data from the PC is [code:1:5cb9b2849c]Goto _reset ' start new program[/code:1:5cb9b2849c] This is the entire bootloader code: [code:1:5cb9b2849c] '---------------------------------------------------------------- ' (c) 1995-2013, MCS ' Bootloader.bas ' This sample demonstrates how you can write your own bootloader ' in BASCOM BASIC ' VERSION 2 of the BOOTLOADER. The waiting for the NAK is stretched ' further a bug was resolved for the M64/M128 that have a big page size '----------------------------------------------------------------- 'This sample will be extended to support other chips with bootloader 'The loader is supported from the IDE $hwstack = 40 $swstack = 40 $framesize = 40 '$crystal = 8000000 '$crystal = 16000000 $crystal = 20000000 '$crystal = 14745600 '$baud = 38400 'this loader uses serial com '$baud = 19200 $baud = 9600 'this loader uses serial com 'It is VERY IMPORTANT that the baud rate matches the one of the boot loader 'do not try to use buffered com as we can not use interrupts 'possible return codes of the PC bootloader.exe ' -6005 Cancel requested ' -6006 Fatal time out ' -6007 Unrecoverable event during protocol ' -6008 Too many errors during protocol ' -6009 Block sequence error in Xmodem ' -6016 Session aborted '$regfile = "m8def.dat" 'Const Loaderchip = 8 '$regfile = "m168def.dat" 'Const Loaderchip = 168 '$regfile = "m16def.dat" 'Const Loaderchip = 16 '$regfile = "m32def.dat" 'Const Loaderchip = 32 '$regfile = "m88def.dat" 'Const Loaderchip = 88 '$regfile = "m162def.dat" 'Const Loaderchip = 162 '$regfile = "m8515.dat" 'Const Loaderchip = 8515 '$regfile = "m128def.dat" 'Const Loaderchip = 128 '$regfile = "m64def.dat" 'Const Loaderchip = 64 '$regfile = "m2561def.dat" 'Const Loaderchip = 2561 '$regfile = "m2560def.dat" 'Const Loaderchip = 2560 '$regfile = "m329def.dat" 'Const Loaderchip = 329 '$regfile = "m324pdef.dat" 'Const Loaderchip = 324 '$regfile = "m644def.dat" '$regfile = "m644pdef.dat" 'Const Loaderchip = 644 $regfile = "m1284def.dat" Const Loaderchip = 1284 $regfile = "m1284pdef.dat" Const Loaderchip = 1284 #if Loaderchip = 88 'Mega88 $loader = $c00 'this address you can find in the datasheet 'the loader address is the same as the boot vector address Const Maxwordbit = 5 Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 168 'Mega168 $loader = $1c00 'this address you can find in the datasheet 'the loader address is the same as the boot vector address Const Maxwordbit = 6 Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 32 ' Mega32 $loader = $3c00 ' 1024 words Const Maxwordbit = 6 'Z6 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 8 ' Mega8 $loader = $c00 ' 1024 words Const Maxwordbit = 5 'Z5 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 161 ' Mega161 $loader = $1e00 ' 1024 words Const Maxwordbit = 6 'Z6 is maximum bit ' #elseif Loaderchip = 162 ' Mega162 $loader = $1c00 ' 1024 words Const Maxwordbit = 6 'Z6 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 8515 ' Mega8515 $loader = $c00 ' 1024 words Const Maxwordbit = 5 'Z6 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 Osccal = &HB3 ' the internal osc needed a new value #elseif Loaderchip = 64 ' Mega64 $loader = $7c00 ' 1024 words Const Maxwordbit = 7 'Z7 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 128 ' Mega128 $loader = &HFC00 ' 1024 words Const Maxwordbit = 7 'Z7 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 2561 ' Mega2561 $loader = &H1FC00 ' 1024 words Const Maxwordbit = 7 'Z7 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 2560 ' Mega2560 $loader = &H1FC00 ' 1024 words Const Maxwordbit = 7 'Z7 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 16 ' Mega16 $loader = $1c00 ' 1024 words Const Maxwordbit = 6 'Z6 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 329 ' Mega32 $loader = $3c00 ' 1024 words Const Maxwordbit = 6 'Z6 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 324 ' Mega32 $loader = $3c00 ' 1024 words Const Maxwordbit = 6 'Z6 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 644 ' Mega644P $loader = $7c00 ' 1024 words ' $loader = $7800 ' 1024 words Const Maxwordbit = 7 'Z7 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #elseif Loaderchip = 1284 ' Mega1284 $loader = $FC00 ' 1024 words Const Maxwordbit = 7 'Z7 is maximum bit ' Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 #endif Const Maxword =(2 ^ Maxwordbit) * 2 '128 Const Maxwordshift = Maxwordbit + 1 Const Cdebug = 0 ' leave this to 0 #if Cdebug Print Maxword Print Maxwordshift #endif 'Dim the used variables Dim Bstatus As Byte , Bretries As Byte , Bblock As Byte , Bblocklocal As Byte Dim Bcsum1 As Byte , Bcsum2 As Byte , Buf(128) As Byte , Csum As Byte Dim J As Byte , Spmcrval As Byte ' self program command byte value Dim Z As Long 'this is the Z pointer word Dim Vl As Byte , Vh As Byte ' these bytes are used for the data values Dim Wrd As Word , Page As Word 'these vars contain the page and word address Dim Bkind As Byte , Bstarted As Byte 'Mega 88 : 32 words, 128 pages Disable Interrupts 'we do not use ints 'Waitms 100 'wait 100 msec sec 'We start with receiving a file. The PC must send this binary file 'some constants used in serial com Const Nak = &H15 Const Ack = &H06 Const Can = &H18 'we use some leds as indication in this sample , you might want to remove it 'Config Pinb.2 = Output 'Portb.2 = 1 'the stk200 has inverted logic for the leds 'Config Pinb.3 = Output 'Portb.3 = 1 ' 'CONFIG PRINT0 = portd.2 Config Print0 = portd.2 , Mode = Set Config portd.2 = Output 'set the direction yourself $timeout = 400000 'we use a timeout '$timeout = 800000 'we use a timeout 'When you get LOADER errors during the upload, increase the timeout value 'for example at 16 Mhz, use 200000 Bretries = 5 'we try 5 times Testfor123: #if Cdebug Print "Try " ; Bretries Print "Wait" #endif Bstatus = Waitkey() 'wait for the loader to send a byte #if Cdebug Print "Got " #endif Print Chr(bstatus); If Bstatus = 123 Then 'did we received value 123 ? Bkind = 0 'normal flash loader Goto Loader Elseif Bstatus = 124 Then ' EEPROM Bkind = 1 ' EEPROM loader Goto Loader Elseif Bstatus <> 0 Then Decr Bretries If Bretries <> 0 Then Goto Testfor123 'we test again End If 'For J = 1 To 10 'this is a simple indication that we start the normal reset vector ' Toggle Portb.2 : Waitms 100 'Next #if Cdebug Print "RESET" #endif Goto _reset 'goto the normal reset vector at address 0 'this is the loader routine. It is a Xmodem-checksum reception routine Loader: #if Cdebug Print "Clear buffer" #endif Do Bstatus = Waitkey() Loop Until Bstatus = 0 ' For J = 1 To 3 'this is a simple indication that we start the normal reset vector ' Toggle Portb.2 : Waitms 50 ' Next If Bkind = 0 Then Spmcrval = 3 : Gosub Do_spm ' erase the first page Spmcrval = 17 : Gosub Do_spm ' re-enable page End If Bretries = 10 'number of retries Do Bblocklocal = 1 Bstarted = 0 ' we were not started yet Csum = 0 'checksum is 0 when we start Print Chr(nak); ' firt time send a nack Do Bstatus = Waitkey() 'wait for statuse byte Select Case Bstatus Case 1: ' start of heading, PC is ready to send Csum = 1 'checksum is 1 Bblock = Waitkey() : Csum = Csum + Bblock 'get block Bcsum1 = Waitkey() : Csum = Csum + Bcsum1 'get checksum first byte For J = 1 To 128 'get 128 bytes Buf(j) = Waitkey() : Csum = Csum + Buf(j) Next Bcsum2 = Waitkey() 'get second checksum byte If Bblocklocal = Bblock Then 'are the blocks the same? If Bcsum2 = Csum Then 'is the checksum the same? Gosub Writepage 'yes go write the page Print Chr(ack); 'acknowledge Incr Bblocklocal 'increase local block count Else 'no match so send nak Print Chr(nak); End If Else Print Chr(nak); 'blocks do not match End If Case 4: ' end of transmission , file is transmitted If Wrd > 0 And Bkind = 0 Then 'if there was something left in the page Wrd = 0 'Z pointer needs wrd to be 0 Spmcrval = 5 : Gosub Do_spm 'write page Spmcrval = 17 : Gosub Do_spm ' re-enable page End If ' Waitms 100 ' OPTIONAL REMARK THIS IF THE DTR SIGNAL ARRIVES TO EARLY Print Chr(ack); ' send ack and ready ' Portb.3 = 0 ' simple indication that we are finished and ok Waitms 20 Goto _reset ' start new program Case &H18: ' PC aborts transmission Goto _reset ' ready Case 123 : Exit Do 'was probably still in the buffer Case 124 : Exit Do Case Else Exit Do ' no valid data End Select Loop If Bretries > 0 Then 'attempte left? Waitms 1000 Decr Bretries 'decrease attempts Else Goto _reset 'reset chip End If Loop 'write one or more pages Writepage: If Bkind = 0 Then For J = 1 To 128 Step 2 'we write 2 bytes into a page Vl = Buf(j) : Vh = Buf(j + 1) 'get Low and High bytes lds r0, {vl} 'store them into r0 and r1 registers lds r1, {vh} Spmcrval = 1 : Gosub Do_spm 'write value into page at word address Wrd = Wrd + 2 ' word address increases with 2 because LS bit of Z is not used If Wrd = Maxword Then ' page is full Wrd = 0 'Z pointer needs wrd to be 0 Spmcrval = 5 : Gosub Do_spm 'write page Spmcrval = 17 : Gosub Do_spm ' re-enable page Page = Page + 1 'next page Spmcrval = 3 : Gosub Do_spm ' erase next page Spmcrval = 17 : Gosub Do_spm ' re-enable page End If Next Else 'eeprom For J = 1 To 128 Writeeeprom Buf(j) , Wrd Wrd = Wrd + 1 Next End If ' Toggle Portb.2 : Waitms 10 : Toggle Portb.2 'indication that we write Return Do_spm: Bitwait Spmcsr.0 , Reset ' check for previous SPM complete Bitwait Eecr.1 , Reset 'wait for eeprom Z = Page 'make equal to page Shift Z , Left , Maxwordshift 'shift to proper place Z = Z + Wrd 'add word lds r30,{Z} lds r31,{Z+1} #if _romsize > 65536 lds r24,{Z+2} sts rampz,r24 ' we need to set rampz also for the M128 #endif Spmcsr = Spmcrval 'assign register spm 'this is an asm instruction nop nop Return 'How you need to use this program: '1- compile this program '2- program into chip with sample elctronics programmer '3- select MCS Bootloader from programmers '4- compile a new program for example M88.bas '5- press F4 and reset your micro ' the program will now be uploaded into the chip with Xmodem Checksum ' you can write your own loader.too 'A stand alone command line loader is also available 'How to call the bootloader from your program without a reset ??? 'Do ' Print "test" ' Waitms 1000 ' If Inkey() = 27 Then ' Print "boot" ' Goto &H1C00 ' End If 'Loop 'The GOTO will do the work, you need to specify the correct bootloader address 'this is the same as the $LOADER statement. [/code:1:5cb9b2849c] Thanks again for your responses and help. Tim

BASCOM-AVR : OLED Charactor display interface : REPLY

$
0
0
Hello Revenue, I have the same problem with the same display. I also have the R/W pin tied low on my boards. It took quite a bit of time for the problem to manifest itself - 3 weeks. Did you find a solution? If so, can you share with me? Thank you, Tim

BASCOM-AVR : Help with bootloader please... : REPLY

$
0
0
MWS, [quote:1d679a8516]A first test is to have the bootloader upload the application code and after uncheck BOOTRST. If your application works after re-powering, you have a reset issue, if it still does not work, the bootloader did not correctly load up the application code.[/quote:1d679a8516] The application did NOT work following your proposed procedure. But again, the bootloader did not throw any errors either. Any other ideas? Thanks, Tim

BASCOM-AVR : Help with bootloader please... : REPLY

$
0
0
[quote:ab46e7bde0="TSEYFARTH"]It is modified to the extent that the M1281 was added, and the Baud rate was changed to 9600.[/quote:ab46e7bde0] Assumed only these two mods, I was not able to match any of the Bascom sample bootloader codes to your code. Where you did derive the modified code from? It would have been helpful, if you would have left a reference to the original code in the header.

BASCOM-AVR : Long and fast bit-shift register : NEWTOPIC

$
0
0
I´m trying to make 512-byte long shift register (4096 bits) to simply shift bits but all my attempts was without success: [code:1:e1a41c54b1] '1. dim var(4096) as bit 'and then shift bit to bit from end - bit array is not allowed '2. dim var as string*512 'and then shift var, right - string cannot be shifted '3. dim var(512) as byte 'and then in loop (indexed): shift var(512), right '- shift bits in byte var(512).7 = var(511).0 '- carry bit between bytes 'and so on for all remaining bytes - but this is too slow[/code:1:e1a41c54b1] Is possible to shift all 4096 bits under 1ms? Any ideas? [b:e1a41c54b1][color=red:e1a41c54b1](BASCOM-AVR version : 2.0.7.8 )[/b:e1a41c54b1][/color:e1a41c54b1]

BASCOM-AVR : Help with bootloader please... : REPLY

$
0
0
MWS, Agreed - it does not work... I got it from the samples. Maybe the problem lies with using COM2 instead of COM1. Will have another look. Thank you, Tim

BASCOM-AVR : 18B20 and 1284P troubles : NEWTOPIC

$
0
0
Hi, I design a board for temperatures measurements with a 1284P and 18B20 sensors. I get a big problem. I design the port C to connect sensors. But 18B20 does not work on PORT C. After many testing, and several hours, I found it work on PORT B. Any idea or tricks to use 1wire sensors on PORT C ??? Best regards Georges [b:335b3c933b][color=red:335b3c933b](BASCOM-AVR version : 2.0.7.8 )[/b:335b3c933b][/color:335b3c933b]

BASCOM-AVR : Help with bootloader please... : REPLY

$
0
0
[quote:4f903c88e4="TSEYFARTH"]Agreed - it does not work...[/quote:4f903c88e4] Sure enough. But one has to find the reason. Do you need this Com1/2? I'd do a restart, use a proven working bootloader sample and set it up for the 1281. For double checking: is the app working on the 1281, if flashed via ISP?

BASCOM-AVR : Help with bootloader please... : REPLY

$
0
0
I MWS, Yes, I need it to work on COM2. That is the com port that connects to the PC. The app works perfectly when programmed with an AVRMKII. The bootloader came from the MCS samples. Am reviewing it again. Tim

BASCOM-AVR : Help with bootloader please... : REPLY

$
0
0
Found it... I think. Your statement of [quote:093b4a4d5d] Disabling the BOOTRST fuse sets the bootloader out of bussiness, if the bootloader would have previously loaded a valid application into the flash, the application would have been started from the reset vector &h0000. As this does not work, the bootloader did not load a valid application. [/quote:093b4a4d5d] led me to look at that part of the bootloader app. The original had this: [code:1:093b4a4d5d] #if(loaderchip = 128) Or (loaderchip = 2561) lds r24,{Z+2} sts rampz,r24 ' we need to set rampz also for the M128 #endif [/code:1:093b4a4d5d] I changed it to this: [code:1:093b4a4d5d] #if(loaderchip = 128) Or (loaderchip = 2561) Or (loaderchip = 1281) lds r24,{Z+2} sts rampz,r24 ' we need to set rampz also for the M128 #endif [/code:1:093b4a4d5d] Now it works. :? I did also notice that the code in the Help did not have this part at all. Instead it has this: [code:1:093b4a4d5d] #if _romsize > 65536 lds r24,{Z+2} sts rampz,r24 ' we need to set rampz also for the M128 #endif [/code:1:093b4a4d5d] Maybe the help is even newer than the samples. If so, and the help code works, that would be better since it is more generic. Thoughts? Tim

BASCOM-AVR : Help with bootloader please... : REPLY

$
0
0
Also please look that Sample Code configure pins. [code:1:393e84a12e]'we use some leds as indication in this sample , you might want to remove it Tx_d_led Alias Porte.5 Config Tx_d_led = Output 'Input Set Tx_d_led 'Set = High Rx_d_led Alias Porte.4 Config Rx_d_led = Output 'Input Set Rx_d_led 'Set = High Config Print1 = Portd.6 , Mode = Set Coma_rts Alias Portd.6 'UART1 RTS Config Coma_rts = Output 'Input 'Set Coma_rts 'Set = High 'Coma_RTS = 0 [/code:1:393e84a12e] State of microcontroller AFTER BOOTLOADER IS NOT STATE AFTER RESET. So I must once use option "Init LCD".. It depends pins You use

BASCOM-AVR : Help with bootloader please... : REPLY

$
0
0
That's why I've asked for the origin of the bootloader, saw no sense of looking through the bootloader code, without knowing its origin. I'd say the latter block for setting RAMPZ is more universal, as it gets _romsize from the dat-file, so no extra inclusion of the chip in question is necessary.

BASCOM-AVR : 18B20 and 1284P troubles : REPLY

$
0
0
Disable JTag in the fusesettings. It's active by default.

BASCOM-AVR : Long and fast bit-shift register : REPLY

$
0
0
Use a circular buffer. Use two pointers, one for reading bytes and another for writing. The read bytes can be shifted out @ Clock/2 so 10Mhz or less, using SPI. 4096 bits can be shifted out within 409.6 us. It doesn't leave much room for other tasks, despite the fact that SPI does the hard work.

BASCOM-AVR Old versions : FM PLL Transmitter 88Mhz - 108Mhz, Using TSA5511 & Atmeg : REPLY

$
0
0
[quote:902c6b1487="kimmi"]Most FM transmitter use the RDVV 300mW schematic All you need is to connect SDA SCL (I2C) and +5V gnd from M16 to the transmitter board [url=http://bygselvhifi.dk/audio/fm-stereo-rds-transmitter/]here is a good link lot of info and pcb sch ect[/url][/quote:902c6b1487] Kimmi, Thanks for your link. Anyway, I founded below code over the an internet, this code is refer to the schematic could you please helping me out to convert or translate this code to Bascom AVR, using Atmega8 and IC Prescaler TSA5511. This code for IC PIC16F819 and SAA1057. Below are complete code : Thanks. Regards, Eban.

BASCOM-AVR : Long and fast bit-shift register : REPLY

$
0
0
What you want to do with it? If you want to control some hardware let spi doing it for you.
Viewing all 20696 articles
Browse latest View live


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