a) you need to use the /SS pin for INT-driven SPI slave (see Datasheet)
b) you should not use "NOSAVE" if you plan to use BASCOM-Statements in your ISR. You can never be shure what registers your BASCOM statements are using and that the register usage will remain the same after a BASCOM update or when changing the controller type.
c) you should not use BIT vars in isr for flags, use BYTE instead. Otherwise you need to encapsulate every use of every BITVAR in main loop like
[code:1:a9e82dad93]disable interrupts
if BITVAR = 1 then
BITVAR = 0
end if
enable interrupts
[/code:1:a9e82dad93]
because other BIT vars can be corrupted by the isr.
↧
BASCOM-AVR : SPI slave IRQ doesn't work : REPLY
↧
BASCOM-AVR : Questions regardling Structures, overlays and arrays : REPLY
Hi all,
@ Mark - that will be a really cool addition!
@MWS the overlay is for a single word length, not all of them. It is for an array holding 20 descrete addresses each of 2 bytes.
For example,
Tx_Cmd_Wireless_Addr(1) = &hCDEF
The string is to hold the 4 characters 'CDEF' in this case.
Tim
↧
↧
BASCOM-AVR : Questions regardling Structures, overlays and arrays : REPLY
You have a serious misunderstanding if you think a 4 character string overlayed onto a word will hold the characters 'CDEF' when the value of the word is &HCDEF.
↧
BASCOM-AVR : Questions regardling Structures, overlays and arrays : REPLY
HI Adrian,
That was exactly why I posted the question! Normally the overlay would cover the entire 80 bytes (+1) for the string overlay. So how to do it using just 1 element of the word array??? The only other way I could think of was to have a temp word variable, and overlay that. But that also makes for a lot of manipulation. So was looking for the correct and better way.
Tim
↧
BASCOM-AVR : Questions regardling Structures, overlays and arrays : REPLY
No Tim,
You still have it wrong. If you have a word ( 2 bytes ) with value &hCDEF, then there is no direct way using an overlay that you will ever see the representation of its value as a (4 byte) string 'CDEF'. The only way to get that is to do
Dim MyString as string * 4
Dim myWord as word
MyString = hexval(myWord )
which invokes a routine to convert a word value into its (hex) string representation.
Think of the degenerate case where the word value is &h0000 ( ie binary zero ). Then any sort of overlay would put two nulls ( binary zero ) into the first two bytes of the string. But no string can ever contain a null, since that is the string ender character.
The string representation of a binary zero word would be '0000', which is 4 characters of value 48 decimal ( &h30 ).
Get it ?
↧
↧
BASCOM-AVR : Questions regardling Structures, overlays and arrays : REPLY
Hi Adrian,
I believe I can get a handle on it. Thank you for your time and detailed explanation/education.
Tim
↧
BASCOM-AVR : FT800 : NEWTOPIC
As you might know, PeterM made it his mission to write support for the FTDI FT800 graphic chip.
Peter wrote a bascom library in the form of include files and created reusable functions and procedures. I think he spend a small fortune talking to FTDI support to clear up issues.
He also converted a lot of arduino samples into bascom.
When everything worked i converted the code into a special FT800 library and some compiler statements/functions were added, and in the process some nice features were added to the compiler as well.
At this stage Peter is writing the help which is a lot of work since there are really a lot and i mean a lot! of subs/functions.
Since some of you want to experiment with FT800 i created a beta version. You can get this by writing to support. You must have a registered bascom version in order to get the beta.
You really should start to read the ftdi pdf files/documentation. While i did work hard on this project the last weeks, i am not an expert. In fact, i still need to study everything myself!
That might sound odd but when you see the demo code below you might understand it. :D
Peter might have time to answer questions. But otherwise you need to wait till the official release which should be available this month too.
[code:1:3f89ab99b0]' Demo Set 0
' FT800 platform.
' Original code http://www.ftdichip.com/Support/SoftwareExamples/EVE/FT800_SampleApp_1.0.zip
' Requires Bascom 2.0.7.7 beta or greater
$Regfile = "M328pdef.dat"
$Crystal = 8000000
$Baud = 19200
$HwStack = 80
$SwStack = 80
$FrameSize = 350
$NOTYPECHECK
Config ft800=spi , ftsave=0, ftdebug=0
Config Base = 0
Config Submode = New
Config Spi = Hard, Interrupt = Off, Data_Order = Msb, Master = Yes, Polarity = Low, Phase = 0, Clockrate = 4, Noss = 1
SPSR = 1 ' Makes SPI run at double speed
ft800_CS Alias Portb.2
Config ft800_CS = Output
ft800_CS = 1
ft800_Pd Alias PortB.0
Config ft800_Pd = Output
ft800_Pd = 1
Declare Sub Screen (ByVal Characters As String)
Declare Sub Points
Declare Sub Line_s
Declare Sub Rectangles
Declare Sub Bitmap
Declare Sub BitmapPalette
Declare Sub Fonts
Declare Sub Text_8x8
Declare Sub Text_VGA
Declare Sub Bar_Graph
Declare Sub LineStrips
Declare Sub EdgeStrips
Declare Sub Scissor
Declare Sub Polygon
Declare Sub Cube
Declare Sub Ball_Stencil
Declare Sub FtdiString
Declare Sub StreetMap
Declare Sub AdditiveBlendText
Declare Sub MacroUsage
Declare Sub AdditiveBlendPoints
Declare Function Lerp (ByVal t As Single, ByVal a As Single, ByVal b As Single) As Long
Declare Function smoothlerp (ByVal t As Single, ByVal a As Single, ByVal b As Single) As Single
$Include "XXFT800.inc"
$Include "XXFT800_Functions.inc"
Spiinit
Dim Header_Format(3) As Byte
Dim Header_Width(3) As Integer
Dim Header_Height(3) As Integer
Dim Header_Stride(3) As Integer
Dim Header_Arrayoffset(3) As Long
Header_Format(0 + _base) = RGB565
Header_Width(0+_base) = 40
Header_Height(0+_base) = 40
Header_Stride(0+_base) = 80
Header_Arrayoffset(0+_base) = 0
Header_Format(1+_base) = PALETTED
Header_Width(1+_base) = 40
Header_Height(1+_base) = 40
Header_Stride(1+_base) = 40
Header_Arrayoffset(1+_base) = 0
Header_Format(2+_base) = PALETTED
Header_Width(2+_base) = 480
Header_Height(2+_base) = 272
Header_Stride(2+_base) = 480
Header_Arrayoffset(2+_base) = 0
' Type FT_Gpu_Fonts_t
' FT800 font table structure
' Font table address in ROM can be found by reading the address from 0xFFFFC location.
' 16 font tables are present at the address read from location 0xFFFFC
' Width of each character font from 0 to 127
Dim FontWidth (Ft_Numchar_Per_Font) As Byte
' Bitmap format of font wrt bitmap formats supported by FT800 - L1, L4, L8
Dim FontBitmapFormat As Dword
' Font line stride in FT800 ROM
Dim FontLineStride As Dword
' Font width in pixels
Dim FontWidthInPixels As Dword
' Font height in pixels
Dim FontHeightInPixels As Dword
' Pointer to font graphics raw data
Dim PointerToFontGraphicsData As Dword
Dim Display_fontstruct As Byte At FontWidth(_base) Overlay
if FT800_Init()=1 Then END ' Initialise the FT800
'<< Un-Rem any of the demo's, compile and run ! >>
'------------------------------
' Set 0 Demo's
' Unremark one or more demos and compile
'------------------------------
Screen "Set0 START"
' Points
' Line_s
' Rectangles
' Bitmap
' BitmapPalette
' Fonts
' Text_8x8
' Text_VGA
' Bar_graph
' LineStrips
' EdgeStrips
' Scissor
' Polygon
' Cube
' Ball_Stencil
' FtdiString
' StreetMap
' AdditiveBlendText
' MacroUsage
' AdditiveBlendPoints ' requires Const Qsincos = 1 in FT800.inc
Screen "Set0 END!"
End
'------------------------------------------------------------------------------------------------------------
Sub Screen (ByVal Characters As String)
'------------------------------------------------------------------------------------------------------------
ClearColorRGB &HFF, &HFF, &HFF ' background colour
Clear_B 1, 1, 1
ColorRGB &H80, &H80, &H00
CmdText FT_DispWidth/2, FT_DispHeight/2, 31, OPT_CENTER, Characters
UpdateScreen
Wait 1
End Sub ' Screen
'------------------------------------------------------------------------------------------------------------
Sub Points
'------------------------------------------------------------------------------------------------------------
' Example code to display few points at various offsets with various colors
' Construct Display List of points
Wr32 RAM_DL + 0 , _ClearColorRGB(128, 128, 128)
Wr32 RAM_DL + 4 , _Clear_B(1,1,1)
Wr32 RAM_DL + 8 , _ColorRGB (128, 0, 0)
Wr32 RAM_DL + 12, _PointSize(5 * 16)
Wr32 RAM_DL + 16, _Begin_G (FTPOINTS)
Wr32 RAM_DL + 20, _VERTEX2F( FT_DispWidth / 5 * 16, FT_DispHeight / 2 * 16)
Wr32 RAM_DL + 24, _ColorRGB (0, 128, 0)
Wr32 RAM_DL + 28, _PointSize (15 * 16)
Wr32 RAM_DL + 32, _VERTEX2F(FT_DispWidth * 2 / 5 * 16, FT_DispHeight / 2 * 16)
Wr32 RAM_DL + 36, _ColorRGB (0, 0, 128)
Wr32 RAM_DL + 40, _PointSize (25 * 16)
Wr32 RAM_DL + 44, _VERTEX2F (FT_DispWidth * 3 / 5 * 16, FT_DispHeight / 2 * 16)
Wr32 RAM_DL + 48, _ColorRGB (128, 128, 0)
Wr32 RAM_DL + 52, _PointSize (35 * 16)
Wr32 RAM_DL + 56, _VERTEX2F (FT_DispWidth * 4 / 5 * 16, FT_DispHeight / 2 * 16)
Wr32 RAM_DL + 60, _Display_E() ' display the image
' Do a swap
DLSwap
Wait 1
End Sub ' Points
'------------------------------------------------------------------------------------------------------------
Sub Line_s
'------------------------------------------------------------------------------------------------------------
ClearScreen ' Always use this on your Second line
ColorRGB 128, 0, 0
LineWidth 5 * 16
Begin_G LINES
Vertex2F (FT_DispWidth / 4) * 16, (FT_DispHeight - 25) / 2 * 16
Vertex2F (FT_DispWidth / 4) * 16, (FT_DispHeight + 25) / 2 * 16
ColorRGB 0, 128, 0
LineWidth 10 * 16
Vertex2F (FT_DispWidth * 2) / 4 * 16, (FT_DispHeight - 40) / 2 * 16
Vertex2F (FT_DispWidth * 2) / 4 * 16, (FT_DispHeight + 40) / 2 * 16
ColorRGB 128, 128, 0
LineWidth 20 * 16
Vertex2F (FT_DispWidth * 3) / 4 * 16, (FT_DispHeight - 55) / 2 * 16
Vertex2F (FT_DispWidth * 3) / 4 * 16, (FT_DispHeight + 55) / 2 * 16
UpdateScreen
Wait 1
End Sub ' Lines
'------------------------------------------------------------------------------------------------------------
Sub Rectangles
'------------------------------------------------------------------------------------------------------------
ClearScreen ' Always use this on your Second line
ColorRGB 0, 0, 128
LineWidth 1 * 16 ' LINE_WIDTH is used for corner curvature
Begin_G RECTS
Vertex2F ((FT_DispWidth/4) - 2) * 16, ((FT_DispHeight - 25)/2) * 16
Vertex2F ((FT_DispWidth/4) + 2) * 16, ((FT_DispHeight + 25)/2) * 16
ColorRGB 0, 128, 0
LineWidth 5 * 16
Vertex2F ((FT_DispWidth * 2) / 4 - 5) * 16, (FT_DispHeight - 40) / 2 * 16
Vertex2F ((FT_DispWidth * 2) / 4 + 5) * 16, (FT_DispHeight + 40) / 2 * 16
ColorRGB 128, 128, 0
LineWidth 10 * 16
Vertex2F ((FT_DispWidth * 3) / 4 - 10) * 16, (FT_DispHeight - 55) / 2 * 16
Vertex2F ((FT_DispWidth * 3) / 4 + 10) * 16, (FT_DispHeight + 55) / 2 * 16
UpdateScreen
Wait 1
End Sub ' Rectangles
'------------------------------------------------------------------------------------------------------------
Sub Bitmap
'------------------------------------------------------------------------------------------------------------
Local BMoffsetx As Integer
Local BMoffsety As Integer
Local Ln1 As Dword
Local Ln2 As Dword
' Copy raw data into address 0 followed by generation of bitmap
TempDW = Loadlabel(Bitmap_RawData)
RdFlash_WrFT800 RAM_G, TempDW , Header_Stride(0+_base) * Header_Height(0+_base)
ClearScreen
ColorRGB 255, 255, 255
BitmapSource RAM_G
BitmapLayout Header_Format(0+_base), Header_Stride(0+_base), Header_Height(0+_base)
BitmapSize NEAREST, Border, Border, Header_Width(0+_base), Header_Height(0+_base)
Begin_G BITMAPS ' start drawing bitmaps
Const AW = (FT_DispWidth / 4)
Ln1 = Header_Width(0+_base) / 2
Const AX = FT_DispHeight / 2
Ln2 = Header_Height(0+_base) / 2
BMoffsetx = AW - Ln1
BMoffsety = AX - Ln2
Vertex2II BMoffsetx, BMoffsety, 0, 0
ColorRGB 255, 64, 64 ' red At (200, 120)
Const AY = FT_DispWidth * 2 / 4
Const AZ = FT_DispHeight / 2
BMoffsetx = AY - Ln1
BMoffsety = AZ - Ln2
Vertex2II BMoffsetx, BMoffsety, 0, 0
ColorRGB 64, 180, 64 ' green At (216, 136)
BMoffsetx = BMoffsetx + Ln1
BMoffsety = BMoffsety + Ln2
Vertex2II BMoffsetx, BMoffsety, 0, 0
ColorRGB 255, 255, 64 ' transparent yellow At (232, 152)
Color_A 150
BMoffsetx = BMoffsetx + Ln1
BMoffsety = BMoffsety + Ln2
Vertex2II BMoffsetx, BMoffsety, 0, 0
Color_A 255
ColorRGB 255, 255, 255
Vertex2F -10 * 16, -10 * 16 'For -ve coordinates use vertex2f instruction
UpdateScreen
Wait 1
End Sub ' Bitmap
'------------------------------------------------------------------------------------------------------------
Sub BitmapPalette
'------------------------------------------------------------------------------------------------------------
Local BMoffsetx As Integer
Local BMoffsety As Integer
Local Ln1 As Dword
Local Ln2 As Dword
TempDW = Loadlabel(paletteraw)
RdFlash_WrFT800 RAM_G, TempDW , Header_Stride(1+_base) * Header_Height(1+_base)
TempDW = Loadlabel(paletteLUT)
RdFlash_WrFT800 RAM_PAL, TempDW , 1022
ClearScreen
ColorRGB 255, 255, 255
BitmapSource RAM_G
BitmapLayout Header_Format(1+_base), Header_Stride(1+_base), Header_Height(1+_base)
BitmapSize NEAREST, Border, Border, Header_Width(1+_base), Header_Height(1+_base)
Begin_G BITMAPS ' start drawing bitmaps
Const DA = FT_DispWidth / 4
Ln1 = Header_Width(1+_base) / 2
Const DB = FT_DispHeight / 2
Ln2 = Header_Height(1+_base) / 2
BMoffsetx = DA - Ln1
BMoffsety = DB - Ln2
Vertex2II BMoffsetx, BMoffsety, 0, 0
UpdateScreen
Wait 1
End Sub ' BitmapPalette
'------------------------------------------------------------------------------------------------------------
Sub Fonts
'------------------------------------------------------------------------------------------------------------
' Inbuilt Font example For proportionate And non proportionate Text - hello world
Local B As Byte
Local i As byte
Local j As byte
Local hoffset As word
Local voffset As word
Local stringlen As byte
Local FontTableAddress As Dword
Local Display_string As String * 20
Display_string = "Hello World"
hoffset = FT_DispWidth - 100
hoffset = hoffset / 2
voffset = FT_DispHeight / 2
' Read the Font address From &HFFFFC location
FontTableAddress = Rd32(&HFFFFC)
stringlen = Len(Display_string)
For i = 0 To 15
' Read the Font table From hardware
TempDW = i * FT_FONT_TABLE_SIZE
TempDW = TempDW + FontTableAddress
RdFT800_WrMem TempDW, Display_fontstruct, FT_FONT_TABLE_SIZE
Clear_B 1, 1, 1 ' Clear Screen
ColorRGB 255, 255, 255 ' Clear Screen
' Display String At the center Of Display
Begin_G BITMAPS
hoffset = FT_DispWidth - 120
hoffset = hoffset / 2
voffset = FT_DispHeight - FontHeightInPixels
voffset = voffset / 2
' Display hello world by offsetting wrt char Size
For j = 1 To stringlen
B = Asc(Display_string, j)
Vertex2II hoffset, voffset, i + 16, B
hoffset = hoffset + FontWidth(B+_base)
Next j
UpdateScreen
Wait 1
Next i
End Sub ' Fonts
'------------------------------------------------------------------------------------------------------------
Sub Text_8x8
'------------------------------------------------------------------------------------------------------------
' Display text8x8 Of abcdefgh
Local Text_Array As String * 10
Local String_size As Long
' Write the Data into RAM_G
Text_Array = "abcdefgh"
String_size = Len(Text_Array)
RdMem_WrFT800 RAM_G, Text_Array, String_size
ClearScreen
BitmapSource RAM_G
BitmapLayout TEXT8X8, 8 , 1 ' L1 format, Each Input Data element is in 1 byte size
BitmapSize NEAREST, Border, REPEAT, 8 * 8, 8 * 2 ' Output Is 8x8 format - draw 8 characters In horizontal repeated In 2 Line
Begin_G BITMAPS
' Display Text 8x8 At hoffset, voffset location
VerteX2F 16 * 16, 16 * 16
BitmapLayout TEXT8X8, 4, 2 ' L1 format And Each datatype Is 1 Byte Size
BitMapSize NEAREST, REPEAT, Border, 8 * 16, 8 * 2 ' Each character Is 8x8 In Size - so draw 32 characters In horizontal And 32 characters In vertical
VerteX2F (FT_DispWidth / 2) * 16, (FT_DispHeight / 2) * 16
UpdateScreen
Wait 1
End Sub ' Text_8x8
'------------------------------------------------------------------------------------------------------------
Sub Text_VGA
'------------------------------------------------------------------------------------------------------------
' Display textVGA Of Random values
' Write the Data into RAM_G
Local String_size As Long
Local i As Long
Local Char As Dword
Dim Text_Array(320) As Byte
For i = 0 To 319
Text_Array(i+_base) = Rnd(255)
Next i
'Char = VarPtr(Text_Array(0+_base))
String_size = 320
RdMem_WrFT800 RAM_G, Text_Array(_base), String_size
ClearScreen
BitmapSource RAM_G
' mandatory For textvga As background Color Is also one Of the parameter In textvga format
BlendFunc ONE, ZERO
'draw 8x8
BitmapLayout TEXTVGA, 2 * 4, 8 'L1 format, but Each Input Data element is of 2 bytes in size
BitmapSize NEAREST, Border, Border, 8 * 8, 8 * 8 'Output Is 8x8 format - draw 8 characters In horizontal And 8 vertical
Begin_G BITMAPS
VerteX2F 32 * 16, 32 * 16
End_G
'draw textvga
BitMapLayout TEXTVGA, 2 * 16, 8 'L1 format but Each datatype Is 16Bit Size
BitmapSize NEAREST, Border, REPEAT, 8 * 32, 8 * 32 '8 Pixels per character And 32 rows/colomns
Begin_G BITMAPS
' Display textvga At hoffset, voffset location
Vertex2F (FT_DispWidth / 2) * 16, (FT_DispHeight / 2) * 16
End_G
UpdateScreen
Wait 1
End Sub ' Text_VGA
'------------------------------------------------------------------------------------------------------------
Sub Bar_Graph
'------------------------------------------------------------------------------------------------------------
' Write the Data into RAM_G
Local String_size As Long
Local i As Long
Local tmpval As Long
Local tmpidx As Long
Local tmpL1 As Long
Local tmpL2 As Long
Dim Y_Array(512) As Byte
For i = 0 To 511
Y_Array(i+_base) = Rnd(128) + 64 'within range
Next i
String_size = 512
RdMem_WrFT800 RAM_G, Y_Array(_base), String_size
ClearColorRGB 255, 255, 255
Clear_B 1, 1, 1
BitmapSource RAM_G
BitmapLayout BARGRAPH, 256, 1
ColorRGB 128, 0, 0
BitmapSize NEAREST, Border, Border, 256, 256
Begin_G BITMAPS
' Display Text 8x8 At hoffset, voffset location
Vertex2II 0, 0, 0, 0
Vertex2II 256, 0, 0, 1
UpdateScreen
' Download the DL into DL RAM
Wait 1
For i = 0 To 512
' tmpval = 128 + (i/3 * qsin(-65536 * i / 48 )) / 65536
tmpidx = i
tmpL1 = -65536 * i
tmpL1 = tmpL1 /48
tmpL2 = qsin(tmpL1)
tmpL1 = i/3
tmpL1 = tmpL1 * tmpL2
tmpL1 = tmpL1 / 65536
tmpval = tmpL1 + 128
Y_Array(i+_base) = tmpval And &Hff
Next i
String_size = 512
RdMem_WrFT800 RAM_G, Y_Array(_base), String_size
Wait 1
Clear_B 1, 1, 1 ' Clear Screen
BitmapSource RAM_G
BitmapLayout BARGRAPH, 256, 1
BitmapSize NEAREST, Border, Border, 256, 256
Begin_G BITMAPS
ColorRGB 255, 0, 0
' Display bargraph At hoffset, voffset location
Vertex2II 0, 0, 0, 0
Vertex2II 256, 0, 0, 1
ColorRGB 0, 0, 0
Vertex2II 0, 4, 0, 0
Vertex2II 256, 4, 0, 1
UpdateScreen
Wait 1
End Sub ' Bar_Graph
'------------------------------------------------------------------------------------------------------------
Sub LineStrips
'------------------------------------------------------------------------------------------------------------
ClearColorRGB 5, 45, 10
ColorRGB 255, 168, 64
Clear_B 1 ,1 ,1
Begin_G LINE_STRIP
Vertex2F 16 * 16, 16 * 16
Vertex2F (FT_DispWidth * 2 /3) * 16, (FT_DispHeight * 2 / 3) * 16
Vertex2F (FT_DispWidth - 80) * 16, (FT_DispHeight - 20) * 16
UpdateScreen
Wait 1
End Sub ' LineStrips
'------------------------------------------------------------------------------------------------------------
Sub EdgeStrips
'------------------------------------------------------------------------------------------------------------
ClearColorRGB 5, 45, 10
ColorRGB 255, 168, 64
Clear_B 1 ,1 ,1
Begin_G EDGE_STRIP_R
Vertex2F 16 * 16, 16 * 16
Vertex2F (FT_DispWidth * 2 / 3) * 16, (FT_DispHeight * 2 / 3) * 16
Vertex2F (FT_DispWidth - 80) * 16, (FT_DispHeight - 20) * 16
UpdateScreen
Wait 1
End Sub ' EdgeStrips
'------------------------------------------------------------------------------------------------------------
Sub Scissor
'------------------------------------------------------------------------------------------------------------
Clear_B 1,1,1
ScissorXY 40, 20 ' Scissor rectangle top Left At (40, 20)
ScissorSize 40, 40 ' Scissor rectangle Is 40 x 40 Pixels
ClearColorRGB 255, 255, 0 ' CLEER To yellow
Clear_B 1, 1, 1
UpdateScreen
Wait 1
End Sub ' Scissor
'------------------------------------------------------------------------------------------------------------
Sub Polygon
'------------------------------------------------------------------------------------------------------------
Clear_B 1, 1, 1 ' CLear Screen
ColorRGB 255, 0, 0
StencilOP Incrx, Incrx
ColorMask 0,0,0,0 'mask All the colors
Begin_G EDGE_STRIP_L
Vertex2II FT_DispWidth / 2, FT_DispHeight / 4 , 0, 0
Vertex2II FT_DispWidth * 4 / 5, FT_DispHeight * 4 / 5, 0, 0
Vertex2II FT_DispWidth / 4, FT_DispHeight / 2 , 0, 0
Vertex2II FT_DispWidth / 2, FT_DispHeight / 4, 0, 0
End_G
ColorMask 1,1,1,1 'Enable All the colors
StencilFunc EQUAL,1,255
Begin_G EDGE_STRIP_L
Vertex2II FT_DispWidth, 0, 0, 0
Vertex2II FT_DispWidth, FT_DispHeight,0,0
End_G
' Draw Lines At the BORDERs To make sure anti aliazing Is also done
StencilFunc ALWAYS, 0, 255
LineWidth 1 * 16
ColorRGB 0, 0, 0
Begin_G Lines
Vertex2II FT_DispWidth / 2, FT_DispHeight / 4, 0, 0
Vertex2II (FT_DispWidth * 4) / 5, (FT_DispHeight * 4) /5, 0, 0
Vertex2II (FT_DispWidth * 4) / 5, (FT_DispHeight * 4) /5, 0, 0
Vertex2II FT_DispWidth / 4, FT_DispHeight / 2, 0, 0
Vertex2II FT_DispWidth / 4, FT_DispHeight / 2, 0, 0
Vertex2II FT_DispWidth / 2, FT_DispHeight / 4, 0, 0
End_G
UpdateScreen
Wait 1
End Sub ' Polygon
'------------------------------------------------------------------------------------------------------------
Sub Cube
'------------------------------------------------------------------------------------------------------------
Local cnt As Byte
Local F0 As Integer, F1 As Integer, F2 As Integer, F3 As Integer, F4 As Integer, F5 As Integer, F6 As Integer
Local x As Long, y As Long, i As Long, z As Long, f As Long, g As Long
Local xoffset As Integer, yoffset As Integer, CubeEdgeSz As Integer
Dim point(30) As Long
Dim colorsA(3) As Word
Dim colorsB(3) As Word
Dim colorsC(3) As Word
Dim colorsD(3) As Word
Dim colorsE(3) As Word
Dim colorsF(3) As Word
' Color vertices
colorsA(0+_base) = 255
colorsA(1+_base) = 0
colorsA(2+_base) = 0
colorsB(0+_base) = 255
colorsB(1+_base) = 0
colorsB(2+_base) = 150
colorsC(0+_base) = 0
colorsC(1+_base) = 255
colorsC(2+_base) = 0
colorsD(0+_base) = 110
colorsD(1+_base) = 120
colorsD(2+_base) = 110
colorsE(0+_base) = 0
colorsE(1+_base) = 0
colorsE(2+_base) = 255
colorsF(0+_base) = 128
colorsF(1+_base) = 128
colorsF(2+_base) = 0
' Cube dimention Is Of 100 * 100 * 100
CubeEdgeSz = 100
xoffset = FT_DispWidth / 2
xoffset = xoffset - CubeEdgeSz
yoffset = FT_DispHeight - CubeEdgeSz
yoffset = yoffset / 2
' xy plane(front)
point(0+_base) = _Vertex2F(xoffset * 16, yoffset * 16)
F0 = xoffset + CubeEdgeSz
F1 = yoffset + CubeEdgeSz
point(1+_base) = _Vertex2F(F0 * 16, yoffset * 16)
point(2+_base) = _Vertex2F(F0 * 16, F1 * 16)
point(3+_base) = _Vertex2F(xoffset * 16, F1 * 16)
point(4+_base) = point(0+_base)
'yz plane (Left)
F2 = CubeEdgeSz / 2
x = xoffset + F2 ' xoff+w/2
y = yoffset - F2 ' yoff-h/2
F3 = y + CubeEdgeSz
point(5+_base) = point(0+_base)
point(6+_base) = _Vertex2F(x * 16, y * 16)
point(7+_base) = _Vertex2F(x * 16, F3 * 16)
point(8+_base) = point(3+_base)
point(9+_base) = point(5+_base)
'xz plane(top)
F4 = x + CubeEdgeSz
point(10+_base) = point(0+_base)
point(11+_base) = point(1+_base)
point(12+_base) = _Vertex2F( F4 * 16, y * 16)
point(13+_base) = point(6+_base)
point(14+_base) = point(10+_base)
'xz plane(bottom)
point(15+_base) = point(3+_base)
point(16+_base) = point(2+_base)
point(17+_base) = _Vertex2F(F4 * 16, F3 * 16)
point(18+_base) = point(7+_base)
point(19+_base) = point(15+_base)
'yz plane (Right)
point(20+_base) = point(2+_base)
point(21+_base) = point(17+_base)
point(22+_base) = point(12+_base)
point(23+_base) = point(1+_base)
point(24+_base) = point(20+_base)
'yz plane (back)
point(25+_base) = point(6+_base)
point(26+_base) = point(7+_base)
point(27+_base) = point(17+_base)
point(28+_base) = point(12+_base)
point(29+_base) = point(25+_base)
Clear_B 1, 1, 1
LineWidth 16
ClearColorRGB 255, 255, 255
Clear_B 1, 1, 1
ColorRGB 255, 255, 255
' Draw a cube
StencilOP Incrx, Incrx
Color_A 192
For z = 0 To 5
Clear_B 0, 1, 1 ' Clear Stencil buffer
ColorMask 0, 0, 0, 0 ' Mask All the colors And draw one surface
StencilFunc ALWAYS, 0, 255 ' Stencil Function To increment All the values
Begin_G EDGE_STRIP_L
For i = 0 To 4
cnt = z * 5
cnt = cnt + i
Cmd32 point(cnt+_base)
Next
End_G
' Set the Color And draw a strip
ColorMask 1, 1, 1, 1
StencilFunc EQUAL, 1 , 255
Select Case z
Case 0
ColorRGB colorsA(0+_base), colorsA(1+_base), colorsA(2+_base)
Case 1
ColorRGB colorsB(0+_base), colorsB(1+_base), colorsB(2+_base)
Case 2
ColorRGB colorsC(0+_base), colorsC(1+_base), colorsC(2+_base)
Case 3
ColorRGB colorsD(0+_base), colorsD(1+_base), colorsD(2+_base)
Case 4
ColorRGB colorsE(0+_base), colorsE(1+_base), colorsE(2+_base)
Case 5
ColorRGB colorsF(0+_base), colorsF(1+_base), colorsF(2+_base)
End Select
F5 = CubeEdgeSz * 2
F6 = CubeEdgeSz * 2
Begin_G RECTS
Vertex2II xoffset, 0, 0, 0
Vertex2II xoffset + F5, yoffset + F6, 0, 0
End_G
Next
UpdateScreen
Wait 1
End Sub ' Cube
'------------------------------------------------------------------------------------------------------------
Sub Ball_Stencil
'------------------------------------------------------------------------------------------------------------
' First draw points followed by Lines To Create 3d ball kind Of effect
Local xball As Integer, yball As Integer, rball As Integer, numpoints As Integer, numlines As Integer
Local i As Integer, asize As Integer, aradius As Integer, gridsize As Integer
Local asmooth As Long, loopflag As Long, dispa As Long, dispr As Long, displ As Long, Temp1 As Long, Temp2 As Long
Local dispb As Long, xflag As Long, yflag As Long, tempsmooth As Long
Local TempDB As Single
xball = FT_DispWidth/2
yball = 120
rball = FT_DispWidth/8
numpoints = 6
numlines= 8
gridsize= 20
dispr = FT_DispWidth - 10
displ = 10
dispa = 10
dispb = FT_DispHeight - 10
xflag = 1
yflag = 1
Temp1 = dispr - displ
Temp2 = Temp1 Mod gridsize
dispr = dispr - Temp2
Temp1 = dispb - dispa
Temp2 = Temp1 Mod gridsize
dispb = dispb - Temp2
' Write the Play sound
Wr16 Reg_Sound, &H50
loopflag = 100
While loopflag > 0
Temp1 = xball + rball
Temp1 = Temp1 + 2
Temp2 = xball - rball
Temp2 = Temp2 - 2
If Temp1 >= dispr Or Temp2 <= displ Then
xflag = xflag Xor 1
Wr8 Reg_Play, 1
End If
Temp1 = yball + rball
Temp1 = Temp1 + 8
Temp2 = yball - rball
Temp2 = Temp2 - 8
If Temp1 >= dispb Or Temp2 <= dispa Then
yflag = yflag Xor 1
Wr8 Reg_Play, 1
End If
If xflag > 0 Then
xball = xball + 2
Else
xball = xball - 2
End If
If yflag > 0 Then
yball = yball + 8
Else
yball = yball - 8
End If
ClearColorRGB 128, 128, 0
Clear_B 1, 1, 1 ' Clear Screen
StencilOP IncrX, IncrX
ColorRGB 0, 0, 0
' draw grid
LineWidth 16
Begin_G LINES
Temp1 = dispr - displ
Temp1 = Temp1 / gridsize
For i = 0 To Temp1
Temp2 = gridsize * i
Temp2 = Temp2 + displ
Vertex2F Temp2 * 16, dispa * 16
Vertex2F Temp2 * 16, dispb * 16
Next i
Temp1 = dispb - dispa
Temp1 = Temp1 / gridsize
For i = 0 To Temp1
Temp2 = gridsize * i
Temp2 = Temp2 + dispa
Vertex2F displ * 16, Temp2 * 16
Vertex2F dispr * 16, Temp2 * 16
Next i
End_G
ColorMask 0, 0, 0, 0 'mask All the colors
PointSize rball * 16
Begin_G FTPOINTS
Vertex2F xball * 16, yball * 16
StencilOP Incrx, Zero
StencilFunc GEQUAL, 1, 255
' one side points
For i = 1 To numpoints
asize = i * rball
asize = asize * 2
Temp1 = numpoints + 1
asize = asize / Temp1
TempDB = 2 * rball
Temp2 = TempDB
TempDB = asize / TempDB
asmooth = smoothlerp(TempDB, 0, Temp2)
If asmooth > rball Then
'change the offset To -ve
tempsmooth = asmooth - rball
Temp1 = rball * rball
Temp2 = tempsmooth * tempsmooth
Temp1 = Temp1 + Temp2
Temp2 = 2 * tempsmooth
aradius = Temp1 / Temp2
PointSize aradius * 16
Temp1 = xball - aradius
Temp1 = Temp1 + tempsmooth
Vertex2F Temp1 * 16, yball * 16
Else
tempsmooth = rball - asmooth
Temp1 = rball * rball
Temp2 = tempsmooth * tempsmooth
Temp1 = Temp1 + Temp2
Temp2 = 2 * tempsmooth
aradius = Temp1 / Temp2
PointSize aradius * 16
Temp1 = xball+ aradius
Temp1 = Temp1 - tempsmooth
Vertex2F Temp1 * 16, yball * 16
End If
Next i
End_G
Begin_G LINES
' draw Lines - Line should be At least radius diameter
For i = 1 To numlines
Temp1 = i * rball
Temp1 = Temp1 * 2
Temp1 = Temp1 / numlines
asize = Temp1
TempDB = 2 * rball
Temp2 = TempDB
TempDB = asize / TempDB
asmooth = smoothlerp (TempDB, 0 , Temp2)
LineWidth asmooth * 16
Temp1 = xball - rball
Temp2 = yball - rball
Vertex2F Temp1 * 16, Temp2 * 16
Temp1 = xball + rball
Temp2 = yball - rball
Vertex2F Temp1 * 16, Temp2 * 16
Next i
End_G
ColorMask 1, 1, 1, 1 ' Enable All the colors
StencilFunc ALWAYS, 1, 255
StencilOP KEEP, KEEP
ColorRGB 255, 255, 255
PointSize rball * 16
Begin_G FTPOINTS
Temp1 = xball - 1
Temp2 = yball - 1
Vertex2F Temp1 * 16, Temp2 * 16
ColorRGB 0, 0, 0 ' shadow
Color_A 160
Temp1 = xball + 16
Temp2 = yball + 8
Vertex2F Temp1 * 16, Temp2 * 16
Color_A 255
ColorRGB 255, 255, 255
Vertex2F xball * 16, yball * 16
ColorRGB 255, 0, 0
StencilFunc GEQUAL, 1, 1
StencilOP KEEP, KEEP
Vertex2F xball * 16, yball * 16
End_G
UpdateScreen
Waitms 30
Decr loopflag
Wend
End Sub ' Ball_Stencil
'------------------------------------------------------------------------------------------------------------
Function Lerp (ByVal t As Single, ByVal a As Single, ByVal b As Single) As Long
'------------------------------------------------------------------------------------------------------------
Local TempS As Single
TempS = 1 - t
TempS = TempS * a
TempS = TempS + t
TempS = TempS * b
Lerp = TempS
End Function ' Lerp
'------------------------------------------------------------------------------------------------------------
Function smoothlerp (ByVal t As Single, ByVal a As Single, ByVal b As Single) As Single
'------------------------------------------------------------------------------------------------------------
Local TempS As Single
Local TempT As Single
TempS = 3 * t
TempS = TempS * t
TempT = 2 * t
TempT = TempT * t
TempT = TempT * t
smoothlerp = lerp (TempS-TempT, a, b)
End Function ' smoothlerp
'------------------------------------------------------------------------------------------------------------
Sub FtdiString
'------------------------------------------------------------------------------------------------------------
Local hoffset As Integer, voffset As Integer, PointSz As Integer
voffset = FT_DispHeight - 49 '49 Is the Max height of inbuilt Font Handle 31
voffset = voffset / 2
hoffset = FT_DispWidth - 144
hoffset = hoffset / 2
PointSz = 20
hoffset = hoffset + PointSz
Wr32 RAM_DL + 0, _Clear_B(1, 1, 1) ' Clear Screen
Wr32 RAM_DL + 4, _Begin_G(BITMAPS) ' start drawing bitmaps
Wr32 RAM_DL + 8, _Vertex2II (hoffset, voffset, 31, 70) ' ascii F in font 31
hoffset = hoffset + 24
Wr32 RAM_DL + 12, _Vertex2II (hoffset, voffset, 31, 84) ' ascii T
hoffset = hoffset + 26
Wr32 RAM_DL + 16, _Vertex2II (hoffset, voffset, 31, 68) ' ascii D
hoffset = hoffset + 29
Wr32 RAM_DL + 20, _Vertex2II (hoffset, voffset, 31, 73) ' ascii I
Wr32 RAM_DL + 24, _End_G()
Wr32 RAM_DL + 28, _ColorRGB (160, 22, 22) ' change Color To red
Wr32 RAM_DL + 32, _PointSize(PointSz * 16) ' Set Point Size
hoffset = FT_DispWidth - 144
hoffset = hoffset / 2
Wr32 RAM_DL + 36, _Begin_G (FTPOINTS) ' start drawing points
Wr32 RAM_DL + 40, _Vertex2II (hoffset, FT_DispHeight / 2, 0, 0) ' red Point
Wr32 RAM_DL + 44, _End_G()
Wr32 RAM_DL + 48, _Display_E() ' Display the image
DLSwap
Wait 2
End Sub ' FtdiString
'------------------------------------------------------------------------------------------------------------
Sub StreetMap
'------------------------------------------------------------------------------------------------------------
' Call And Function Example - simple graph
ClearColorRGB 236, 232, 224 'light gray
Clear_B 1, 1, 1
ColorRGB 170, 157, 136 'medium gray
LineWidth 63
Call_C 19 ' draw the streets
ColorRGB 250, 250, 250 'white
LineWidth 48
Call_C 19 'draw the streets
ColorRGB 0, 0, 0
Begin_G BITMAPS
Vertex2II 240,91,27,77 'draw 'Main st.' At (240,91)
Vertex2II 252,91,27,97
Vertex2II 260,91,27,105
Vertex2II 263,91,27,110
Vertex2II 275,91,27,115
Vertex2II 282,91,27,116
Vertex2II 286,91,27,46
End_G
Display_E
Begin_G Lines
Vertex2F -160,-20
Vertex2F 320,4160
Vertex2F 800,-20
Vertex2F 1280,4160
Vertex2F 1920,-20
Vertex2F 2400,4160
Vertex2F 2560,-20
Vertex2F 3040,4160
Vertex2F 3200,-20
Vertex2F 3680,4160
Vertex2F 2880,-20
Vertex2F 3360,4160
Vertex2F -20,0
Vertex2F 5440,-480
Vertex2F -20,960
Vertex2F 5440,480
Vertex2F -20,1920
Vertex2F 5440,1440
Vertex2F -20,2880
Vertex2F 5440,2400
End_G
Return_C
UpdateScreen
Wait 2
End Sub ' StreetMap
'------------------------------------------------------------------------------------------------------------
Sub AdditiveBlendText
'------------------------------------------------------------------------------------------------------------
' Usage of Additive Blending - Draw 3 'G's
Clear_B 1, 1, 1 ' Clear Screen
Begin_G BITMAPS
Vertex2II 50, 30, 31, &H47
Color_A 128
Vertex2II 58, 38, 31, &H47
Color_A 64
Vertex2II 66, 46, 31, &H47
End_G
UpdateScreen
Wait 1
End Sub ' AdditiveBlendText
'------------------------------------------------------------------------------------------------------------
Sub MacroUsage
'------------------------------------------------------------------------------------------------------------
' Usage Of Macro
Local xoffset As Long, yoffset As Long, xflag As Long, yflag As Long, flagloop As Long
Local Temp1 As Integer
' Local p_bmhdr As SAMAPP_Bitmap_header_t
xflag = 1
yflag = 1
flagloop = 1
xoffset = FT_DispWidth / 3
yoffset = FT_DispHeight / 2
' First Write a valid Macro instruction into macro0
Wr32 REG_MACRO_0, _Vertex2F(xoffset * 16, yoffset * 16)
TempDW = Loadlabel(Bitmap_RawData)
RdFlash_WrFT800 RAM_G, TempDW, Header_Stride(0+_base) * Header_Height(0+_base)
Clear_B 1, 1, 1 ' Clear Screen
BitmapSource RAM_G
BitmapLayout Header_Format(0+_base), Header_Stride(0+_base), Header_Height(0+_base)
BitmapSize NEAREST, Border, Border, Header_Width(0+_base), Header_Height(0+_base)
Begin_G BITMAPS ' start drawing %BITMAPS
Macro_R 0 ' draw the image At (100,120)
End_G
UpdateScreen
flagloop = 300
While flagloop > 0
Temp1 = xoffset + Header_Width(0+_base)
If Temp1 >= FT_DispWidth Or xoffset <= 0 Then
xflag = xflag Xor 1
End If
Temp1 = yoffset + Header_Height(0+_base)
If Temp1 >= FT_DispHeight Or yoffset <= 0 Then
yflag = yflag Xor 1
End If
If xflag > 0 Then
Incr xoffset
Else
Decr xoffset
End If
If yflag > 0 Then
Incr yoffset
Else
Decr yoffset
End If
' update just the Macro
Wr32 REG_MACRO_0, _Vertex2F(xoffset * 16, yoffset * 16)
Waitms 10
Decr flagloop
Wend
End Sub ' MacroUsage
'------------------------------------------------------------------------------------------------------------
Sub AdditiveBlendPoints
'------------------------------------------------------------------------------------------------------------
' Additive blending Of points - 1000 points
Local i As Long, hoffset As Long, voffset As Long, flagloop As Long ,j As Long
Local hdiff As Long, vdiff As Long, PointSz As Long, t As Long
Local Temp1 As Long, Temp2 As Long, Temp3 As Integer, Temp4 As Integer
PointSz = 4
flagloop = 20
While flagloop > 0
Clear_B 1, 1, 1 ' Clear Screen
ColorRGB 20, 91, 20 ' green Color For additive blending
BlendFunc SRC_ALPHA, ONE 'Input Is Source alpha And destination Is whole Color
PointSize PointSz * 16
Begin_G FTPOINTS
' First 100 Random values
For i = 0 To 99
hoffset = Rnd(FT_DispWidth)
voffset = Rnd(FT_DispHeight)
Vertex2F hoffset * 16, voffset * 16
Next i
' Next 480 are sine values Of two cycles
For i = 0 To 159
' i is x offset, y is sinwave
hoffset = i * 3
Temp1 = FT_DispWidth / 6
Temp2 = -65536 * i
Temp2 = Temp2 / Temp1
Temp1 = qsin(Temp2)
Temp2 = FT_DispHeight / 2
Temp2 = Temp2 * Temp1
Temp2 = Temp2 / 65536
Temp1 = FT_DispHeight / 2
Temp2 = Temp2 + Temp1
voffset = Temp2
Vertex2F hoffset * 16, voffset * 16
For j = 0 To 3
Temp3 = Rnd(24)
hdiff = Temp3 - 12
Temp4 = Rnd(24)
vdiff = Temp4 - 12
Temp1 = hoffset + hdiff
Temp2 = voffset + vdiff
Vertex2F Temp1 * 16, Temp2 * 16
Next
Next
End_G
UpdateScreen
Waitms 10
Decr flagloop
Wend
End Sub ' AdditiveBlendPoints
'------------------------------------------------------------------------------------------------------------
$inc Bitmap_RawData, nosize, "Bitmap_RawData.raw" ' used in SUB Bitmap and SUB MacroUsage
$inc paletteraw, nosize, "lenaface40_palette.raw" ' used in SUB BitmapPalette
$inc paletteLUT, nosize, "lenaface40_palette_LUT.raw" ' used in SUB BitmapPalette[/code:1:3f89ab99b0]
[b:3f89ab99b0][color=red:3f89ab99b0](BASCOM-AVR version : 2.0.7.7 )[/b:3f89ab99b0][/color:3f89ab99b0]
↧
BASCOM-AVR : ollopa's swusb and timers : NEWTOPIC
Hi,
I intent to use a timer (counter, NO INTERRUPT) for a project (remote controller-> USB Keyboard adaptor).
I got
1) USB working (typemessage works)
2) Remote working (I changed from interrupt to no interrupt first, which was the first step to integrate both parts)
but both combined doesnt work, timer1 seems to give unlogical values
Does anyone know whether timer1 or timer0 is used by ollopas library?
[b:179ffc48af][color=red:179ffc48af](BASCOM-AVR version : 2.0.7.6 , Latest : 2.0.7.7 )[/b:179ffc48af][/color:179ffc48af]
↧
BASCOM-AVR : ollopa's swusb and timers : REPLY
[quote:8d4598e2d0]it is not confusing. if I remember it right, Opalla pointed out somewhere that you cannot use own interrupts with his lib. The USB speed is so high and time-critical, that the USB routines must have absolute priority. Using own interrupts, you disturb the USB timing.
You may use timers, but you have to poll them. Own interrupts are forbidden. [/quote:8d4598e2d0]
I read this yesterday..
This Quote is taken from [url=http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=7537&postdays=0&postorder=asc&start=255]here[/url]
↧
↧
BASCOM-AVR : HX711 ADC 24 bits : NEWTOPIC
Hi all,
I hope my question is really new about Chip HX711 ADC 24 bits, in this forum.
I am using ATmega32 MCU with crystal 4Mhz to communicate with HX711 Dual-Channel Weighing Sensor Module, this module image can be found on the internet.
While the HX711 datasheet in http://www.dfrobot.com/image/data/SEN0160/hx711_english.pdf
I am trying to convert from C (page 8th) to Bascom code, but it does not work at all even timing clock is set with different timing.
It means the return value is always 0 (zero).
Can anyone help me, may have a code that has been successfully working?
Thank you in advance.
Original code:
[code:1:b69c597091]
//********************************************************
//*** C Coding ********************************************
//********************************************************
sbit ADDO = P1^5;
sbit ADSK = P0^0;
unsigned long ReadCount(void){
unsigned long Count;
unsigned char i;
ADDO=1;
ADSK=0;
Count=0;
while(ADDO);
for (i=0;i<24;i++){
ADSK=1;
Count=Count<<1;
ADSK=0;
if(ADDO) Count++;
}
ADSK=1;
Count=Count^0x800000;
ADSK=0;
return(Count);
}
[/code:1:b69c597091]
My snippet code conversion:
[code:1:b69c597091]
'********************************************************
'*** Bascom *********************************************
'********************************************************
Adsk Alias Portd.4 'I use pin D.4 as output Clock
Addo Alias Portd.5 'I use pin D.5 as input Databit
Config Adsk = Output
Config Addo = Input
Dim Count As Long
'-------------------------------------------------------------------------------
Function HX711_Read() As Long
'-------------------------------------------------------------------------------
Local I As Byte
'ADDO = 1 'I also give quotation marks at this alternately coz as input, not output
Adsk = 0 'clock LOW
Count = 0 'reset variable
While Addo = 1 'wait until data ready
Wend
'Shiftin ADDO , ADSK , Count , 1 , 24 , 10 --> similar ?
For I = 1 To 24 'channel A, gain 128x
Adsk = 1 'clock HIGH
Shift Count , Left , 1 'shift to left 1 bit
Adsk = 0 'clock LOW
If Addo = 1 Then Incr Count 'give bit 1 for LSB, otherwise 0
Next
Adsk = 1 'clock HIGH
Count = Count Xor &H800000 '0x800000
Adsk = 0 'clock LOW
Hx711_read = Count 'returned value
End Function
[/code:1:b69c597091]
[b:b69c597091][color=red:b69c597091](BASCOM-AVR version : 2.0.7.3 , Latest : 2.0.7.7 )[/b:b69c597091][/color:b69c597091]
↧
BASCOM-AVR : ollopa's swusb and timers : REPLY
Yeah I use no interrupts.
the code looks a bit like this
if pinb.1=0 then
timer0=0
start timer0
do
loop until pinb.1=1
stop timer0
a=timer0
message=str(a)
endif
[code:1:afbb5335e8]
if pinb.1=0 then
timer0=0
start timer0
do
loop until pinb.1=1
stop timer0
a=timer0
message=str(a)
call typemessage(message)
endif
[/code:1:afbb5335e8]
I should get timer values of about 90 something, but i get 1-5. As I said the program using the timers (remote code reader) works fine for my dimmer project...
↧
BASCOM-AVR : ollopa's swusb and timers : REPLY
Looks like I found the issue. If anyone has an idea howto implement this anyway, please let me know!
[code:1:4c21ea3851]
do 'main loop
portb.0=1
Resetcounter = 0
Call Usb_check_reset
Akey = Usb_check_rx()
portb.0=0
.
.
.
.
my code bla bla
poll input
bla bla
loop 'main loop
end
[/code:1:4c21ea3851]
so looks like the portb.0 is high most of the time. So there is a veeery high chance to miss the startbit of the remote transmission.
↧
BASCOM-AVR : ollopa's swusb and timers : REPLY
This is the part that takes up most of the cpu time
[code:1:142cb513b3]
Akey = Usb_check_rx()
[/code:1:142cb513b3]
↧
↧
BASCOM-AVR : HX711 ADC 24 bits : REPLY
Try
[code:1:1a66c78af5]
Addo Alias Pind.5 'I use pin D.5 as input Databit
[/code:1:1a66c78af5]
↧
BASCOM-AVR : Local Variables : NEWTOPIC
I wanted to comment out a sub, and inserted [u:42f057210e]exit sub [/u:42f057210e]as shown below , rather than find, and comment out all of the calls throughout the main code.
The result was that the code crashed about once an hour, and it took me some time to realise why.
The exit sub must go [i:42f057210e]after[/i:42f057210e] the two locals because they must go [i:42f057210e]after[/i:42f057210e] any executable code.
Unfortunately the compliler doesnt recognise 'end sub' as executable code.
[code:1:42f057210e]
sub check_for_ringing()
exit sub 'new line added
local ringvolts as byte
local ringmsg as string*20
code
blah
blah
blah
end sub
[/code:1:42f057210e]
[b:42f057210e][color=red:42f057210e](BASCOM-AVR version : 2.0.7.7 )[/b:42f057210e][/color:42f057210e]
↧
Share your working BASCOM-AVR code here : Library for Nokia16161 display : NEWTOPIC
NOKIA-1616 series color display has resolution 128x160, size 1,8". Controller is SPFD54124B
[URL=http://radikal.ru/fp/6e6949223d1c4aa6a9210810c769ad36][img:cca089d00a]http://s019.radikal.ru/i626/1410/13/84c39e822c25t.jpg[/img:cca089d00a][/URL][URL=http://radikal.ru/fp/89275ba6c4c040e7ba382f7c3b65c9af][img:cca089d00a]http://s020.radikal.ru/i701/1410/38/8c6c5abe8bf1t.jpg[/img:cca089d00a][/URL]
Library works on NOKIA displays:
[b:cca089d00a]100, 101, 112, 113, 1616, 1661, 1662, 1800, 5030с, С1-00, С1-01, С1-02, С1-03, С2-00, X1-01[/b:cca089d00a] (12-pin socket):
[URL=http://radikal.ru/fp/f0870c683360435e813bc780e86f9105][img:cca089d00a]http://s019.radikal.ru/i642/1410/6b/9dff2000e29ft.jpg[/img:cca089d00a][/URL]
And [b:cca089d00a]2865cdma, 5070, 5200, 6060, 6061, 6070, 6080, 6085, 6086, 6101, 6102, 6103, 6125, 6136, 6151, 7360[/b:cca089d00a] (22-pin socket DF23-22):
[URL=http://radikal.ru/fp/d1cb4c9d2c334d6e8d63a7516630c5b7][img:cca089d00a]http://s019.radikal.ru/i607/1410/f6/d541da759663t.jpg[/img:cca089d00a][/URL]
Backlight is 3V or 7V, be careful.
Library has "Portrait" & "Landscape" mode and "Rotate 180°" function.
Example in attachment.
↧
BASCOM-AVR : ollopa's swusb and timers : REPLY
ok
one step further, I was able to block the usb_rx call by using a loop and a counter.
However - the int0 usb_isr takes up just as much time :-))
I think I'll have to use 2 chips and use uart polling...
↧
↧
Share your working BASCOM-AVR code here : Library for UC1608 display : NEWTOPIC
LCD module from [i:14e0683e3b]Displaytech Ltd[/i:14e0683e3b]. View area 92x53mm, resolution 128x240.
[URL=http://radikal.ru/fp/74c4dfd97b494fe582213d1183eabd4b][img:14e0683e3b]http://s020.radikal.ru/i711/1410/30/fed9b3a9c25ft.jpg[/img:14e0683e3b][/URL]
Power & levels are 3,3V. Backlight nominal current is 120mA. I use 3,3V with 1,6 Ohm resistor.
I wrote 3 libraries for SPI & Parallel modes:
[URL=http://radikal.ru/fp/1a67d79537f849c782a903e5ac7f85e1][img:14e0683e3b]http://s020.radikal.ru/i702/1410/59/6d972d8f43cet.jpg[/img:14e0683e3b][/URL][URL=http://radikal.ru/fp/8d0f9db5f315492b87b6ba68fed2a335][img:14e0683e3b]http://s010.radikal.ru/i314/1410/87/66dd0a6ea74bt.jpg[/img:14e0683e3b][/URL][URL=http://radikal.ru/fp/1aabac38f96e4ad6931b9bd7246b9b40][img:14e0683e3b]http://s019.radikal.ru/i611/1410/01/44b6f0edc0cdt.jpg[/img:14e0683e3b][/URL]
In SPI mode "read from display" not supported by UC1608, so no graphics in this mode (dots, lines, boxes, circles) - only text & pictures.
Pictures for this display must be "SED".
Examples & libraries in attachment.
↧
BASCOM-AVR : Local Variables : REPLY
[quote:8e3860e3f9="njepsen"]Unfortunately the compliler doesnt recognise 'end sub' as executable code.[/quote:8e3860e3f9] :?: :?: :?:
I see it as a compiler problem.
As described by the help, the exit sub jumps to a label at the end of the sub, where the Y-pointer is cleaned up.
The problem is: locals are created at the exact line in code.
The procedure is as follows:
For each local a two-byte pointer is created, this pointer is stored indexed by the Y-pointer, while the Y-pointer is decreased by two.
As the sub exits, it assumes an altered Y-pointer and tries to clean up, which is done by increasing the Y-pointer by the same numbers decreased before.
But if preceded by an exit sub, the locals are not created and thus the Y-pointer is not altered at first - but increased after.
At return of the sub, the Y-pointer is messed up and the thing goes nuclear.
Can be fixed, if locals are created in any case, doesn't matter, where they are placed within a sub or function.
↧
BASCOM-AVR : Local Variables : REPLY
I only tumbled to the problem after finally determining that the processor crashed just after the sub that I had killed, had been called. I seemed to remember from somewhere a note that locals must be written "before" executable code. The hour between crashes didnt help.
↧