Hi Haris,
Can you explain a bit further, you say [quote:ddedc95fb1]"uC haven't work correctly yet"[/quote:ddedc95fb1]
Is the Micro not working, or is there no display or the I2C RTC no communicating.
Regards
Dean
↧
BASCOM-AVR : (Need Help) : How to configure DS3231 RTC with AVR8535? : REPLY
↧
BASCOM-AVR Old versions : (Need Help) : How to configure DS3231 RTC with AVR8535? : REPLY
Also check the battery !!
↧
↧
BASCOM-AVR : I2C Problem with ATMega 168pa : NEWTOPIC
Dear all,
I try to drive a MIDAS-Display (ST7032 Controller) with a ATMega 168pa. I have also two port expander and some other I2C connected with the bus.
After a long sequence of trying to initialize the display I got doubts whether the TWI is working. I also tested both expander and also no reaction.
The pull up resistors are connected 3,3V -> 4k7.
By reading the documentation from Atmel for ATMega168 I found this remark:
[quote:a699865dd8]The PRTWI bit in Power Reduction Register - PRR on page 40 must be written to zero to
enable the 2-wire Serial Interface.[/quote:a699865dd8]
PRTWI is bit 7
In m168pdef.dat I found PRR=$64. Is it comparable with &H64? Is it possible to change to &H24 ($24, in this case bit 7 would be 0)? Is it the reason why TWI can´t be accessed?
best regards,
Benedikt
[b:a699865dd8][color=red:a699865dd8](BASCOM-AVR version : 2.0.7.6 , Latest : 2.0.7.7 )[/b:a699865dd8][/color:a699865dd8]
↧
BASCOM-AVR : I2C Problem with ATMega 168pa : REPLY
the register is 0 by default/reset so TWI is enabled.
do you use TWI mode (lib included???) or soft mode twi?
Better to show some code!
↧
BASCOM-AVR : I2C Problem with ATMega 168pa : REPLY
Here is one sample. The base of this sample is from one post. I modified a little bit.
So that I failed to initialize the Display, I tried to access a PCA9554 expander. I also failed and then I found the remark in the documentation from Atmel regarding the PRR and PRTWI-Bit.
How can I check the value of the Power-Reduction-Register?
↧
↧
BASCOM-AVR : I2C Problem with ATMega 168pa : REPLY
you can simply print the value just like any other register.
i advise to first run the i2cscanner from the samples . it will show all i2c devices on the bus.
↧
BASCOM-AVR : 2077 official release : REPLY
Bascom Rocks !!
Baie goed !
Nico
↧
BASCOM-AVR : I2C slave and master in same chip..? : REPLY
I've tried this in all possible combinations, with or without twen, twie and twint
twie 0/1 for master and so on.
sub SetToSlave()
twcr.twen = 0
twcr.twie = 0
twcr.twint = 1
Gosub _twi_init
isMaster = 0
twcr.twen = 1
end sub
sub SetToMaster()
twcr.twen = 0
twcr.twie = 1
twcr.twint = 1
Gosub _i2c_init
isMaster = 1
twcr.twen = 1
end sub
My program starts with this (after all the basic stuff...):
$lib "i2c_twi.lbx"
twbr = 72
twsr = 0
'Config Twi = 100000
Config Sda = Portd.1
Config Scl = Portd.0
i2cinit
const i2cAddress = &HA8
call SetToMaster()
After that I send a few bytes on the I2C line and it works fine, see "beforeS.png"
Then I load the slave driver, config it and set it back to Master:
$lib "i2c_twi-slave.LBX"
Config Twislave = &HA8 , BTR = 2 , BITRATE = 100000 , SAVE = save , GENCALL = no ', USERACK = on
call SetToMaster()
Now Master mode doesn't work and the I2C line looks like in AfterS.png
[img]
[/img]
Any ideas?
↧
BASCOM-AVR : Problem with serial data transfer : REPLY
Hi Mark Alberts ,
many thanks for your answer , I change my code like the first post . Your second post I do not understand , I change the code in the receiving MC but I don't know the change in the transmit MC . The variable Y is not more in the print command . On the lcd I can see the data from x and y , but I cannot control in what line or colum they are displayed .
Many thanks for every answer
Hans
↧
↧
BASCOM-AVR : Problem with serial data transfer : REPLY
hi, i do not give complete samples, i just try to get you on your way.
the Y i was missing. my point : when you start sending data like 123------456 123----456 ,how can you be sure that the receiver know what the start is? some data might never arrive because receiver is powered later for example.
So you need to have a simple protocol.
# means start of data , in your receiver you keep waiting till you get this character !
, can be delimiter for multiple values like x and y :
I would not send all the ------ since you can easily add that in the receiver. send as little data as is needed is best.
so send would send :
#123,456#123,456
here you see, you do not know the end ! so you need a trailer as well like *
so you can send : #123,456*
or #123,456*#123,456*#123,456*
IN the receiver you need to build some logic using a simple state machine:
dim bState as byte
ISR :
b=udr 'get the character
select case b ' depending on the state
case 0 : 'no header yet so wait for #
if b="#" then ' ok we got the header
bstate=1 'next state
sX="" : sY="" 'clear strings
end if
case 1 : 'we only get here when the header was received so all data is X value until we get a ,
if b= "," then 'check the comma
bstate=2 'next state
else ' this means we receive data for X
sX=sX+chr(b) 'store in string
end if
case 2 ' this means the comma was received and now we receive data for Y till we get a *
if b="*" then 'end
lcd sX
lowerline lcd sY
bstate=0 'reset state
else 'still data for Y
sY=sY+ chr(b)
end if
end select
return
try to follow the flow in the isr. maybe by using the simulator.
↧
BASCOM-AVR : I2C slave and master in same chip..? : REPLY
ahem, my comment was confusing.
sub SetToMaster()
twcr.0 = 0 'disable
end sub
sub SetToSlave()
twcr.0=1 'enable
end sub
That way it should work. But you must switch when the bus is free.
Do you use Proteus? if you make me a proteus i will check it.
The slave driver work on interrupt so it need an enabled interrupt.
The master does not work in int mode so that is why you need to disable it.
And other wise you can test this :
after you loaded the master, save the register content of twcr , then do the same after the slave mode, and then write the backed up master value.
↧
BASCOM-AVR : printbin array length of a variable? : REPLY
Does Peersize really have to be a variable in your application ?
Whie I can imagine cases where that might be useful, my impression is that for the very few times you might want to control the number of elements printed from an array within the program, you might as well use a loop.
That at least offers the most flexibility, like printing from say element 15 to element 23, both under program control. You would need a complex addition to the compiler to handle that, and who would remember it ?
I know that Bascom has gone well past the original acronym of Basic, but I still feel its better to limit the number of commands and the complexity of the syntax, and let users learn them well enough to be able to do anything they can construct.
↧
KokkeKat FAT-free SD card lib : Compatibility : NEWTOPIC
Hi Niclas,
Is this FAT32 library compatible with a PC so thet the card can be read / /modified on a PC
and then reinserted into the micro and used with the modified data.
Regards
Deanus
↧
↧
BASCOM-AVR : I2C Problem with ATMega 168pa : REPLY
Dear Mark,
thanks for information. The program is now working. The last days I used AVRStudio 5 with the known results. Finally I tried the same code without any changings with AVRStudio 6 and the display started. Any idea about the reason why I2C didn´t work?
Much thanks again.
Best regards,
Benedikt
↧
BASCOM-AVR : I2C Problem with ATMega 168pa : REPLY
maybe studio 5 programmer did not work?
I have no idea. maybe a wire or setting in studio options?
↧
BASCOM-AVR : I2C slave and master in same chip..? : REPLY
Thanks Mark
Reloading TWCR is a brilliant idea :-)
How do you suggest I make sure the bus is free?
Will it work by checking twcr.twint = 1 or do I also need to check the pin states of SCL SDA?
↧
BASCOM-AVR : I2C slave and master in same chip..? : REPLY
i think that you can simply use i2cstop for both master/slave
↧
↧
BASCOM-AVR : LS7366r : NEWTOPIC
Hi
I use a LS7366 encoder counter chip in non-quadrature count mode, - so no crystal.
The spi data from the chip seems to be fine - hardware wise .
My hardware spi setup is :
cpu clock = 16 MHz
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 1
Spiinit
Config Pinb.0 = Output 'Will be used a SS pin. (Can be any I/O pin)
Portb.0 = 1
I can read data from the chip and it change as I rotate the encoder - up down count sequence 100 % , chip itself is working fine.
The problem is that I can not change the MDR1 register to 2 byte counting - it is set to 00 on power so it is set as 4 byte counting and I have to read 4 bytes.
The second problem is that the count bytes , after received in a LONG is not in order , it is LSB , LSB+1 , LSB +2 , MSB.
The order out of the chip on my scope is bit 32 ...........bit 0
Printed as binary on screen it is bit 7 -----bit 0 , bit 8...... bit 15 , bit 16 ......bit 23 , bit 24 .......bit 31
So to get the 2 byte count I require I have to use makeint ( byte 3 , byte 2 ) .
parts of code :
Dim Enccntlong As Long
Dim Encb0 As Byte At Enccntlong Overlay
Dim Encb1 As Byte At Enccntlong + 1 Overlay
Dim Encb2 As Byte At Enccntlong + 2 Overlay
Dim Encb3 As Byte At Enccntlong + 3 Overlay
Dim Enccntwrd As Word
Spicount:
Reset Portb.0 ' spi ss
Tempb = &B01100000 'read counter command
Spiout Tempb , 1 ' send command to chip
Spiin Enccntlong , 4 ' read the 4 counter bytes
nop
Set Portb.0
Enccntwrd = Makeint(encb3 , Encb2) ; use only last 16 bits from 32 bits
Print #2 , Enccntwrd ; this is the correct count value
Print #2 ,
Return
I can perform a chip counter reset .
What can be the reason that I can not write to the counter registers to change the counter mode ( nr of bytes ) ?
From the datasheet the data is shifted out MSb first .
So if I shift 32 bits data over SPI the MSB of the data will end up as bit 0 in a LONG variable ?
Is there a way to specify the data order into a variable since I can not change the order the chip transmit it .
Cheers
nico
[b:fc55a099db][color=red:fc55a099db](BASCOM-AVR version : 2.0.7.6 , Latest : 2.0.7.7 )[/b:fc55a099db][/color:fc55a099db]
↧
BASCOM-AVR : ATXMega128D4U : NEWTOPIC
I have not been able to find a .dat file for this chip. Can anyone help? I suspect I have to use one for another chip and modify but how and what?
Peter
[b:71f5be4d1e][color=red:71f5be4d1e](BASCOM-AVR version : 2.0.7.7 )[/b:71f5be4d1e][/color:71f5be4d1e]
↧
BASCOM-AVR : Error - Control 'dxDockErrorPanel' has no parent window : NEWTOPIC
Hello,
I don't know what happens but now i can't start correctly Bascom, it show always
Control 'dxDockErrorPanel' has no parent window.
What can i do to fix that?
Best regards
toto
[b:760c86f661][color=red:760c86f661](BASCOM-AVR version : 2.0.7.2 , Latest : 2.0.7.7 )[/b:760c86f661][/color:760c86f661]
↧