Hello all,
Just starting to use Projects and Include files. In some cases, Line Labels are used. What is best practice for Line Labels, including those used by _Isr's, when using multiple include files?
Thank you,
Tim
[b:96f7e97687][color=red:96f7e97687](BASCOM-AVR version : 2.0.7.7 )[/b:96f7e97687][/color:96f7e97687]
↧
BASCOM-AVR : Line Label Best Practices with Include Files : NEWTOPIC
↧
BASCOM-AVR : HHO Generator : REPLY
Robert
Yes Please, post something when finished.
Interesting to see how you are going to control the Engine plus
run it without some substitute gas to complement Hydrogen Generator.
↧
↧
BASCOM-AVR : double < 0 : REPLY
You ask about precision and have doubt about my skill? - no
Some time positive double value lower then Zero.
Why precision?
my code is very big size. i try simulate this on small code and post here.
And sorri my english ) I am from Russia.
↧
BASCOM-ARDUINO : XLS correlation table AVR atmega 2560/328 / Arduino : NEWTOPIC
Hi everybody,
As I said it is possible to read XLSX file when you have downloaded the microsoft converter.
But some doesn't want it, so I translate it for you ! :wink:
JP
↧
BASCOM-AVR : Atmega8 and SURE(ht1632c) green dot matrix 16x24 : NEWTOPIC
Hi
I try connect this matrix and atmega8 with external 8MHz crystal . I use this code example, but nothing happens. All connections ok. Help...
[code:1:2b57b0ba11]
$regfile = "m8def.dat"
$crystal = 8000000
$hwstack = 128
$swstack = 256
$framesize = 256
Declare Sub Commandwrite(byval Command As Word )
Declare Sub Display_nibble(byval Register As Byte , Byval Value As Byte)
Const Sysen = &B100000000010
Const Ledon = &B100000000110
Const Ledoff = &B100000000100
Const Blinkon = &B100000010010
Const Mastermode = &B100000101110
Const Rc = &B100000110110
Const Commonsoption = &B100001011000 'N-MOS open drain output
Const Pwmduty = &B100101111100
Const Pwm 1_16duty = &B100101000000
Const Pwm 2_16duty = &B100101000100
Const Blinkoff = &B100000010000
Cs1 Alias Portc.3
Clk Alias Portc.4
Dat Alias Portc.5
Config Dat = Output
Config Clk = Output
Config Cs1 = Output
Dim Daten As Word
Dim Runde As Byte
Dim Daten_adres As Byte
Dim Char As Byte
Dim X As Byte
Dim Y As Byte
Dim Shiftdat As Word
'init ht1632
Call Commandwrite(sysen)
Set Cs1
Waitus 100
Reset Cs1
Waitus 100
Shiftdat = Sysen
Shiftout Dat , Clk , Shiftdat , 1 , 12
Shiftdat = Ledon
Shiftout Dat , Clk , Shiftdat , 1 , 12
'Call Commandwrite(ledon)
Shiftdat = Mastermode
Shiftout Dat , Clk , Shiftdat , 1 , 12
'Call Commandwrite(mastermode)
Shiftdat = Rc
Shiftout Dat , Clk , Shiftdat , 1 , 12
'Call Commandwrite(rc)
Shiftdat = Commonsoption
Shiftout Dat , Clk , Shiftdat , 1 , 12
'Call Commandwrite(commonsoption)
Shiftdat = Pwmduty
Shiftout Dat , Clk , Shiftdat , 1 , 12
'Call Commandwrite(pwmduty)
'clear display
For X = 0 To 95
Call Display_nibble(x , 0)
Next X
'display bascom
Restore Bascom
For X = 0 To 95
Read Y
Call Display_nibble(x , Y)
Next X
End
Sub Display_nibble(byval Register , Byval Value)
Daten = 0
Set Cs1
Nop
Reset Cs1
Nop
Clk = 0
Dat = 1
Nop
Clk = 1
Clk = 0
Dat = 0
NOP
Clk = 1
NOP
Clk = 0
Dat = 1
NOP
Clk = 1
NOP
' ---------------------------------------------------------------------
' | | | | | A | A|A |A |A |A |A |D |D |D |D |
' D15|D14|D13|D12|D11|D10|D9|D8|D7|D6|D5|D4|D3|D2|D1|D0|
' ---------------------------------------------------------------------
' ^
' | adres 0 - 63 data 0-15
'
Daten = 0
Daten.10 = Register.6
Daten.9 = Register.5
Daten.8 = Register.4
Daten.7 = Register.3
Daten.6 = Register.2
Daten.5 = Register.1
Daten.4 = Register.0
Daten.3 = Value.3
Daten.2 = Value.2
Daten.1 = Value.1
Daten.0 = Value.0
For Runde = 0 To 10
Clk = 0
NOP
If Daten.10 = 1 Then
Dat = 1
Else
Dat = 0
End If
NOP
Clk = 1
Shift Daten , Left , 1
Next Runde
Daten = 0
'-------------------------------------
NOP
Set Cs1
End Sub
Sub Commandwrite(byval Command As Word )
Local Cmd_byte As Byte
Set Cs1
Waitus 100
Reset Cs1
Waitus 100
Command = Command And &H0FFF
Shift Command , Left , 4
For Cmd_byte = 1 To 12
Clk = 0
If Command.15 = 1 Then
Dat = 1
Else
Dat = 0
End If
Clk = 1
Shift Command , Left , 1
Waitus 100
Next
Waitus 100
Set Cs1
End Sub
Bascom:
'character 1
Data 0 , 0 , 4 , 0 , 4 , 0 , 7 , 1 , 4 , 10 , 4 , 10 , 7 , 1 , 0 , 0
'character 2
Data 0 , 0 , 0 , 0 , 0 , 14 , 13 , 0 , 4 , 12 , 4 , 2 , 13 , 12 , 0 , 0
'character 3
Data 0 , 0 , 0 , 0 , 0 , 0 , 6 , 6 , 8 , 9 , 8 , 9 , 6 , 6 , 0 , 0
'character 4
Data 0 , 0 , 0 , 0 , 0 , 0 , 4 , 4 , 6 , 12 , 5 , 4 , 4 , 4 , 0 , 0
[/code:1:2b57b0ba11]
[b:2b57b0ba11][color=red:2b57b0ba11](BASCOM-AVR version : 2.0.7.7 )[/b:2b57b0ba11][/color:2b57b0ba11]
↧
↧
BASCOM-AVR : Line Label Best Practices with Include Files : REPLY
hello,
could you be more explicit ?
what do you want ?
use gosub....label where label is in file include ?
or use loadlabel ?
Would you please add a small code example.
JP
:wink:
↧
BASCOM-ARDUINO : XLS correlation table AVR atmega 2560/328 / Arduino : REPLY
oops the file !
↧
BASCOM-AVR : Line Label Best Practices with Include Files : REPLY
Hello Duval JP,
Thank you for your response. The following are some specific examples.
Tim
'********************************************************************************************
'* Timer0 '1mS Timer '8 Bit Timer
'*************************************************************************************************
Const Timer0reload = 125
Config Timer0 = Timer , Prescale = 64
On Ovf0 Timer0_isr
Enable Timer0
'********************************************************************************************
'* Timer1 '500uS 16bit Timer
'*************************************************************************************************
Const Timer1reload = 4000
Config Timer1 = Timer , Prescale = 1
Load Timer1 , Timer1reload
On Ovf1 Timer1_isr
'**********************************************************************************************
'**********************************************************************************************
'* Timer0 '1mS Timer '8 Bit Timer
Timer0_isr: '1 mS Timer
Load Timer0 , Timer0reload
If Ack_interval_counter = 10000 Then Ack_interval_counter = 0
If Wait_4_ack = 1 Then Incr Ack_interval_counter
Return
'**********************************************************************************************
'**********************************************************************************************
'* Timer1 '500uS 16bit Timer
Timer1_isr: '500 uS Timer
Load Timer1 , Timer1reload
If Strt_debounce > 0 Then Decr Strt_debounce
Return
'*************************************************************************
Receive_data:
'poll RFM12 for Rx data.
Rfm12_get_status_bit
If Rx_status_bit = 1 Then
Rfm12_rx Rxbuffer(1)
Alarm_data_received = 1
Rxbuff(1) = Rxstring
End If
Return
'*************************************************************************
Isr_ffit:
Gosub Receive_data
Return
↧
BASCOM-AVR : Line Label Best Practices with Include Files : REPLY
Hi,
I usually split my programs using includes based on functionality:-
l2c_bus.lib - contains the low level i2c routines
IO.lib - contains the alias definitions for PIN/ADC's
Sensors.lib - contains the Scaling/Smoothing and alarming routines
SF04.lib - contains the Sensirion flow sensor routines
Amsys.lib - contains the Pressure sensor routines
Sm.lib - contains the "Smart bus" battery routines
The main program then just consists of the code to setup the AVR, Interrupt service routines and the State machine handler.
The example above if doe a project I'm currently working on that at the moment consists of about 6000lines of code.
Breaking the cod down into functional groups makes testing a lot easier. I can create a small test program, add the required sensors and test it.
Regards
Ian Dobson
↧
↧
BASCOM-AVR : Line Label Best Practices with Include Files : REPLY
For my "test board" I have done configurations and subroutines in files that I include only. Configuration for Lcd, Timers and what ever can be included before Do Loop and Sub`s after Loop. It does not matter whether it's IRQ. For new projects do not have to write this again
[code:1:f3b2eb965d]
$regfile = "m8def.dat"
$crystal = 8000000
$hwstack = 64
$swstack = 64
$framesize = 64
'$loadersize = 1024
$include "encoder_config_new.bas"
$include "lcd_config_new.bas"
$include "menu_config.bas"
$include "sterowanie_config.bas"
$include "temperatura_config.bas"
'Dim Hbyte(2) As Byte , Hword(2) As Word , N As Byte , T(2) As Word
Flaga_zegar = 1 : Flaga_menu = 0 : Flaga_odliczanie = 1
Dim Autolight As Byte
Light = 0
Do
If Stan_enc <> 0 Then
Alarms = 0 'kasuje alarm do czasu ostygnięcia pieca
Wygaszenie = 0 'pozwala pikać
End If
' automatyczne wyjście z menu
If Menu_timeout = 0 And Flaga_odliczanie = 1 Then
Flaga_odliczanie = 0 ' wyzeruj flage
Flaga_zegar = 1
Flaga_menu = 0
Nr_podprogramu = 0
Light = 1
Cls
Lcd "PIEC:--"
Lowerline
Lcd Chr(0) ; " BOJLER" ; Chr(126)
End If
If Zegarek_licznik = 0 Then
Zegarek_licznik = 250 'to co sekunde
If Flaga_zegar = 1 And Flaga_menu = 0 Then 'jesli nie wyswietlane menu
Gosub Glowna
If Light = 0 Then Incr Autolight
End If
Gosub Temperatura
Gosub Sterowanie
End If
If Autolight = 2 Then
Autolight = 0
Light = 1
End If
If Stan_enc = Enc_enter Then ' sprawdź czy ekran główny i wciśnięty przycisk ENTER
If Flaga_menu = 0 And Nr_podprogramu = 0 And Enc_menu > 650 Then
Flaga_zegar = 0 ' ustaw flage
Flaga_menu = 1 ' ustaw flagę że wyświetlane jest menu
Menu_nr_linii = 1 ' kursor w pierwszej linii menu
Flaga_odswiez_kursor = 1
Pozycja_menu = Loadlabel(menu_glowne) ' zapamietaj adres danych pierwszej linii menu
Call Wyswietl_menu(pozycja_menu , 1 , Down)
Stan_enc = 0 ' kasuj zapamiętany przycisk
Menu_timeout = 2000
Flaga_odliczanie = 1
Else
Enc_menu = 0
End If
Light = 0
End If
' obsługa menu
Call Obsluga_menu()
' wykonanie podprogramu wybranego z menu
Gosub Menu_podprogramy
' kasuj zapamiętany stan enkodera
Stan_enc = 0
Loop
End
$include "encoder.bas"
$include "menu.bas"
$include "temperatura.bas"
$include "sterowanie.bas"
$include "lcd.bas"[/code:1:f3b2eb965d]
↧
BASCOM-AVR : Line Label Best Practices with Include Files : REPLY
Hello i.dobson and EDC,
Thank you for your replies! Interesting, that EDC includes.bas files. So it appears that you can include both .inc and .bas files. I thought that only 1 .bas file could be in the project.
i.dobson, as you described you put line labels like those used for ISR's in the main .bas, from my brief work, that seemed to be the only place they would work. I also noted that your file names are of .lib - does this mean that any file extension can be used?
EDC, in you include.bas files. In those, do you have also ISRs, timers and other items as necessary - or are they only in your main .bas file?
In both cases, this was quite enlightening! I think it will make it much easier to work on a large project having the ability to organize in to file size chunks. Also nice is that the same files can be used elsewhere when necessary as you both did.
Thanks again for your replies!
Tim
↧
BASCOM-AVR : Line Label Best Practices with Include Files : REPLY
Hi Tim,
Woops your right, the file names are with .inc not .lib
Regards
Ian Dobson
↧
BASCOM-AVR : Line Label Best Practices with Include Files : REPLY
Hi Ian,
Thanks for the clarification. I had not tried it yet, but it would be kind of cool if you could use different file extensions. Especially since the whole file name has to be stated in the $Include line.
Do all &Include files need to be in the same folder as the Project / main .bas file? If not is it correct that the source has to have a hard coded full path to the files.
In your case, I can see there the above would come into play since the $Includes are used in many projects, probably at one time. So a central repository would make sense. Is this what you do?
Thanks again Ian,
Tim
↧
↧
BASCOM-AVR : Line Label Best Practices with Include Files : REPLY
Hi,
I've never tried with different directories. I usually just copy the required modules from my central module directly into the project directory.
I work for pharmaceutical companies and testing/documentation/validation if very important for them and using standard/pre-tested modules makes my life much easier. When I start testing/documenting a project I can just pull in the modules documentation and set a reference to the previous tests performed, rather than having to test everything again. I still need to test the interface to the main application but not the low level code within the module.
Regards
Ian Dobson
↧
BASCOM-AVR : XMega64 / 128 mit 4 port EBI and SRam : NEWTOPIC
Ich habe in vielen Stunden Arbeit herausgefunden, wie der XMega64 /128 mit einem vollständigen 4-Port-EBI
betrieben werden kann.
Dabei stehen die Leitungen A0 bis A21, CS0 bis CS3, RW, RD und D0 bis D7 zur Verfügung.
SRam ist zwar etwas teurer als Dram, aber mindestens um den Faktor 4 schneller.
Zudem lässt sich so Hardware Memory-mapped an den XMega anbinden.
DMA aus und in den externen Bereich funktionieren einwandfrei.
Im Anhang befindet sich ein exakter Schaltplan und der Bascom Code...
Hier der Bascom-Code zum einstellen des 4 Port-EBI:
$regfile = "xm128a1def.dat"
$crystal = 32000000
$hwstack = &H32
$swstack = &H32
$framesize = &H32
$xramstart = &H100000
$xramsize = &H080000
'------------------
' CPU:
' ATXMEGA128A1U-AU : 2,23/100 Mouser Muss -->A1U-AU<-- sein !!!
' ATXMEGA64A1U-AU
'------------------
' SRam:
' 512 KB AS6C4008-55PCN : SRAM 4MB 2.7V-5.5V, 512KX8, PDIP32 3,09/100 @ Farnell <------------ in Use
' 512 KB AS6C4008-55SIN : SRAM 4MB 2.7V-5.5V, 512KX8, SOP32 2,76/100 @ Farnell <-- for ready design
' 512 KB AS6C4008-55SIN : SRAM 4MB 2.7V-5.5V, 512KX8, SOP32 2,46/100 @ Mouser <-- for ready design
' 2,33/500 @ Mouser
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
' #### Four Port SRAM ####
' MODE SRAM 4Port direkt
' PortH.0 - Pin 55 /WR
' PortH.1 - Pin 56 /RD
' PortE.4 - Pin 39 /CS0 / A16 -> CS0: SRAM 512 KB
' PortE.5 - Pin 40 /CS1 / A17 -> CS1: unbenutzt
' PortE.6 - Pin 41 /CS2 / A18 -> CS2: unbenutzt
' PortE.7 - Pin 42 /CS3 / A19 -> CS3: unbenutzt
' PortJ.0 - Pin 65 D0 -> SRam
' PortJ.1 - Pin 66 D1 -> SRam
' PortJ.2 - Pin 67 D2 -> SRam
' PortJ.3 - Pin 68 D3 -> SRam
' PortJ.4 - Pin 69 D4 -> SRam
' PortJ.5 - Pin 70 D5 -> SRam
' PortJ.6 - Pin 71 D6 -> SRam
' PortJ.7 - Pin 72 D7 -> SRam
' PortK.0 - Pin 75 A0 -> SRam
' PortK.1 - Pin 76 A1 -> SRam
' PortK.2 - Pin 77 A2 -> SRam
' PortK.3 - Pin 78 A3 -> SRam
' PortK.4 - Pin 79 A4 -> SRam
' PortK.5 - Pin 80 A5 -> SRam
' PortK.6 - Pin 81 A6 -> SRam
' PortK.7 - Pin 82 A7 -> SRam
' PortF.0 - Pin 45 A8 -> SRam
' PortF.1 - Pin 46 A9 -> SRam
' PortF.2 - Pin 47 A10 -> SRam
' PortF.3 - Pin 48 A11 -> SRam
' PortF.4 - Pin 49 A12 -> SRam
' PortF.5 - Pin 40 A13 -> SRam
' PortF.6 - Pin 41 A14 -> SRam
' PortF.7 - Pin 42 A15 -> SRam
' PortH.2 - Pin 57 A16 -> SRam
' PortH.3 - Pin 58 A17 -> SRam
' PortH.4 - Pin 59 A18 -> SRam
' PortH.5 - Pin 60 A19 - unbenutzt
' PortH.6 - Pin 61 A20 - unbenutzt
' PortH.7 - Pin 62 A21 - unbenutzt
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
' include the following lib and code, the routines will be replaced since
' they are a workaround
$lib "xmega.lib"
$external _xmegafix_clear
$external _xmegafix_rol_r1014
'-------------------------------------------------------------------------------
'----------generate a 32 MHz system clock by use of the PLL (2MHz * 23 = 46MHz)
Config Osc = Disabled , Extosc = Enabled
'Set the Multiplication factor and select the clock Reference for the PLL
'Osc_pllctrl = &B00_0_10100 '2MHz clock Source and Multiplication factor = 23
' 00 : 2 MHz internal OSC
' 01 : Reerved
' 10 : 32 MHz internal OSC
' 11 : External Clock Source
' 1 : 0=PLL-Output devided by 1 |1=PLL-Output devided by 2
' xxxxx: Multiplikation of PLL 1-31
Osc_pllctrl = &B11_0_01000 : Const Mhz = 32 ' 32 MHz
'enable PLL
Set Osc_ctrl.4 'PLL enable
'configure the systemclock
Config Sysclock = Pll 'use PLL
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
Config Com1 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Open "com1:" For Binary As #1
' Termninal initialisieren
Printbin #1 , &H1B ; &H5B ; &H30 ; &H6D ' All attributes off(normal)
Printbin #1 , &H1B ; &H5B ; &H32 ; &H4A ' Bildschirm löschen
Printbin #1 , &H1B ; &H5B ; &H48 ; ' Cursor Home
Printbin #1 , &H1B ; &H5B ; &H3F ; &H32 ; &H35 ; &H68 ; ' Cursor an
'-------------------------------------------------------------------------------
' Einstellungen externer Speicher
' Alle EBI-Ports müssen auf OUTPUT
' ALLE Ports, die ATKIV-LOW sind müssen auf 1 gesetzt werden !!!
' ALLE Ports, die ATKIV-HIGH sind müssen auf 0 gesetzt werden !!!
Print #1 , "Config Ports for external Adress / Data-Bus with no ALE... ";
Portj_dirset = &B1111_1111 : Portj = &B0000_0000 ' D0:7
Portj_pin0ctrl = &B0_0_000_000 'Totem (PushPull)
Portj_pin1ctrl = &B0_0_000_000 'Totem (PushPull)
Portj_pin2ctrl = &B0_0_000_000 'Totem (PushPull)
Portj_pin3ctrl = &B0_0_000_000 'Totem (PushPull)
Portj_pin4ctrl = &B0_0_000_000 'Totem (PushPull)
Portj_pin5ctrl = &B0_0_000_000 'Totem (PushPull)
Portj_pin6ctrl = &B0_0_000_000 'Totem (PushPull)
Portj_pin7ctrl = &B0_0_000_000 'Totem (PushPull)
Portk_dirset = &B1111_1111 : Portk = &B1111_1111 ' A0:7
Portk_pin0ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portk_pin1ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portk_pin2ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portk_pin3ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portk_pin4ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portk_pin5ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portk_pin6ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portk_pin7ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
' PortX_pinYctrl = &B0_0_001_000 : X= Port A... Y= Bit Nr. 0-7
' X :7 : 0= SlewRate normal, 1= SlewRate limited
' X :6 : 0= IO normal, 1= IO inverted
' XXX :5:3: 000 = Totem (PushPull)
' XXX :5:3: 001 = Totem + Buskeeper
' XXX :5:3: 010 = Totem + Pulldown on Input
' XXX :5:3: 011 = Totem + PullUp on Input
' XXX :5:3: 100 = Wired or
' XXX :5:3: 101 = Wired and
' XXX :5:3: 110 = Wired Or + PullDown
' XXX :5:3: 111 = Wired And + PullUp
' XXX:2:0: 000 = Both edges trigger port Interrupts / Events
' XXX:2:0: 001 = Rising edge trigger port Interrupts / Events
' XXX:2:0: 010 = Falling edge trigger port Interrupts / Events
' XXX:2:0: 011 = Low Level trigger port Interrupts / Events
' XXX:2:0: 100 = Reserved
' XXX:2:0: 101 = Reserved
' XXX:2:0: 110 = Reserved
' XXX:2:0: 111 = Input Buffer Disabled (Only Port A to F) for use with ADC or AC
Portf_dirset = &B1111_1111 : Portf = &B1111_1111 ' A8:15
Portf_pin0ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portf_pin1ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portf_pin2ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portf_pin3ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portf_pin4ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portf_pin5ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portf_pin6ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Portf_pin7ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Porth_dirset = &B1111_1111 : Porth = &B1111_1111 ' WR, RD , A16, A17, A18, A19, A20, A21
Porth_pin0ctrl = &B0_0_000_000 'Totem (PushPull)
Porth_pin1ctrl = &B0_0_000_000 'Totem (PushPull)
Porth_pin2ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Porth_pin3ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Porth_pin4ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Porth_pin5ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Porth_pin6ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Porth_pin7ctrl = &B0_0_001_000 'Totem (PushPull) + Buskeeper
Porte_dirset = &B1111_1111 : Porte = &B1111_0000 ' CS3, CS2, CS1, CS0
Porte_pin0ctrl = &B0_0_000_000 'Totem (PushPull) CS3 ---
Porte_pin1ctrl = &B0_0_000_000 'Totem (PushPull) CS2 ---
Porte_pin2ctrl = &B0_0_000_000 'Totem (PushPull) CS1 ---
Porte_pin3ctrl = &B0_0_000_000 'Totem (PushPull) CS0 SRAM
Porte_pin4ctrl = &B0_0_000_000 'Totem (PushPull)
Porte_pin5ctrl = &B0_0_000_000 'Totem (PushPull)
Porte_pin6ctrl = &B0_0_000_000 'Totem (PushPull)
Porte_pin7ctrl = &B0_0_000_000 'Totem (PushPull)
' EBI-OUT legt die 4 ChipSelect's auf einen anderen Port, damit die Adressleitungen
' A16 bis A21 auf Port-H frei wird.
Ebiout = &B0000_00_11
' XXXX : RESERVED
' -> 00 : EBI Port3 adress output on PORT-F 0..7: SD: 4'h0, A[11:8] - SR or SR-LPC with SD on CS3: A[23:16] - SR NoAle or ALE1: A[15:8]
' 01 : EBI Port3 adress output on PORT-E 0..7: SD: 4'h0, A[11:8] - SR or SR-LPC with SD on CS3: A[23:16] - SR NoAle or ALE1: A[15:8]
' 10 : EBI Port3 adress output on PORT-F 4..7: SD: A[11:8] - SR or SR-LPC with SD on CS3: A[19:16] - SR NoAle or ALE1: ---
' 11 : EBI Port3 adress output on PORT-E 4..7: SD: A[11:8] - SR or SR-LPC with SD on CS3: A[19:16] - SR NoAle or ALE1: ---
' 00 : EBI CS-output on PORT-H 4..7
' 01 : EBI CS-output on PORT-L 4..7
' 10 : EBI CS-output on PORT-F 4..7
' -> 11 : EBI CS-output on PORT-E 4..7
Ebi_ctrl = &B01_00_11_10 'SRAM ALE12, 3Port
' XX : 00: 4 Bit Data Bus
' XX -> : 01: 8 Bit Data Bus
' XX : 10: RESERVED
' XX : 11: RESERVED
' XX -> : 00: LPC-Mode: ALE1
' XX : 01: LPC-Mode: RESERVED
' XX : 10: LPC-Mode: ALE12
' XX : 11: LPC-Mode: RESERVED
' XX : 00: ALE1 - Adressbyte 0 and 1 multiplexed
' XX : 01: ALE2 - Adressbyte 0 and 2 multiplexed
' XX : 10: ALE12- Adressbyte 0,1 and 2 multiplexed
' -> XX : 11: NOALE- No adress multiplexing
' XX: 00: Externer Bus disabled
' XX: 01: 3 Port Control-Bus # Data-Bus # A0:A7 und A8:A15 über ALE1 gemuxt
' -> XX: 10: 4 Port
' XX: 11: 2 Port
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
'ChipSelect0 für 512 KByte SRam
' xxxxxxxx xxxx----
' Bit: 23 bis 12 11 bis 0 nicht verwendet
' | |
Ebi_cs0_baseaddr = &B00010000_00000000 ' Start &H100000 = 1M
' 00000000_00100000_00000000 = &H002000 = 8K
' 00000000_00110000_00000000 = &H003000 = 12K
' 00000000_01000000_00000000 = &H004000 = 16K
' 00000000_10000000_00000000 = &H008000 = 32K
' 00000001_00000000_00000000 = &H010000 = 64K
' 00000010_00000000_00000000 = &H020000 = 128K
' 00000100_00000000_00000000 = &H040000 = 256K
' 00001000_00000000_00000000 = &H080000 = 512K
' -> 00010000_00000000_00000000 = &H100000 = 1M
' 00100000_00000000_00000000 = &H800000 = 2M
' 01000000_00000000_00000000 = &H800000 = 4M
' 10000000_00000000_00000000 = &H800000 = 8M
Ebi_cs0_ctrla = &B0_01011_01 ' Size &H080000 = 512 KB
' X : RESERVED
' XXXXX : AdressBlockSize
' 00000 : 256 Byte
' 00001 : 512 Byte
' 00010 : 1 KByte
' 00011 : 2 KByte
' 00100 : 4 KByte
' 00101 : 8 KByte
' 00110 : 16 KByte
' 00111 : 32 KByte
' 01000 : 64 KByte
' 01001 : 128 KByte
' 01010 : 256 KByte
' -> 01011 : 512 KByte
' 01100 : 1 MByte
' 01101 : 2 MByte
' 00110 : 4 MByte
' 01111 : 8 MByte
' 10000 : 16 MByte
' XX : ChipSelectMode
' 00 : disabled
' -> 01 : Enabled for SRAM
' 10 : Enabled for SRAM LPC (LowPinCount)
' 11 : Enabled for SD-SRAM
Ebi_cs0_ctrlb = &B00000_100 ' je nach Geschwindigkeit des SRam's
' XXXXX : RESERVED
' XXX : Waitstates
' 000 : 0 Waitstates
' 001 : 1 Waitstates
' 010 : 2 Waitstates
' 011 : 3 Waitstates
' -> 100 : 4 Waitstates
' 101 : 5 Waitstates
' 110 : 6 Waitstates
' 111 : 7 Waitstates
'-------------------------------------------------------------------------------
' Nun kann das externe SRam genauso wie das interne SRam angesprochen werden.
' Vorteil: erheblich schneller im Zugriff, wie DRam !!!
' So kann auch Hardware "memory-mapped" eingebunden werden
' oder ein ISA-Bus realisiert werden.
[b:bfbc928b90][color=red:bfbc928b90](BASCOM-AVR version : 2.0.7.7 )[/b:bfbc928b90][/color:bfbc928b90]
↧
BASCOM-AVR : Line Label Best Practices with Include Files : REPLY
I add a good practice :
see the help : "on interrupt"
"Finally some tips :
* when you use a timer interrupt that occurs each 10 uS for example, be sure that the interrupt code can execute in 10 uS. Otherwise you would loose time.
* it is best to set just a simple flag in the interrupt routine and to determine it's status in the main program. This allows you to use the NOSAVE option that saves stack space and program space. You only have to Save and Restore R24 and SREG in that case.
--"
jp :wink:
↧
BASCOM-AVR : Line Label Best Practices with Include Files : REPLY
Using $nocompile bas files is like hiding some knowed code from eyes. Compiler can hide some configurations but with $nocompile You can do more because override this. Eg. for test board I have Mega328p and target device is Mega8 whitch have diferent names for timer registers. In main Bas file I include config for Timer Isr and diferrent connection for Lcd.
[code:1:948b4688eb]$nocompile
#if Atmega328 = 1
Config Timer2 = Timer , Async = Off , Prescale = 256 , Compare_a = Disconnect , Compare_b = Disconnect , Clear Timer = 1
Enable Compare2a : On Compare2a Timer2_isr : Compare2a = 124
Config Lcdpin = Pin , Db4 = Portb.2 , Db5 = Portb.3 , Db6 = Portb.4 , Db7 = Portb.5 , E = Portb.0 , Rs = Portc.0
Config Lcd = 20 * 4
#else
Config Timer2 = Timer , Prescale = 256 , Compare = Disconnect , Clear Timer = 1
Enable Compare2 : On Compare2 Timer2_isr : Compare2 = 124
Config Lcdpin = Pin , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0 , E = Portc.4 , Rs = Portc.5 'mirley UPT M16
Config Lcd = 16 * 2
#endif[/code:1:948b4688eb]
In main declare Const and Include
[code:1:948b4688eb]'$sim ' For the Bascom simulator only
'$regfile = "m328pdef.dat"
$regfile = "m8def.dat"
$crystal = 8000000
$hwstack = 64
$swstack = 64
$framesize = 64
Const Atmega328 = 0
$include "config_lcd_timer.bas"
$include "config_temperatura.bas"
'*********** START **********
Do
'some code
Gosub Temperatura
Loop
'*********** END ************
$include "timer_isr.bas"
$include "temperatura.bas"[/code:1:948b4688eb]
Routines for Timer2_isr and reading dallas You can put in separate bas nocompile files.
[code:1:948b4688eb]
$nocompile
Odmierz2ms:
Timer2 = Presettimer2
If Menu_timeout <> 0 Then Decr Menu_timeout
If Zegarek_licznik <> 0 Then Decr Zegarek_licznik
If Temperatura_timer <> 0 Then Decr Temperatura_timer
If Dth11_timer <> 0 Then Decr Dth11_timer
Incr Minuta
If Minuta = 60000 Then
Minuta = 0
Incr Minuty
End If
Return[/code:1:948b4688eb]
[code:1:948b4688eb]$nocompile
Temperatura:
Disable Interrupts
1wreset
Select Case Ktory_ds
Case 0:
1wwrite &HCC
1wwrite &H44
Case 1:
1wwrite &H55
1wwrite Ds1(1) , 8
1wwrite &HBE
Lsb = 1wread():
Msb = 1wread():
Case 2:
1wwrite &H55
1wwrite Ds2(1) , 8
1wwrite &HBE
Lsb = 1wread():
Msb = 1wread():
End Select
Enable Interrupts
If Ktory_ds > 0 Then
T(ktory_ds) = Msb * 256
T(ktory_ds) = T(ktory_ds) + Lsb
T(ktory_ds) = T(ktory_ds) * 10
T(ktory_ds) = T(ktory_ds) / 16
End If
Incr Ktory_ds
If Ktory_ds = 3 Then Ktory_ds = 0
Return[/code:1:948b4688eb]
If You compile main BAS file compiler test whole project and will tell You if code is no correct or some variable is missing for separate bas file with number of line :D Eg. Error 43 Line 11 File not found Temperatura.bas or Error Line 24 in Temperatura.bas which is added nocompile file.
↧
↧
BASCOM-AVR : i2cslave best practice : NEWTOPIC
Hi All,
I'm currently working on a i2c slave board that supports multiple functions (IRDA data send, IRDA data receive, Read RFID Number, Enable/Disable RFID) and have a few questions about the best way to handle the i2c comms.
I already have the i2cslave lib and can communicate with the slave, that's not my problem. My question is what's the best way to handle the i2c comms at a higher level I need to send a command from the master to the slave, the slave should then act on the command or return data something like:-
for Data to send per IRDA
i2cstart, IRDA Send Command, IRDA to send (X Bytes), i2cstop
Get last data packet received from IRDA
i2cstart, IRDA Receive Command, last IRDA packet received (X Bytes), i2cstop
So for some commands I need to switch from Sending a Byte (Command) to receiving data (last IRDA packet received). Looking at other i2c devices they always seem to use a i2crestart to switch from Slave Receiving to i2c Slave sending. So my question is if the i2crestart really necessary? I'm controlling both ends of the i2c bus and don't need compatibility with other systems so I can program it as I want.
Regards
Ian Dobson
[b:613e81dea9][color=red:613e81dea9](BASCOM-AVR version : 2.0.7.7 )[/b:613e81dea9][/color:613e81dea9]
↧
BASCOM-ARDUINO : Some Arduino (hardware) Tips : NEWTOPIC
To help avoid losing hair I recommend wearing a helmet (joking!!)
I thought I share some Hardware issues I came across while bashing my head on the wall a few times.
1) If you are going to power your Arduino via USB power watch out how much
current you are going to consume especially when using a Shield(s).
Use a good quality USB cable (not those thin cables) but if in doubt if you are not sure
about exceeding the current don't waste your time, use a descent clean Power supply which
will save you many hours of fustration !.
2) Be warned, at times Headers can cause some problems, some are Brass, some gold plated
and some are rubbish. Occasionally use some good electronics cleaner (spray) and give the Pins/Sockets a
clean.
3)Make sure if you use a Breadboard its fairly new and has good contacts.
4) If using cable male/female jumpers use a descent gauge wire (but not too stiff).
BTW Excellent new Forum Section added !
↧
BASCOM-AVR : i2cslave best practice : REPLY
Hi,
To answer my own question you need to use :
i2cstart, Write "Write Addres", Write Command, i2crepstart, Write "Read Address", Read Bytes, i2cstop
The i2cslave lib needs to see the read address to work.
Regards
Ian Dobson
↧