I am trying to implement a 1-Wire iButton (DS18B20) with my Q24Plus module on a WISMO02 Development Board. I am “pin-bashing” GPIO4 which corresponds to the ADL_IO_Q24PLUS_GPIO_4 pin. However I am finding that the fastest I can get from the Q24Plus is 2.198kHz @ 2.8V but I need at least a 1MHz signal for 1-Wire.
Not only does the Q24Plus generate this slow signal (2.198kHz), it can only generate it for 10 seconds before the program crashes. I then have to restart the program by autodetecting it in Terminal Emulator.
The timer() method is indirectly called from the Keyboard handler via the hello() method. I wanted to make sure that the Keyboard handler can call any method. I was having the same problem when I was calling the timer() method directly from within it.
The boolean “flag” is unset using the Keyboard Handler.
void timer()
{
//TRACE (( mcs_TraceLevel, "Inside the timer method at the beginning"));
s8 returnCode;
flag = TRUE;
//int count = 0;
while(flag){
//if (count == 1){
if (toggle == 0x00000000)
toggle = ADL_IO_Q24PLUS_GPIO_4;
else
toggle = 0x00000000;
returnCode = adl_ioWrite(gpioHandle, ADL_IO_Q24PLUS_GPIO_4, toggle);
/*count = 0;
}
count++;*/
}
//TRACE (( mcs_TraceLevel, "Inside the timer method at the end"));
}
void hello(){
TRACE ((mcs_TraceLevel, "Hello from hello() method"));
adl_atSendResponse(ADL_AT_UNS, "Hello from hello() method\r\n");
timer();
}
OUTPUT from Terminal Emulator:
Open AT: timer started //my comments: started timer
Hello from hello() method
+WIND: 0 // my comments: program crashes
+WIND: 7
kïýkïÿ ¨ ° ¸ À È Ð Ø à è ¼Open AT: timer started // my comments: restarted program then restarted timer.
Hello from hello() method
+WIND: 0 // my comments: crash again.
+WIND: 7
I didn’t find anything in the documentation about the clock rate on the Q24Plus but I think that it should be capable of generating a 1MHz signal so there must be something wrong with my code. Either that or there is a setting that I have overlooked.
Thank you for the speedy reply. I am new to programming microcontrollers and still learning.
I am using the MultiApp library which hopefully means that my program should run more than one application (thread?). This MultiApp library came with the sample programs bundled with OpenAT 3.19.
The reason why I thought the Q24Plus “should be capable of generating a 1MHz signal” was because of a quote in the datasheet WM_PRJ_Q24NG_PTS_001-004, p28 entitled “PTS_Q24_Series” but it is with reference to the SPI Bus where it reads “The frequency clock is programmable from 812kHz to 13MHz.” Surely if the Q24 can generate a clock signals within that range, it could do 1MHz.
Anyway thank you Awneil for the helpful tips, much appreciated.
It seems that the 1-wire protocol can be implemented directly using … a simple UART. The full explanation can be found in the datasheet of the Atmel AVR318 atmel.com/dyn/resources/prod … oc2579.pdf
I am interested to know if it works…
Actually, the technique is described in an Application Note on the Maxim/Dallas site.
I suggest that you start from the source document (on the Maxim/Dallas site) rather than someone else’s interpretation of it (the datasheet of the Atmel AVR318).
But I’m not sure if Open-AT will give you close enough control of the UART to do this…?
Bbo, thanks for pointing me in the right direction. I am looking at the AVR318 document now.
True Avneil, I am also looking at the Maxim Application Note 192 for using a UART. To use their userial lib (in the 1-Wire Public Domain Kit) the UART needs to use at least a DS2408B Serial 1-Wire Line Driver.
Again, I’m not sure that Open-AT gives you sufficient control of the UART - so you may still need to use a “bridge” chip like the DS2408B, or one of the others mentioned earlier, or a separate microcontroller…
Sorry, I haven’t sent a recent reply. Thanks for the heads up.
I have put aside the 1-Wire for now so I can first work on capturing GPS data through UART2 and send it as SMS. Then capturing image data and sending that. Finally I will come back to the 1-Wire in about two weeks time.