2020-07-17 05:41 AM
hello sir
i use the i2c bus on a stm8s208.
there is just connected 2 pcf8574.
the crystal i used is 8Mhz, and a i2c clock divider of 4
one pcf8574 is connected to dipswitched , adress is 42
the second pcf8574 is connected to led's, adress is 40
individualy its working. both.
so i can read, the switches, and i can send information so the leds are lighting up.
even i read first the switches and then i go to the led sending routine ,and put then a 'break" in the stv development its still ok.
but, now, if i jump back to read the switches, , i can't read my switches, its stops in the "pcf8574 start routine" of the led's.
another information, the same board, the same adressing, id working with the arduino i2c bus.
so,my board is "functionaly" ok.
send the file in addembler here with
can you tell me or give me some clues,what i did wrong in the programming
many thanks
marc debruyne
2020-07-20 02:02 AM
hello
well, its sometimes necesary, to try to solve it all yourself , after a bit of search, it works with just adding a delay of 100ms
now it works ok
bye
marc debruyne
2020-07-21 09:52 AM
Hello Marc!
Usually I'm glad to see people programing in assembler, but the code listed by you it's a total disaster - I hope it's not discouraging!
Some thoughts:
; initialize SP
ldw X,#$stack_segment_end
ldw SP,X
bres I2C_CR1,#0
mov I2C_TRISER,#$10
mov I2C_CCRL,#$A0 ;was 46
mov I2C_CCRH,#$28
mov I2C_ITR,#$02
mov I2C_FREQR,#$01 ;was 11
mov I2C_OARH,#$40
mov I2C_OARL,#$A0
bset I2C_CR1,#0
; bset I2C_CR2,#2
; bset I2C_CR2,#0
ret
, now let me see: you write to a reserved location in I2C_CCRH (bit 5), the values you write in I2C_CCRL makes no sense (very low SCL frequency); you write the own address registers and I guess from your description that your MCU is a master.
Goodbyte!
2020-07-21 11:12 AM