Hi Evert,
can you help me?
i trying use your application for loading firmware into cpu and appls again and again trying send 123 to cpu and uploading dont start. i use RS485 for uploading firmware. original MCS bootloaders working fine and also bootloader on picture.
i need make my custom communictation application for my home automation, because i need upload firmware into modules on home bus with addressable function. i don't need use application for comercial. only for private use.
can you help me. i need any source code for bootloader that will be work. ideal is VB6
this is code of my bootloader
[code:1:327ce73ae1]'----------------------------------------------------------------
' (c) 1995-2009, 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
$crystal = 11059200
'$crystal = 14745600
$baud = 38400 '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
#if 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
#endif
Const Maxword =(2 ^ Maxwordbit) * 2 '128
Const Maxwordshift = Maxwordbit + 1
Const Cdebug = 0 ' leave this to 0
'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 Portc.0 = Output
Pwrled Alias Portc.0
Set Pwrled
Config Portd.2 = Output
Serialdir Alias Portd.2
Reset Serialdir
'Setup for RS-485 Half-Duplex.
Config Print0 = Portd.2 , Mode = Set
$timeout = 200000 'we use a timeout
Bretries = 5 'we try 5 times
Testfor123:
Bstatus = Waitkey() 'wait for the loader to send a byte
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 20
'Print Bretries 'this is a simple indication that we start the normal reset vector
Toggle Pwrled : Waitms 100
Next
Goto _reset 'goto the normal reset vector at address 0
'this is the loader routine. It is a Xmodem-checksum reception routine
Loader:
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 Pwrled : 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
Bstarted = 0 ' we were not started yet
Csum = 0 'checksum is 0 when we start
Print Chr(nak);
Do
Bstatus = Waitkey() 'wait for statuse byte
Select Case Bstatus
Case 1: ' start of heading, PC is ready to send
Incr Bblocklocal 'increase local block count
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
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
Set Pwrled ' 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 Pwrled : Waitms 10 : Toggle Pwrled '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[/code:1:327ce73ae1]
thantks for your help and time.
[b:327ce73ae1][color=red:327ce73ae1](BASCOM-AVR version : 2.0.7.6 )[/b:327ce73ae1][/color:327ce73ae1]
↧
BASCOM-AVR : Problem - bootloader don't work witm evertdekker VB6 bootloa : NEWTOPIC
↧
BASCOM-AVR : GETADC(9) on mega32u4 : REPLY
what kind of hardware do you use? how is avcc connected?
↧
↧
BASCOM-AVR : GETADC(9) on mega32u4 : REPLY
It's a bug, ADCSRB is set, but not correctly. But as GetADC modifies it, this code is without effect:
[code:1:3decb004d0]ADCSRB.MUX5 = 1
W = GetADC(1)[/code:1:3decb004d0]
Also this doesn't do the trick:
[code:1:3decb004d0]W = GetADC(1, 32)[/code:1:3decb004d0]
as well it should, normally the 32 addresses bit 5, which corresponds to MUX5.
However and interestingly, this works:
[code:1:3decb004d0]W = GetADC(33)[/code:1:3decb004d0]
it sets MUX5 in ADCSRB and MUX0 in ADMUX, this way selecting ADC9.
↧
BASCOM-AVR : Diy serial LCD : REPLY
Hi ,
I test the following code but I get allways from Bascom an errormessage . Can someone find the mistake ?
[
' $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
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 * 6
Dim Temp as String * 6
Dim A as Byte
Do
A = Waitkey()
If A = 1 Then
Locate 1,1
LCD " Sauerstoff "
Locate 2,1
Input Wert
LCD Wert ,"%"
EndIf
If A = 2 Then
Locate 3,1
LCD " Temperatur "
Locate 4,1
Input Temp
LCD Temp ,"Grad"
EndIf
Waitms 500
Reset Watchdog
Loop
End]
code]
Thanks
Hans
↧
BASCOM-AVR : ST7920 128x64Dots Serial/Parallel LCD : REPLY
Hello
Displays with the ST7920 have two modes, a character-dispay-mode and a graphic-mode. To drive the
display in the character-mode is similiar to a LCD with HD44780. I wrote some code for this mode,
working with parallel- and serial-interface.
The graphic-mode is more complex, it's only possible to drive 8 pixels at once, no single-pixel can
be set or reset. So, you have to manage the graphic display-content by your self. For better ideas,
I am very open minded .. :D
Attached my code for the character-mode.
Regards
Thomas
↧
↧
BASCOM-AVR : Diy serial LCD : REPLY
simple fix
when you use LCC cmd it must use [b:db320f2e48][color=red:db320f2e48];[/color:db320f2e48][/b:db320f2e48] not [b:db320f2e48],[/b:db320f2e48]
[code:1:db320f2e48]LCD Wert ;"%" 'USE ;
LCD Temp ;"Grad" 'USE ; [/code:1:db320f2e48]
↧
BASCOM-AVR : GETADC(9) on mega32u4 : REPLY
WOW - IT WORKS!!
I changed the Pin to D.7 => ADC10 and tried GetAdc(34).
And with GetAdc(39) i can read the Temp. sensor.
This is excellent support
Thanks for helping!
Peter
↧
BASCOM-AVR : Diy serial LCD : REPLY
Hi Kimmi ,
your answer was very helpful .
Many thanks
Hans
↧
BASCOM-AVR : GETADC(9) on mega32u4 : REPLY
but that is what i wrote before : use the value from the mux table. that has been so since day 1.
this line from the dat file : ADC_MUX=6,ADMUX.0-4,ADCSRB.5 contains the info which bits to set.
for the 2077 prerelease i wrote in the history :
- M1280/M2560 and other processors with MUX5 bit : getadc() when used with the optional parameter will write to ADLAR for some values.
Use the channel instead. You can combine the channel and offset when not using the optional offset.
Thus Getadc(32) will read ADC8 in single ended mode.
↧
↧
BASCOM-AVR : ST7920 128x64Dots Serial/Parallel LCD : REPLY
thank you for sharing your code. Maybe you can post it at 'share your code' forum as well.
for lcd with read only mode and multiple pixels/byte the only way to do it (to my knowledge) is to create a screen buffer. but this cost a lot of ram. for 128x64 it would cost 1024 bytes of ram for the screen buffer.
when the CLS is used you would erase the screen and clear the buffer.
when writing a pixel, you would read the byte from the screen buffer, alter the byte, write it back to the buffer + the screen.
when reading a pixel you would read from the buffer. it is reasonable simple. (in theory). but like i said, it cost 1KB of sram just for a 128x64.
↧
BASCOM-AVR : Avr doesn't start (boot) : REPLY
[quote:ae6ea5edbc]I see nothing in the datasheet to suggest the AVR needs a critical rate of rise of power supply to make a reset[/quote:ae6ea5edbc]
Well, I picked the Data Sheet for a Mega168 because I tend to use that chip a lot.
In Section 28.5 System and Reset Characteristics, Table 28-3. Reset, Brown-out and internal voltage Characteristics, one finds Vponsr, (Power-on Slope Rate), with minimum and maximum values to "qualify" the POR circuitry.
JC
↧
BASCOM-AVR : Avr doesn't start (boot) : REPLY
Looks like it pays to read the datasheet for the chip you use.
Nothing like that in the 8535, atmega16,32,64, 644 or several others I looked at, and tried way back.
My ( 2005 ) datasheet for the Mega168 does not show a section 28.5, and nowhere near there is any mention of power supply rate of rise. Section 9.0.3 lists the power on reset characteristics, and is the same as most others I looked at.
↧
BASCOM-AVR : Please help to code Bascom : NEWTOPIC
Please help to code below, if you use the language BASCOM AVR.
I try to control IC LM7001 IC ATtiny2313 wear.
[code:1:3dee5e8767]#include <avr/io.h>
#include <inttypes.h>
#ifndef F_CPU
#define F_CPU 8000000UL //Takt = 8 MHz
#endif
#include <util/delay.h>
#include <stdint.h>
#define PORT_MK PORTB //Port für Mäuseklavier
#define PIN_MK PINB //Pin-Register für Mäuseklavier
#define DDR_MK DDRB //Datenrichtungsregister für Mäuseklavier
#define PORT_T_IC_EA PORTD //Port, an dem der Taster, der LM7001 und der Transistor zur Steuerung der Endstufe hängen
#define PIN_T_IC_EA PIND //Pin-Register für diesen Port
#define DDR_T_IC_EA DDRD //Datenrichtungsregister für diesen Port
#define CL_PIN PD2 //Pin für Clock-Leitung
#define DATA_PIN PD3 //Pin für Daten-Leitung
#define CE_PIN PD4 //Pin für Enable-Leitung
#define TASTER_PIN PD5 //Pin für Taster
#define EA_PIN PD6 //Pin für die Endstufen-Aktivierung
void Ewire_send_bit(char bit)
{
if(bit) //Wenn das aktuelle Bit '1' ist...
PORT_T_IC_EA |= (1<<DATA_PIN); //...dann wird die Daten-Leitung auf high gesetzt...
/* Wenn bit '0' ist, muss man nichts machen, weil die Pins standartmäßig auf low sind */
_delay_us(2); //2 us Delay (T_SU)
PORT_T_IC_EA |= (1<<CL_PIN); //Die Clock-Leitung wird auf high gesetzt
_delay_us(2); //2 us Delay (T_HD)
PORT_T_IC_EA &= ~(1<<CL_PIN); //Clock-Leitung wird auf low gesetzt
PORT_T_IC_EA &= ~(1<<DATA_PIN); //Data-Leitung wird auf low gesetzt
}
void Ewire_send_word(char *ptr, int len)
{
int iAnzahl_der_Bits = 0;
PORT_T_IC_EA |= (1<<CE_PIN); //Enable-Leitung auf high
_delay_us(2); //2 us Delay (T_ES)
while(iAnzahl_der_Bits < len) //Schleife, die jedes Bit an die Funktion Ewire_send_bit() übergibt
{
Ewire_send_bit(*ptr); //Bit übergeben
ptr++; //Pointer auf das nächste Element setzen
iAnzahl_der_Bits++; //Zählvariable inkrementieren
}
PORT_T_IC_EA &= ~(1<<CE_PIN); //Enable-Leitung auf low
}
void Daten_an_LM7001_senden()
{
PORT_T_IC_EA &= ~(1<<EA_PIN); //Endstufe ausschalten
uint16_t Frequenz; //Variable für die Frequenz
uint16_t N_Teiler; //Variable für N-Teiler
char data[24] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1};
/* Array für die Bits, die gesendet werden sollen (Bits durch Komma getrennt)
Nur die ersten 14 Bits werden geändert, die restlichen Bits sollen hier gesetzt werden */
Frequenz = 875u + (uint8_t)(~PIN_MK); //Berechnen der Frequenz (und die Bits in PIN_MK werden invertiert)
N_Teiler = Frequenz * 2; //N_Teiler = ((Frequenz / 10) / 0.05) = Frequenz * 2
for(uint8_t i = 0; i < 14; i++) //kopiert den Wert von N_Teiler in das data-Array ("gespiegelt")
data[i] = ((N_Teiler>>i) & 1);
Ewire_send_word(data, sizeof(data)); //Daten senden
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
_delay_ms(200);
/* 5 Sekunde Delay, damit die PLL einrasten kann */
PORT_T_IC_EA |= (1<<EA_PIN); //Endstufe wieder einschalten
}
int main()
{
DDR_MK = 0x00; //Mäuseklavier als Eingang (eigentlich überflüssig, weil das Datenrichtungsregister standartmäßig mit '0' initialisiert ist)
PORT_MK = 0xFF; //interne Pullup-Widerstände für die Dip-Schalter aktivieren
DDR_T_IC_EA |= (1<<CL_PIN); //Clock-Pin als Ausgang
DDR_T_IC_EA |= (1<<DATA_PIN); //Data-Pin als Ausgang
DDR_T_IC_EA |= (1<<CE_PIN); //Enable-Pin als Ausgang
DDR_T_IC_EA |= (1<<EA_PIN); //Pin für die Endstufen-Aktivierung als Ausgang
/* Taster-Pin bleibt als Eingang, das Datenrichtungsregister ist mit 0 initialisiert */
_delay_ms(100); //Auf LM7001 warten, Quarz anschwingen lassen
Daten_an_LM7001_senden(); //Daten übertragen, die Frequenz wird durch die Dip-Schalter bestimmt
while(1) //Main-Loop
{
if((PIN_T_IC_EA & (1<<TASTER_PIN)) == 0) //Wenn Taster gedrückt
Daten_an_LM7001_senden(); //Daten übertragen, die Frequenz wird durch die Dip-Schalter bestimmt
}
return 0;
}
[/code:1:3dee5e8767]
IMAGE
[img:3dee5e8767]http://senderbau.egyptportal.ch/forum/data/media/1/lm7001neu.GIF[/img:3dee5e8767]
Thanks.
[b:3dee5e8767][color=red:3dee5e8767](BASCOM-AVR version : 2.0.7.6 )[/b:3dee5e8767][/color:3dee5e8767]
↧
↧
BASCOM-AVR : KS0108 Display: Trouble with higher clock speed : REPLY
nope scope channel 1 has something wrong
i suspect a reed relay
in X10 mode it kinda works so I took the next pictures in that mode.
btw I will be getting a Agilent MSOX2024A in week 10 :D :D :D ...nice bossy
O-family
I hope I understand your question correctly
you want to see the reset pin of the avr and the reset pin of the lcd in one picture?
W.
↧
BASCOM-AVR : KS0108 Display: Trouble with higher clock speed : REPLY
here the both resets
↧
BASCOM-AVR : Diy serial LCD : REPLY
Maybe consider using SPI for driving LCD, see [url=http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=9091]this link [/url=http://www.svet-el.si/english/index.php/data-displays/31-data/14-avr63]or [url]this link[/url], where using LCD on an SPI was described.
I could drive more LCDs with only 3 pins used on a uC.
Best regards
Jure
↧
BASCOM-AVR : KS0108 Display: Trouble with higher clock speed : REPLY
It will be why.....
I think waveform as indicating normal operation.
I want to check again.
When standard "glcdKS108.LBX" is used, even if a picture may be confused, doesn't the phenomenon to freeze occur?
↧
↧
BASCOM-AVR : KS0108 Display: Trouble with higher clock speed : REPLY
Please try on this library.
O-Family
↧
BASCOM-AVR : simple spi soft problem : REPLY
Hi mark,
I use my own dev card, it is a card with 3 kind ok µC 40, 28, and 8 pins - all independent only the power supply is common
The 3 ISP ports are "removable" by jumpers, I did it when the program is in flash
I try to run the both programs on the sample without any success, I use 2 LCD display, one for the master and one for the slave.
I join the program, and the pdf of the card.
Again I'm in the darkness. :smt017 i'm waiting for the :idea: :wink:
Best regards
JP
↧
Various : Please help to code Bascom : REPLY
Hi,
here is a test setup for LM7001 hope it works
login to see bas file
↧