Saturday, 2016-06-18

*** tpb has joined #timvideos00:00
*** sab_123 has joined #timvideos00:51
sab_123mithro, I have one question. I understand that UART needs code in the ISR because it has no clock. But since MPSSE allows only master mode, can I have all my I2C routines running on a main while() loop instead of an ISR? Otherwise code wise the ISR will become extremely long00:53
*** springermac_ has joined #timvideos00:56
*** springermac is now known as Guest9107100:56
*** springermac_ is now known as springermac00:56
*** Guest91071 has quit IRC00:57
mithrosab_123: If your ISR routines are more then a couple of instructions you are doing something wrong02:45
sab_123mithro, I decided not to use the ISR for I2C02:46
mithrosab_123: you should be using the ISR for doing the actual shifting02:46
sab_123mithro, I have tried that out02:47
sab_123mithro, it becomes pretty complex02:47
sab_123I need to have about 10 states02:47
mithrosab_123: then you are doing something wrong02:47
sab_123mithro, the problem is this. If you plan to shift data out in the ISR, then you need to have data ready in the buffer. Different I2C devices have different number of bytes which need to be sent as address. For example the eeprom that I am working on has a 3 byte address02:48
sab_123mithro, not only this you need to change the state also in the ISR02:48
sab_123mithro, my second attempt02:49
mithrosab_123: your ISR shouldn't understand I2C, it should be a simple shifter02:49
sab_123mithro, take a look at this02:49
sab_123please note code isnt formatted02:50
sab_123I am redoing the architecture now fully02:50
sab_123because I believe using the ISR is not a good way to proceed( I may be wrong here)02:50
mithrosab_123: I'm not looking at any code which isn't formatted02:51
mithrosab_123: no seriously, if you aren't formatting your code correctly then you are wasting a huge amount of time02:53
tpbTitle: [C] if ( my_i2c_states == start ) { //Send the start bit. Need to sen - (at
mithrosab_123: formatting is broken02:54
sab_123mithro, I ran it through astyle02:54
sab_123Which line is broken02:55
mithroLook at line 39 and below02:59
sab_123mithro, I did that02:59
sab_123It makes it easier to understand where the jumps are02:59
sab_123in asm there is no bracket03:00
sab_123so i was getting confused as to where the jumps end03:00
sab_123If you need to shift bits out in ISR, then you need to shift bits in also in the same ISR for the read part03:01
sab_123Then you need to put these into a buffer03:01
sab_123do you want me to proceed like that?03:02
sab_123Have a read and write block in ISR, once it is done put it into the buffer and have states which the ISR sets to understand what the data is?03:02
mithrosab_123: As I mentioned above the ISR should be something as simple was "rotate BUF, mov C->Y, mov Z->C, rotate BUF"03:05
mithrosab_123: then your other code should put the right data into BUF03:06
mithrosab_123: maybe you want BUF to be double buffered03:06
sab_123mithro, I should have atleast a CJNE to know if it is write or read03:07
sab_123a counter to count03:07
sab_123both in ISR03:07
sab_123It adds up pretty quickly03:07
mithrosab_123: not really, the ISR just shouldn't be running when there is nothing to shift in/out03:07
sab_123it needs a count to know how many bits have been shifted out correct?03:08
sab_123Anyway I will give it another try and write it again03:08
mithrosab_123: and like literally the above are the ASM commands03:08
sab_123Line 58-7603:09
sab_123Line 80-9703:10
sab_123Inside ISR03:10
sab_123mithro, I will try to make it shorter03:11
sab_123and then commit and ping you back03:11
mithrosab_123: As I said, the ISR should *not* understand I2C, it is simply something which shifts data in/out03:12
mithrosab_123: If your ISR is longer then 8 ASM instructions, you are doing something wrong03:12
sab_1238 cycles is going to be pretty hard to achive03:15
sab_123I will give it a shot03:15
mithrosab_123: I think you can do it in 503:15
sab_123Shift + toggle SCL yes03:15
sab_123but how does ISR know read/write03:16
sab_123so CJNE 303:16
sab_123But CJNE with what? You need to do a mov to do CJNE03:16
sab_123So thats another 2 cycles03:16
sab_123typically you also want to store the ACK/NAK03:17
mithrosab_123: the ISR you setup to be called is different depend on read, read/write or write03:17
sab_123There are only 3 timer ISR's03:18
sab_123Timer 0 is being used03:18
sab_123for UART03:18
sab_123Timer 1 is also being used for callbacks03:18
sab_123I can use Timer 2 for 103:18
mithrosab_123: patch the jump instruction03:19
sab_123I did not understand03:19
mithrosab_123: when the interrupt is called, the code jumps to a given location in memory03:20
mithrosab_123: that location in memory will be a jump instruction to your ISR routine03:20
mithrosab_123: so if you change the contents of that location in memory you will jump to a different ISR routine03:20
tpbTitle: fx2lib_serial_uart/usbav.a51 at master · RacingTornado/fx2lib_serial_uart · GitHub (at
mithrosab_123: or make the jump instruction a computed jump based on another value03:22
sab_123well jump cycles arent free either03:22
mithrosab_123: yes?03:22
sab_123AJMP is 3 cycles03:24
sab_123LJMP 403:24
mithrosab_123: sure03:24
sab_123so its going to add up pretty quickly right03:24
sab_123CJNE is 4 too03:25
sab_123so a CJNE+MOV to jump is 6 cycles03:25
sab_123Then about 5 for shifting03:25
sab_123maybe 11 cycles03:25
mithrosab_123: I'm pretty sure I said 8 ASM instructions, not 8 cycles03:25
sab_123My bad03:26
sab_123Another thing we arent thinking of is the ACK/NAK bit03:26
sab_123If you want to store in an extra buffer03:26
sab_123it is the 9th bit03:26
mithrosab_123: the ACK/NAK bit is higher level03:26
sab_123So 8 bits isnt enough03:26
sab_123for shifting03:27
mithrosab_123: How many times do I have to repeat that the ISR knows nothing about I2C?03:27
sab_123I completely agree03:27
sab_123I dont deny it03:27
mithrosab_123: The I2C code will just have to load the ACK/NAK bit into the buffer and cause one more shift to occur03:27
sab_123What I am trying to say is shifting happens on an unsigned char03:28
sab_123This is 8 bits long03:28
sab_123If you try to shift the ACk/NAK into the same buffer03:28
sab_123There is going to be an overrun03:28
sab_123We need extra logic within the ISR to handle this03:28
mithrosab_123: no you don't03:29
mithrosab_123: 9 bits can be divided into 8 bits and 1 bit03:29
mithrosab_123: so you do your 8 bits, then you update the ISR, then you do your final bit, then you update the ISR03:30
mithrosab_123: think of it like this way, how would you write I2C support if you had 8 bit shift register?03:32
sab_123I understand what you are saying.03:32
sab_123I just think we will end up with a couple of more instruction cycles03:32
sab_123Let me give it a 3rd try03:33
sab_123like for example03:34
sab_123We will have to signal ISR has finished trasmitting the 8 bits03:34
sab_123or receiving the 8 bits03:34
sab_123So the main cal clear or read out the current buffer and put in a new one03:35
mithrosab_123: I might give you that one - but I'm not confident it is needed yet03:35
sab_123mithro, okay let me get started then03:36
*** Bertl_oO is now known as Bertl_zZ04:40
mithrosab_123: lots of comments on your pull request05:09
sab_123mithro, okay05:10
*** CarlFK has quit IRC05:14
sab_123mithro, just one things05:19
sab_123Regarding testing05:19
sab_123The information is on the pull request comment05:19
sab_123mithro, in the features section05:20
mithrosab_123: No it isn't, there isn't a set of instructions like "Do X, Do Y, See result Z, Do A, See result B"05:20
sab_123Ah, okay05:21
sab_123Most of what you said can be cleaned up05:21
sab_123mithro, will ping you once it is done05:22
*** CarlFK has joined #timvideos05:22
*** ChanServ sets mode: +v CarlFK05:22
sab_123mithro, is it okay if I combine the timer based UART and fast uart05:55
sab_123fastuart is only 1 function05:55
mithrosab_123: then it should be a really simple pull request05:55
sab_123mithro, yes05:55
mithroand I'll be able to press "Merge" after like 30 seconds of looking at it05:55
mithrowhich is good for everyone05:55
sab_123well I am adding a lot of code05:55
sab_123for timerbased uart05:56
sab_123it is tested05:56
sab_123both work together. I thought I needed to combine them and send it in05:56
mithrosab_123: you want a pull request to be the *smallest* amount of changes that get the effect you are after05:56
sab_123So you want me to add fast_uart first?05:57
sab_123Thats basically like 20 - 30 lines05:57
sab_123I will do that then05:58
*** se6astian|away is now known as se6astian06:44
*** aom has joined #timvideos07:12
*** panther has joined #timvideos07:54
*** sab_123 has quit IRC07:54
*** panther is now known as sab_12308:13
sab_123mithro, still working on it. Modifying the makefile seems to give me memory overlap errors for the DSCR_AREA, so still trying to find the issue08:13
*** se6astian is now known as se6astian|away09:27
sab_123mithro, sent it in10:09
mithro_florent_: ping?10:45
*** Bertl_zZ is now known as Bertl11:00
mithrosab_123: why are you opening and closing so many pull requests?11:01
mithrosab_123: you can see what ends up in a pull request before you click the button11:13
sab_123mithro, I realized that now11:13
sab_123mithro, its just that going back is kind of hard because I have so many things added11:14
sab_123mithro, I am going to get back to I2C now11:15
mithrosab_123: remember you should be writing small independent modular chunks that can be added together11:19
sab_123mithro, I agree11:20
mithrosab_123: that should be easy to send pull requests for each small part then11:20
sab_123mithro, I wanted to test how they work together11:21
mithrosab_123: sure, that should be additional work on the of the small parts11:22
mithroif you made your modular bits correctly, they shouldn't have to change at all to test them together11:24
mithrosab_123: you should aim to try and get stuff reviewed as early as you can11:29
sab_123mithro, okay11:29
*** se6astian|away is now known as se6astian11:49
*** panther_ has joined #timvideos12:16
*** sab_123 has quit IRC12:16
*** Bertl is now known as Bertl_oO12:28
*** ssk1328 has joined #timvideos13:50
*** panther_ has quit IRC15:45
*** ssk1328 has quit IRC16:24
*** se6astian is now known as se6astian|away16:41
*** ssk1328 has joined #timvideos17:37
*** se6astian|away is now known as se6astian19:22
*** ssk1328 has quit IRC20:44
*** thaytan_ has joined #timvideos20:57
*** thaytan has quit IRC21:00
*** se6astian is now known as se6astian|away21:37
*** springermac_ has joined #timvideos22:35
*** springermac is now known as Guest1270022:35
*** springermac_ is now known as springermac22:36
*** Guest12700 has quit IRC22:38

Generated by 2.13.1 by Marius Gedminas - find it at!