Hello!! Evert
Sorry for the delay.
I made the modification and STK500 card use and I mark mistake !! Something's wrong?
My code:
[code:1:e87331033d]$regfile = "m16adef.dat"
$Crystal=4000000
$hwstack=40
$swstack=16
$framesize=32
Config Pind.0 = Output : Led_0 Alias Portd.0 : Led_0 = 0
Config Pind.1 = Output : Led_1 Alias Portd.1 : Led_1 = 0
Config Pina.7 = Output : Led_7 Alias Porta.7 : Led_7 = 0
Config Pinc.0 = Input : Boton Alias Pinc.0 : Boton = 1
Dim N As Word
Dim Boton As Bit
Dim Led_7 As Bit
Dim Led_0 As Byte
Dim Led_1 As Byte
Config Timer0 = Timer , Prescale = 64
On Timer0 T0_isr
Enable Timer0
Enable Interrupts
Do
If Boton = 0 Then Gosub Blinkeando Else Porta.7 = 1
Led_7 = 0
Loop
End
Blinkeando:
If Led_7 = 1 Then
Incr Led_0
If Led_0 > 50 Then
Led_0 = 0
End If
If Led_0 = 1 Then Portd.0 = 0
If Led_0 = 4 Then Portd.0 = 1
Incr Led_1
If Led_1 > 55 Then
Led_1 = 0
End If
If Led_1 = 1 Then Portd.1 = 0
If Led_1 = 5 Then Portd.1 = 1
End If
Return
T0_isr:
Led_0 = 1
Incr N
If N >= 50 Then
Toggle Porta.7
N = 0
End If
Return
End
[/code:1:e87331033d]
:roll: :roll: :roll:
↧
BASCOM-AVR Old versions : Timer-Interrupts : REPLY
↧
BASCOM-AVR Old versions : Timer-Interrupts : REPLY
Add a variable:
[code:1:6d58754dab]Dim Zs As Bit
Dim Bz As Byte
Dim Bz1 As Byte[/code:1:6d58754dab]
The full code but because no PORTA.7 does not blink?
[code:1:6d58754dab]$regfile = "m16adef.dat"
$Crystal=4000000
$hwstack=40
$swstack=16
$framesize=32
Config Pind.0 = Output : Led_0 Alias Portd.0 : Led_0 = 0
Config Pind.1 = Output : Led_1 Alias Portd.1 : Led_1 = 0
Config Pina.7 = Output : Led_7 Alias Porta.7 : Led_7 = 0
Config Pinc.0 = Input : Boton Alias Pinc.0 : Boton = 1
Dim N As Word
Dim Boton As Bit
Dim Zs As Bit
Dim Bz As Byte
Dim Bz1 As Byte
Config Timer0 = Timer , Prescale = 64
On Timer0 T0_isr
Enable Timer0
Enable Interrupts
Do
If Boton = 0 Then Gosub Blinkeando Else Porta.7 = 1
Zs = 0
Loop
Blinkeando:
If Zs = 1 Then
Incr Bz
If Bz > 50 Then
Bz = 0
End If
If Bz = 1 Then Portd.0 = 0
If Bz = 4 Then Portd.0 = 1
Incr Bz1
If Bz1 > 55 Then
Bz1 = 0
End If
If Bz1 = 1 Then Portd.1 = 0
If Bz1 = 5 Then Portd.1 = 1
End If
Return
T0_isr:
Zs = 1
Incr N
If N >= 50 Then
Toggle Porta.7
N = 0
End If
Return
End
[/code:1:6d58754dab]
:roll: :roll: :roll:
↧
↧
BASCOM-AVR Old versions : Timer-Interrupts : REPLY
[quote:5d8c998710="Evert :-)"]Depends how you connected your button.
If you connected it between pinc.0 and gnd you need a pull-up resistor to vcc.
You can enable this with
[code:1:5d8c998710]portc.0 = 1[/code:1:5d8c998710]
Btw I think [b:5d8c998710]On[/b:5d8c998710] and [b:5d8c998710]Off[/b:5d8c998710] are reserved words in Bascom, better choose other alias.[/quote:5d8c998710]
[code:1:5d8c998710]Config Pinc.0 = Input : Boton Alias Pinc.0 : Boton = 1[/code:1:5d8c998710]
:lol:
↧
BASCOM-AVR Old versions : Timer-Interrupts : REPLY
Try it ;)
[code:1:8ead48d244]$regfile = "m16def.dat"
$Crystal=4000000
$hwstack=40
$swstack=16
$framesize=32
Config Pind.0 = Output : Led_0 Alias Portd.0 : Led_0 = 0
Config Pind.1 = Output : Led_1 Alias Portd.1 : Led_1 = 0
Config Pina.7 = Output : Led_7 Alias Porta.7 : Led_7 = 0
Config Pinc.0 = Input : Boton Alias Pinc.0 : Portc.0 = 1 'Alias is for PIN but Pullup must be done on PORT
' When you specify "Boton Alias PINC.0" and then "Boton = 1" then you NOT! enable pullup because it means "PINC.0 = 1"
Dim N As Word
Dim Zs As Byte ' in interrupt for flag better to use Byte
Dim Bz As Byte
Dim Bz1 As Byte
' IRQ Time = Freq(4MHz)/Prescaler(64)/Timer(256)
' 4 000 000 Hz/64/256 = 244Hz
' 1 second have 1000ms
' 1000ms / 244 = 4ms
Config Timer0 = Timer , Prescale = 64 ' ~4ms @4MHz/64
Enable Timer0 : : On Timer0 T0_isr
Enable Interrupts
Do
If Zs = 1 Then ' every 200ms if flag is set
Zs = 0 ' clear flag
If Boton = 0 Then ' if Boton is pressed
Set Led_7
Incr Bz
If Bz > 10 Then Bz = 0 ' 10x200ms=2s
If Bz = 1 Then Led_0 = 0
If Bz = 4 Then Led_0 = 1 ' Led flash for 3x200ms
Incr Bz1
If Bz1 > 15 Then Bz1 = 0 ' 15x200ms=3s
If Bz1 = 1 Then Led_1 = 0
If Bz1 = 5 Then Led_1 = 1 ' Led flash for 4x200ms
Else ' if Boton released
Toggle Led_7 ' toggle every 200ms
Set Led_0
Set Led_1
End If
End If
Loop
T0_isr:
Incr N
If N >= 50 Then '50x4ms=200ms
N = 0
Zs = 1 'set flag only
End If
Return
End
[/code:1:8ead48d244]
↧
Share your working BASCOM-AVR code here : SSD1306 LCD SPI-mode library : NEWTOPIC
Library for SPI4 OLED displays. Support text & pictures.
[b:1d923f8de3]Note![/b:1d923f8de3] Usually SSD1306 displays has default "Alternative COM pin configuration", but some has "COM Left/Right remap". This UG-2832HSWEG04, for example:
[URL=http://vfl.ru/fotos/3951290813144626.html][img:1d923f8de3]http://images.vfl.ru/ii/1466849099/39512908/13144626_s.jpg[/img:1d923f8de3][/URL]
So I add constant [b:1d923f8de3]Lcd_remap[/b:1d923f8de3]. If it not declared or set to 1 "Alternative" mode will be selected. If Lcd_remap set to 2 - "Left/Right remap".
Also in attach schematic and datasheet for UG-2832HSWEG04.
[URL=http://vfl.ru/fotos/4dffda9513144627.html][img:1d923f8de3]http://images.vfl.ru/ii/1466849122/4dffda95/13144627_s.jpg[/img:1d923f8de3][/URL]
↧
↧
BASCOM-AVR : ATxmega128B3 : REPLY
Hi,
The hardware serial port does not work properly.
Can anybody make a test with a 128B3 ?
Best regards
Georges
↧
BASCOM-AVR Old versions : Timer-Interrupts : REPLY
Hi EDC !!
Many Thanks!! :P :P :D :smt038
↧
BASCOM-AVR : problem with delay using motion sensor : NEWTOPIC
i want to control light in 2 rooms using motion sensor (pir sensor).each room has pir sensor. if motion detect in one of the room then uc will activated a relay to turn on the light for 10 seconds and i use ''wait'' in my basxom code to generate delay. the problem is during that delay the other sensor can't immediately response a motion. is anybody can help me to solve the problem?really appreciate any help you can provide. sorry fory bad english
[b:d99c8c4897][color=red:d99c8c4897](BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.8 )[/b:d99c8c4897][/color:d99c8c4897]
↧
BASCOM-AVR : problem with delay using motion sensor : REPLY
Post your code then we try to tweak it :P
Even if you don`t know how to configure Timer then you can in loop insert small delay eg. 100ms and when one sensor enable relay then set some variable for countdown. When variable is zero then relay off ;)
[code:1:13f52163ec]
Dim Variable_1 As Byte
Dim Variable_2 As Byte
Do
If First_sensor = 0 Then Variable_1 = 100
If Second_sensor = 0 Then Variable_2 = 100
If Variable_1 > 0 Then
Decr Variable_1
Set Realay_1
Else
Reset Realy_1
End If
If Variable_2 > 0 Then
Decr Variable_2
Set Realay_2
Else
Reset Realy_2
End If
Loop[/code:1:13f52163ec]
That`s it :P
↧
↧
Share your working BASCOM-AVR code here : WEB Server based CLOCK with NTP SYNCH on MEGA2560 (no SD nee : NEWTOPIC
Hello everyone. Maybe I never post that simple code but I wana show mistake I made who cost me whole day of thinking :D
I`m not big fan of Arduino PCB`s because its description terminology. To do something I must open two PDF`s and search.
But I got this so I will not complain more :D
When I want to try this thing none of examples work for me.. so after some time I found that webserwer example from Samples folder opens port 500 instead 80 where browsers search for page :P
I also try Paul`s serwer code but nothing happends :D I think so maybe some picture gif or something must be on card but I can`t find anything to download..
So I decide to write some code and after another fiew hours I build page with TIME DATE and LINK to FORUM :D
Page is "color of sand" with blue font.
Know why it took`s me whole day?
[b:ef8bee5bbf]Because I have card inserted in slot but I don`t configure card CS pin and card occasionally destroy my SPI communications[/b:ef8bee5bbf] :D
So be careful because "it`s a trap for young players" like EEVBlog says Hahahaha :D
Here is a screenshot. This code You simply compile (if router IP ends with x.x.0.1) and after minute you have Time corrected by NTP serwer :P
↧
BASCOM-AVR : ATxmega128B3 : REPLY
$regfile = "xm128b3def.dat"
$crystal = 32000000
$hwstack = 96
$swstack = 64
$framesize = 64
'First Enable The Osc Of Your Choice , make sure to enable 32 KHz clock or use an external 32 KHz clock
Config Osc = Enabled , 32mhzosc = Enabled
'configure the systemclock
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
Config Com1 =9600 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Does not work.
Serial Characters are not receive.
Best regards
Georges
↧
BASCOM-AVR Old versions : problem with delay using motion sensor : REPLY
Hello!! as calculated for 100 ms? :-k
↧
BASCOM-AVR Old versions : problem with delay using motion sensor : REPLY
It depends on the value of time?
[code:1:9c93f8dc94]Waitms 100 [/code:1:9c93f8dc94]
:-k
↧
↧
BASCOM-AVR Old versions : problem with delay using motion sensor : REPLY
thank you Mr EDC... it works...
↧
BASCOM-AVR : ATxmega128B3 : REPLY
If you say "Doesn't receive" is it sending?
What pins are you using for com1? Should be TX=C.3 RX= C.2
↧
BASCOM-AVR : Bootloader special characters : NEWTOPIC
Using MCS Bootloader - Works great - When sending characters prior to the #123, how I can enter a carriage return? Tried usual identifiers to no avail.
[b][color=red](BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 )[/b][/color]
↧
BASCOM-AVR : ATxmega128B3 : REPLY
Hi,
Thanks for your help.
I use the right PINS.
I think baudrate or format is not right or something like this.
I communique at 8 bit, 1 stop, 9600 bauds ( GSM SIM808 )
I see character on RX with a sniffer but CPU do not see it.
Best regards
Georges
↧
↧
BASCOM-AVR : Bootloader special characters : REPLY
{013} is a enter ;)
↧
BASCOM-AVR : ATxmega128B3 : REPLY
Try adapt to your Xmega.
For better transmision stability automatic osc calibration is enabled.
Your speed 9600 is slow but for higher (I test this) calibration must be done because transmision errors.
[code:1:7b5a6c4b5b]
$regfile = "xm128a3udef.dat"
$crystal = 32000000 '32MHz
$hwstack = 80 'this is for my other tasks so
$swstack = 100 'you can modify values to your needs
$framesize = 100
Config Submode = New
Const Debuging = 1
' ***************** SYSTEM CLOCK CONFIG **************************
' INTERNAL 32MHz NO PRESCALE
'
Config Osc = Disabled , 32mhzosc = Enabled , 32khzosc = Enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
'
' ENABLING AUTOMATIC OSCILLATOR CALIBRATION
Osc_dfllctrl.0 = 1
Dfllrc32m_ctrl.0 = 1
'
'*****************************************************************
'************ CONFIGURATION FOR COM1 ON PORTC ********************
' ESP8266 ON COM1
Config Com1 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 'Tx-PC3 Rx-PC2
Open "COM1:" For Binary As #1
Config Serialin0 = Buffered , Size = 100 'for COM1
Config Input1 = Crlf , Echo = Crlf
'*****************************************************************
#if Debuging = 1
'*********** CONFIGURATION FOR COM2 ON PORTC *********************
' COM2 IS FOR DEBUG SO SEPARATE CONFIG
Config Com2 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8 'Tx-PC7 Rx-PC6
Open "COM2:" For Binary As #2
Config Serialin1 = Buffered , Size = 50 'for COM2
Config Input2 = Cr , Echo = Cr
'*****************************************************************
#endif
End[/code:1:7b5a6c4b5b]
↧
BASCOM-AVR : Bootloader special characters : REPLY
Thank you very much!
↧