Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

MCU thread

Status
Not open for further replies.

MacIntoshCZ

Active Member
Just scanned ds3231 and it shows two adresses. Why????
1625201945249.png
 
Oh there is also eeprom atmel732... :banghead::banghead::banghead:
 
Last edited:
Can i define speed of i2c in one command like this? Syntax is not working.
I need to set those two bits in zero for no prescaler.
atmega 8, CPU speed is 8Mhz
I am probably just messing #define with functions. becouse this function works
void TW_100khz() {TWBR = 32; TWSR &= ~(0x03);}

1625208810969.png


This not works:

//f = (F_CPU) / (16+2 * (TWBR) * 4^(TWPS))

#define TW_100khz TWBR = 32 TWSR &= ~(0x03)
 
Last edited:
All I2C eeproms are 7 bit 0x5(x), or 8 bit 0xA(x) + address! 0x57( 0xAE ) is the 8th address ie.. all address lines at high.

Check the max speed of the RTC before you jack it too high..

As you only have four options Try slowest, then bit by bit increase until it fails...
 
Does anyone know any datasheet for STM32 that is writted well like datasheets for avr - atmega?
At the moment i think the best way to embdded system is actually reading datasheets.
And this datasheet is well writed. From my perspective... Since my mother language is not English and i am not able to find anything good in CZECH i am forced to read in english. BTW most of my books are from ČSSR era.. =D. In that time comunism forced book publishers to translate technical books or to create their owns...
I also looked for some college books but most of reccomended books are in English. How hilarious!
 
I also looked for some college books but most of reccomended books are in English. How hilarious!

Sorry, but not at all - most Universities teach in English - even French ones have started to do so recently, and the French are rabidly anti-English :D

English is the International language of science, so it makes sense for the books to be in English.

My daughter works at a Dutch University, in a department run by German Professors, needless to say the language used is generally English (she does speak Dutch as well, but not German). Interestingly, while the University all speak English, the city it's in doesn't - as it's near the German border I presume any second language is likely to be German. So while if you go to Amsterdam (or any Western city) English is universally spoken, but in the East it's pretty rare - even tourist attraction have little or no English speaking staff.

However, I can't really complain, I doubt you're going to find many speakers of Czech either :D

As for datasheets, something like an STM32 datasheet is going to be HUGE - even PIC ones are - it's just a matter of occasional searching for what you're looking for.
 
Sorry, but not at all - most Universities teach in English - even French ones have started to do so recently, and the French are rabidly anti-English :D

English is the International language of science, so it makes sense for the books to be in English.

My daughter works at a Dutch University, in a department run by German Professors, needless to say the language used is generally English (she does speak Dutch as well, but not German). Interestingly, while the University all speak English, the city it's in doesn't - as it's near the German border I presume any second language is likely to be German. So while if you go to Amsterdam (or any Western city) English is universally spoken, but in the East it's pretty rare - even tourist attraction have little or no English speaking staff.

However, I can't really complain, I doubt you're going to find many speakers of Czech either :D

As for datasheets, something like an STM32 datasheet is going to be HUGE - even PIC ones are - it's just a matter of occasional searching for what you're looking for.
Well i am ok with english. I can translate world by world in most of cases easily. BUT sometimes the sentence just dont make sence becouse it requires some feeling from mother language. Its hard to explain. Just imagine reading datasheet which is written by person like me in english. :D or translate czech article to english. I guess it will be nightmare.
Also what scares me the most is when i read something in english without figures. I want to close a book then immediately...
 
When interfacing i2c should mcu do other tasks? Shall i implement this line of code (bolded, italic, underlined)? Purpose of this is to wait for "job done" bit.

#include <avr/io.h>
#include <util/delay.h>
#include <util/twi.h>
//Definice adres na sběrnici
#define DS3231 0x68;
#define DS3231_EEPROM 0x57;
//Nastavení rychlosti cpu 8Mhz
#ifndef F_CPU
#define F_CPU 8000000UL
#endif
// Definice příkazů i2c
#define TW_SEND_START TWCR = (1<<TWINT) | (1<<TWSTA)
#define TW_SEND_STOP TWCR = (1<<TWINT) | (1<<TWSTO)
#define TW_SEND_DATA TWCR = (1<<TWINT)
#define TW_WAIT while(!(TWCR & (1<<TWINT)))
#define TW_ON TWCR = (1<<TWEN)
#define TW_OFF TWCR = (0<<TWEN)
//f = (F_CPU) / (16+2 * (TWBR) * 4^(TWPS))

// *** FUNKCE***
// Nastavení 100Khz rychlosti i2c komunikace
void TW_100khz() {TWBR = 32; TWSR &= ~(0x03);}
// Zasílání dat
char I2C_SEND_DATA(char adress, char *data, unsigned int data_size)
{
adress= adress<<1;
TW_ON;
TW_SEND_START;
TW_WAIT;
}
 
Last edited:
Well i am ok with english. I can translate world by world in most of cases easily. BUT sometimes the sentence just dont make sence becouse it requires some feeling from mother language. Its hard to explain. Just imagine reading datasheet which is written by person like me in english. :D or translate czech article to english. I guess it will be nightmare.

A number of other departments at the University where my daughter works use her to edit their work into correct English, while many Dutch speak excellent English there's definitely a few translation issues that end up making no sense :D So having a native English speaker, who also happens to be excellent at English (most scientists aren't), is a huge advantage for them.

Taking 'datasheets' etc, when my daughter first went to the Netherlands it was on a years work experience, working for the worlds leading authority on rubber :D One of her first assignments was to research and find everything she could about rubber and vulcanisation - and much of the early work was in German or Polish, with no English translations available.

As for your English, here at least, it's perfectly acceptable - and I never think "he's not English", as you do with many.
 
A number of other departments at the University where my daughter works use her to edit their work into correct English, while many Dutch speak excellent English there's definitely a few translation issues that end up making no sense :D So having a native English speaker, who also happens to be excellent at English (most scientists aren't), is a huge advantage for them.

Taking 'datasheets' etc, when my daughter first went to the Netherlands it was on a years work experience, working for the worlds leading authority on rubber :D One of her first assignments was to research and find everything she could about rubber and vulcanisation - and much of the early work was in German or Polish, with no English translations available.

As for your English, here at least, it's perfectly acceptable - and I never think "he's not English", as you do with many.
Yours last sentence is good example of "mother language sense" I dont exactly know what do you mean by - I never think "he's not English", as you do with many. I can translate first half as: He can write and understant articles in english, and second part: he thinks about others that they cant write/read in english. =)
 
Whats behind Error() function?What should i code here? Should i end i2c here, wait and repeat?
1625307246301.png
 
Its code you write to handle a condition that deviates for the main flow of your code.

In table your example callout is to handle a bit thats not a start bit .....? Just a guess on my part.
So you code to handle that exception.


Regards, Dana.
 
Can someone tell me, why there is need for repeatedly write logic one to TWI Enable register? Thanks
1625310623976.png

Also i would like implement debug feedback for terminal. Is there any way?
1625310834074.png

Probably need to study this
 
Last edited:
It looks like its working. I though that rigol has better environment. I can see only in event table that ACK bit was received.
This command should adress ds3231 on slave adress 0x68, and then write 0x33 to 00h register.
0x33 -> 0b0_011_0011 -> 33 seconds
1625336349235.png
 

Attachments

  • DS1Z_QuickPrint9.png
    DS1Z_QuickPrint9.png
    52.7 KB · Views: 197
  • DS1Z_QuickPrint10.png
    DS1Z_QuickPrint10.png
    50.3 KB · Views: 201
Last edited:
I need to send high nibble becouse of 4bit lcd comunication.
When i am shifting 4 bits right is masking even necessary? Its not like old snake game =)?
1625485307000.png
 
You don't need to mask for this shift.
 
Last edited:
I am just curious how library of util delay know which frequency of cpu i select?
I have plan to substitute _delay by timers
¨
1625497361721.png
 
I am just curious how library of util delay know which frequency of cpu i select?
I have plan to substitute _delay by timers
¨View attachment 132335

It depends entirely on the compiler/IDE - usually you define it in the source code somewhere - but I've had instances recently using MPLABX and XC8 on PIC's where it seems to detect it automatically, presumably from the clock setting part of the code?.
 
OK, I have written a program for showing a character on the display. I need to learn pointers in C, for char array.
I tried this at C terminal on pc. But it not works.
1625563934914.png

edit 1 :
Oh nice. This works
1625564357486.png

edit 2 :
instead of %s there should be %c.... at first picture
 
Last edited:
I am having this error:
src\main.cpp: In function 'int main()':
src\main.cpp:17:26: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
lcd_string("Ahoj", 0, 1);



void lcd_string(char *string, int x, int y)
{

lcd_nastavKurzor(x, y);
for (int i = 0; string != 0; i++)
{
lcd_data(string);
if(i<15)
{
lcd_posunKurzor_vpravo();
}
}
}

But it works (It displays "A h o j" on second line) anyway.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top