[quote:cda57859bb="Evert :-)"]It's port not pin
[code:1:cda57859bb]
config portb.4 = output 'ss
CONFIG PortD.6 = OUTPUT 'INT/HOLD
CONFIG PortD.5 = OUTPUT 'CS
[/code:1:cda57859bb][/quote:cda57859bb]
Using [b:cda57859bb]Config[/b:cda57859bb] with the word [b:cda57859bb]Pin[/b:cda57859bb] is equal to [b:cda57859bb]Port[/b:cda57859bb], see the help.
↧
BASCOM-AVR : little help please with hard spi and tpic8101 ic : REPLY
↧
BASCOM-AVR : little help please with hard spi and tpic8101 ic : REPLY
Thanks a lot for the help. I realy must finish this project.
I will paste the code with some commends later
I have check the status for pind6 and pind5 and seems that work But i will try and with port word
What I do is simple according to tpic8101 datasheet
First I drive low the int/hold pin ,pind6
Wait a little 10ns as datasheet write
then i drive low the cs ,pind5
wait again 10ns
after that i send spi , spiout
drive high the cs
wait 10ns
then go to next command with cs low etc
so the program looks like
int/hold ,low
delay
cs ,low
delay
command
cs , high
delay
cs ,low
delay
command
cs,high
delay
.
.
.
.
at finish in/hold drive to high
I have try and with hardware ss
I also try to change the int/hold in each command
It is my first project with spi
so i am little confuse
here are some specs of tpic8101 spi
SPI SPI frequency 5 MHz
t1 Time from CS falling edge to SCLK rising edge 10 ns
t2 Time from CS falling edge to SCLK falling edge 80 ns
t3 Time for SCLK to go high 60 ns
t4 Time for SCLK to go low 60 ns
t5 Time from last SCLK falling edge to CS rising edge 80 ns
t6 Time from SDI valid to falling edge of SCLK 60 ns
t7 Time for SDI valid after falling edge of SCLK 10 ns
t8 Time after CS rises until INT/HOLD to go high 8 ns
t9 Time between two words for transmitting 170 ns
t10 Time for SDO valid after SDI on bus, at VDD = 5 V and load = 20 pF 40 ns
Figure 1. Serial Peripheral Interface (SPI)
↧
↧
BASCOM-AVR : little help please with hard spi and tpic8101 ic : REPLY
[quote:9be464eb1b="petros047"]I have check the status for pind6 and pind5 and seems that work But i will try and with port word[/quote:9be464eb1b]
If that works you have different code than you show, as:
[code:1:9be464eb1b]SET PIND5[/code:1:9be464eb1b]translates to[code:1:9be464eb1b]SBI 0x05,0[/code:1:9be464eb1b]
Back-translated it would read:[code:1:9be464eb1b]Set PortB.0[/code:1:9be464eb1b]
[code:1:9be464eb1b]SET PIND6[/code:1:9be464eb1b]translates to[code:1:9be464eb1b]SBI 0x06,0[/code:1:9be464eb1b]
Back-translated it would read:[code:1:9be464eb1b]Set PinC.0[/code:1:9be464eb1b]
Sure I know, what you want to do, as I've read the circuits data sheet, while you miss the very basics how to ask a forum for help and actually get the desired support.
Absolute minimum is to show your latest updated code, so it's possible to check and fix the errors.
It is surely not acceptable to have a description of code, when the code itself is available.
Maybe I should have used more direct words and simply have told you that [b:9be464eb1b]SET PIND6[/b:9be464eb1b] is utter nonsense.
And btw., the way you try to discuss or solve problems is just not what I consider as expedient, so I'll pull out here.
Your urge for success "I realy must finish this project." seems to me exactly the opposite how you approach it and that won't work.
↧
BASCOM-AVR : little help please with hard spi and tpic8101 ic : REPLY
Ok I paste my update code tonight and fix this errors
sorry for my phrase , realy must finish this project,But in March i wait tuner for my rx7 and i would like to have digital knock monitor :)
Also I forget to mention that I build the project in raster I dont know if that is problem for crystal freq or spi data.
Thank you for your time.
↧
BASCOM-AVR : SSD1306 SPI Oled bgf picture display : REPLY
I should do something else but I could not resist :D
I take code from Arduino section and I mood one routine.
Yo can grab example how BGF can be decoded in basic.
Code and BGF file from this screens attached :D
This can be adapted for testing new displays where libs are not available yet.
Normally columns and rows are counted but here I countdown bytes to write.
[code:1:15b552a69b]'we start reading from point that "Restore Gif" set
Read Height 'sholud be divide by 8 because 8 byte bits
Read Width 'number of colums
Sum = 1024 'can be calculated from the above
Startpoint1: 'if we do some repeats then we back here for new
Read Value 'read first value
Startpoint2:
Read Rle 'read second '
'check if we must repeat somethig (AA means that if next byte <>0
If Rle <> &HAA Then 'no, we must show this byte and read new
I2cwbyte Value
Value = Rle 'save readed value because nex byte can be AA
Decr Sum : If Sum = 0 Then Goto Exit_this
Goto Startpoint2 'back for one byte only
Else
'RLE=AA so we must know how many bytes repeat
Read Repeats
For Y = 1 To Repeats
I2cwbyte Value
Decr Sum
Next
If Sum = 0 Then Goto Exit_this
Goto Startpoint1 'back to top for two new values and skip used AA
End If
Exit_this:[/code:1:15b552a69b]
↧
↧
BASCOM-AVR : little help please with hard spi and tpic8101 ic : REPLY
Here is the update code
I try all the combinations and still not work
$Regfile="m1284pdef.dat"
$Crystal=16000000
$hwstack=40
$swstack=16
$framesize=32
DIM FREQ AS BYTE
DIM GAIN AS BYTE
DIM CH1 AS BYTE
DIM BPASS AS BYTE
DIM TC AS BYTE
FREQ = &B01000101 'CRYSTALL 6MHZ
GAIN = &B10010100 '0.73 DB
CH1 = &B11100000
BPASS = &B00100111 '6.37KHZ
TC = &B11000011 '55US
Waitms 1400
config portb.4 = output 'ss
CONFIG PortD.6 = OUTPUT 'INT/HOLD
CONFIG PortD.5 = OUTPUT 'CS
CONFIG SPI = HARD,INTERRUPT=OFF,DATA_ORDER = MSB,MASTER = YES,POLARITY = LOW , PHASE = 0 ,CLOCKRATE = 4,NOSS = 1
SPIINIT
start:
RESET PORTD.6 ' DRIVE LOW THE INT/HOLD PIN
WAITUS 15
RESET PORTD.5 'DRIVE LOW THE CS PIN
WAITUS 15 'WAIT 15 NS
SPIOUT FREQ,1 'SEND COMMAND
WAITUS 80 'WAIT 80NS
SET PORTD.5 'SET HIGH CS
WAITUS 180 'WAIT FOR NEXT COMMAND
'SET PORTD.6
'WAITUS 10
RESET PORTD.6
WAITMS 15
RESET PORTD.5
WAITUS 15
SPIOUT GAIN,1
WAITUS 80
SET PORTD.5
WAITUS 180
'SET PORTD.6
'WAITUS 10
RESET PORTD.6
WAITMS 15
RESET PORTD.5
WAITUS 15
SPIOUT CH1,1
WAITUS 80
SET PORTD.5
WAITUS 170
'SET PORTD.6
'WAITUS 10
RESET PORTD.6
WAITMS 15
RESET PORTD.5
WAITUS 15
SPIOUT BPASS,1
WAITUS 80
SET PORTD.5
WAITUS 170
'SET PORTD.6
'WAITUS 10
RESET PORTD.6
WAITMS 15
RESET PORTD.5
WAITUS 15
SPIOUT TC,1
WAITUS 80
SET PORTD.5
WAITUS 10
SET PORTD.6
↧
BASCOM-AVR : little help please with hard spi and tpic8101 ic : REPLY
This is little interesting topic for me because I`m mechatronic :D
After configuring port pins as outputs they still have their states - after reset this is low.
So after configuring pins you have Int_hold and Cs_pins in low state and chip listening for commands :D
After configuring pins like Int_hold and Cs_pin should be set to High state.
Next thing - you should know that nanoseconds (ns) are not microseconds (us) :D
I thik build one Sub for all these task is helpful.
All procedures which are repeated you should pack into some functions/subs
And at the end you should stop processor for executing if there is no more other code because it will start from the begining :D
So try like that:
[code:1:e49b048504]$regfile = "m1284pdef.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32
Config Submode = New 'first write a sub then use it in code
Dim Freq As Byte : Freq = &B01000101 'CRYSTALL 6MHZ
Dim Gain As Byte : Gain = &B10010100 '0.73 DB
Dim Ch1 As Byte : Ch1 = &B11100000
Dim Bpass As Byte : Bpass = &B00100111 '6.37KHZ
Dim Tc As Byte : Tc = &B11000011 '55US
Config Portb.4 = Output : Spi_ss Alias Portb.4 : Set Spi_ss
Config Portd.6 = Output : Int_hold Alias Portd.6 : Set Int_hold
Config Portd.5 = Output : Cs_pin Alias Portd.5 : Set Cs_pin
Config Spi = Hard , Interrupt = Off , Data_order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 1
Spiinit
Sub Send(byval Value As Byte)
Reset Int_hold
Reset Cs_pin
Spiout Value , 1
Set Cs_pin
Set Int_hold
End Sub
'sub is ready
'now program start
Call Send(freq)
Call Send(gain)
Call Send(ch1)
Call Send(bpass)
Call Send(tc)
End 'this is important to stop the program
[/code:1:e49b048504]
↧
BASCOM-AVR : little help please with hard spi and tpic8101 ic : REPLY
Thank you for your reply and for your code ,incuding tips :D
unfortunately didnt work yet for some reason i take 5v out no matter what freq I give in input
I try also to your code to reset the int/hold at the begining and after all the commands set it again
I try with noss:1,0 and with high,low polarity
I add only 1us for delay between cs and command and after the command.
Maybe I have to try it in pcb and not in raster maybe I loose spi commands
Thanks for help
↧
BASCOM-AVR : SSD1306 SPI Oled bgf picture display : REPLY
I tested my 1,3' SH1106 display with I2C interfece using this lib:
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=13013&highlight=sh1106
It works fine with software and also hardware I2C (much faster)
Maybe there is an easy way to change the interface from I2C to SPI (preferably hardware SPI) inside this lib?
↧
↧
BASCOM-AVR : Bascom IDE Editor : NEWTOPIC
Hello,
The names of registers are in lower cases in some .bas files but PINx and PORTx always change automatically into upper.
Sometimes they (registers) change into upper in whole file after changing window and return back, but after saving/closing/opening they are lower again
This situation is both with or without .cfg file.
What determine this ?
Regards,
[b:2efd2c53ec][color=red:2efd2c53ec](BASCOM-AVR version : 2.0.7.8 )[/b:2efd2c53ec][/color:2efd2c53ec]
↧
BASCOM-AVR : Bascom IDE Editor : REPLY
the names of registers defined in the DEF file are only shown in capital. the source itself is not altered. so portB will show as PORTB.
the color is determined by the option settings.
when you open a source for a m2561 and then switch the regfile to say tiny13, only the registers known to tiny13 are shown in capital.
when no $regfile is found in the code, the registers can not be colored the right way.
↧
BASCOM-AVR : Bascom IDE Editor : REPLY
Two different files, but almost similar.
Beginning of the first one
[code:1:59c1f3dc2c]$lib "xmega.lib"
$regfile = "xm8e5def.dat"
$crystal = 8000000
$hwstack = 64
$swstack = 40
$framesize = 40
$baud = 4800
Osc_ctrl = &B00_1_0000_0 [/code:1:59c1f3dc2c]
The same part of second file
[code:1:59c1f3dc2c]$lib "xmega.lib"
$regfile = "xm8e5def.dat"
$crystal = 8000000
$hwstack = 64
$swstack = 40
$framesize = 40
'$baud = 4800
OSC_CTRL = &B00_1_0000_0 [/code:1:59c1f3dc2c]
There is $regfile in both and no errors after compiling, so the names are recognized.
↧
BASCOM-AVR : ATTiny104 : NEWTOPIC
Hi Mark,
Any chances of support the ATTiny104 chip in a near future?
A 14 pin device with UART under at 0.64$ (digikey) seems nice. :)
Thanks
[b:4e1fa65335][color=red:4e1fa65335](BASCOM-AVR version : 2.0.7.8 )[/b:4e1fa65335][/color:4e1fa65335]
↧
↧
BASCOM-AVR : ATTiny104 : REPLY
IMHO unlikely. These chips have a crippelt CPU with less instructions and only 16 CPU registers - not enough for BASCOM.
↧
BASCOM-AVR : ATTiny104 : REPLY
Didn't realize that this was a reduced core chip...
Seems that to be supported by some C compliers...
Anyway not for me... :) I'm a BASCOM fan...
64 cents... You get want you pay..
↧
Share your working BASCOM-AVR code here : Library for Nokia1616 display : REPLY
Hello Mrshilov
Do you have any sample for loading "BMP" files from sdcard for this display?
(or any suggestion for doing that?)
Thanks for your great works(we should name you "Display Man"!)
Best regards
↧
BASCOM-AVR : little help please with hard spi and tpic8101 ic : REPLY
Finally solved I post the complete working code so if someone want to drive this ic can use it
The code from EDC , thanks you
$regfile = "m1284pdef.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32
Config Submode = New 'first write a sub then use it in code
Dim Freq As Byte : Freq = &B01000101 'CRYSTALL 6MHZ
Dim Gain As Byte : Gain = &B10010100 '0.73 DB
Dim Ch1 As Byte : Ch1 = &B11100000
Dim Bpass As Byte : Bpass = &B00100111 '6.37KHZ
Dim Tc As Byte : Tc = &B11000011 '55US
Config Portb.4 = Output : Spi_ss Alias Portb.4 : Set Spi_ss
Config Portd.6 = Output : Int_hold Alias Portd.6 : Set Int_hold
Config Portd.5 = Output : Cs_pin Alias Portd.5 : Set Cs_pin
Config Spi = Hard , Interrupt = Off , Data_order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 1
Spiinit
Sub Send(byval Value As Byte)
Reset Int_hold
waitus 1 'need some delay before cs drive low
Reset Cs_pin
waitus 1 'delay before send the command
Spiout Value , 1
waitus 1 'delay before drive high cs
Set Cs_pin
End Sub
'sub is ready
'now program start
Call Send(freq)
Call Send(gain)
Call Send(ch1)
Call Send(bpass)
Call Send(tc)
Set Int_hold
Do
Set Int_hold 'You have to drive high and low the in/hold in order to integrate the input signal and take the output active
Waitus 1500 '
Reset Int_hold
Waitus 1500
Loop
End 'this is important to stop the program
My code work too but is complete mess :D
↧
↧
Share your working BASCOM-AVR code here : Library for Nokia1616 display : REPLY
IMHO it's not good idea - it will be very slow (several seconds per picture). Better use for this LCD with parallel interface. For example NOKIA3110 - the same resolution & controller.
http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=13057&highlight=3110
Example of using SD-card BMP included.
↧
BASCOM-AVR : little help please with hard spi and tpic8101 ic : REPLY
@petros047
- please use the code tags when posting code.
↧
BASCOM-AVR : Help convert Basic to assembler : NEWTOPIC
Can someone help or guide me to how to change this code to assembler? I think the FOR-NEXT loop for Carcount is all that is needed.
[code:1:72d2b51aeb]
$regfile = "xm192a3udef.dat"
$hwstack = 255
$swstack = 255
$framesize = 255
$crystal = 32000000
Config Osc = Disabled , 32mhzosc = Enabled ' 32 MHz enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1 'use 32 MHz
Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled
Config Submode = New
Config Vport0 = B
Lcd_cs Alias Port0.4
Lcd_dc Alias Port0.7
Config Spic = Hard , Master = Yes , Mode = 0 , Data_order = Msb , Clockdiv = Clk2 , Ss = None
Spic_ctrl.7 = 1 : Spic_ctrl.0 = 0 : Spic_ctrl.1 = 0
Spiinit
'Note LCD initialization not shown)
Dim Spi_seq(4) As Byte
Spi_seq(1) = &H2A : Spi_seq(2) = &H2B : Spi_seq(3) = &H2C : Spi_seq(4) = 0
Dim Ss As String * 50 , B_ovr(50) As Byte At Ss Overlay
Dim Fnt_w As Word , Fnt_start As Word
Declare Sub Lcd_text(byval Xoffset As Byte , Byval Yoffset As Byte , Byval Fontset As Byte , Byval Forecolor As Word , Byval Backcolor As Word )
Sub Lcd_text(byval Xoffset As Byte , Byval Yoffset As Byte , Byval Fontset As Byte , Byval Forecolor As Word , Byval Backcolor As Word )
Local Temp As Word 'Dim local the variables
Local A As Word , Pixels As Byte , Carcount As Byte
Local Row As Byte , Byteseach As Byte , Blocksize As Byte , Dummy As Byte
Local Colums As Byte , Columcount As Byte , Rowcount As Byte
Local Xpos As Byte , Ypos As Byte , Pixelcount As Byte , Row_b As Byte
Select Case Fontset
Case 1 : Restore Font6x10
Case 2 : Restore Font12x16
End Select
Read Row : Read Byteseach : Read Blocksize : Read Dummy 'Read the first 4 bytes from the font file
!sts {fnt_start}, R8
!sts {fnt_start + 1}, R9
For Carcount = 1 To Len(ss) 'Loop for the numbers of caracters that must be displayed
Temp = B_ovr(carcount) - 32 'Font files start with caracter 32
Temp = Temp * Blocksize
Fnt_w = Fnt_start + Temp
!lds R8, {fnt_w}
!lds R9, {fnt_w + 1}
Rampz = 1
Colums = Blocksize / Row 'Calculate the numbers of colums
Row_b = Row * 8 'Row is always 8 pixels high = 1 byte, so working with row in steps of 8.
Decr Row_b : Decr Colums
Dummy = Carcount - 1
For Rowcount = 0 To Row_b Step 8 'Loop for numbers of rows
A = Rowcount + Yoffset
For Columcount = 0 To Colums 'Loop for numbers of Colums
Read Pixels
Temp = Dummy * Byteseach
Xpos = Columcount + Temp
Xpos = Xpos + Xoffset
For Pixelcount = 0 To 7 'Loop for 8 pixels to be set or not
Ypos = A + Pixelcount 'Each pixel on his own spot
Pixel = Pixels.pixelcount 'Set the pixel (or not)
If Pixel = 1 Then Pixel = Forecolor Else Pixel = Backcolor
Lcd_cs = 0
Lcd_dc = 0
Spiout Spi_seq(1) , 1
Lcd_dc = 1
Spiout Spi_seq(4) , 1
Spiout Xpos , 1
Lcd_dc = 0
Spiout Spi_seq(2) , 1
Lcd_dc = 1
Spiout Spi_seq(4) , 1
Spiout Ypos , 1
Lcd_dc = 0
Spiout Spi_seq(3) , 1
Lcd_dc = 1
Spiout Colh , 1
Spiout Coll , 1
Lcd_cs = 1
Next Pixelcount
Next Columcount
Next Rowcount
Next Carcount
End Sub
Do
Loop
End[/code:1:72d2b51aeb]
[b:72d2b51aeb][color=red:72d2b51aeb](BASCOM-AVR version : 2.0.7.8 )[/b:72d2b51aeb][/color:72d2b51aeb]
↧