Hi everyone,
I'm trying to interface a temperature sensor DS18B20.
There is a way to implement one wire protocol to cc3200?
There is already an implementation?
Thanks in advance.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi everyone,
I'm trying to interface a temperature sensor DS18B20.
There is a way to implement one wire protocol to cc3200?
There is already an implementation?
Thanks in advance.
Hi,
I want understand if is my code wrong
//this code write 1 or 0 on 1-wire bus
//it takes the bit as parameter
void write_bit(unsigned short bit){ GPIODirModeSet(GPIOA0_BASE, 0x8, GPIO_DIR_MODE_OUT); PinConfigSet(PIN_58, PIN_STRENGTH_2MA|PIN_STRENGTH_6MA, PIN_TYPE_STD); GPIO_IF_Set(3, g_uport, g_upin, 1); UtilsDelay((3*80)/3); GPIO_IF_Set(3, g_uport, g_upin, 0); if(bit==0){ //must be 0 for 60 usec UtilsDelay(60*80); } else{ //must be to 0 for 1 usec UtilsDelay((3*80)/3); } GPIO_IF_Set(3, g_uport, g_upin, 1); GPIODirModeSet(GPIOA0_BASE, 0x8, GPIO_DIR_MODE_IN); PinConfigSet(PIN_58, PIN_STRENGTH_2MA|PIN_STRENGTH_6MA, PIN_TYPE_OD_PU); if(bit==0){ //must be 0 for 60 usec UtilsDelay((3*80)/3); } else{ //must be 0 for 1 usec UtilsDelay(60*80); } }
Hi,
I've modified my code to use a timer
in the main thread I set
MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK); MAP_PRCMPeripheralReset(PRCM_TIMERA0); MAP_TimerConfigure(TIMERA0_BASE,TIMER_CFG_ONE_SHOT); MAP_TimerPrescaleSet(TIMERA0_BASE,TIMER_A,0); Timer_IF_IntSetup(TIMERA0_BASE, TIMER_A, handletimer); GPIO_IF_GetPortNPin(3, &g_uportauscita, &g_upinuscita); set_output(); //set output line to high GPIO_IF_Set(3, g_uport, g_upin, 1); UtilsDelay((10*80)/3); MAP_TimerLoadSet(TIMERA0_BASE,TIMER_A,(8000000/1000000)*(1)); GPIO_IF_Set(3, g_uportauscita, g_upinuscita, 0); MAP_TimerEnable(TIMERA0_BASE,TIMER_A); In the handler the code Semaphore_pend(sem,BIOS_WAIT_FOREVER); //UART_PRINT("Overflow\n\r"); if(counter_phases==0){ if(counter_tick_GPT<480){ GPIO_IF_Set(3, g_uport, g_upin, 0); //the timer count every 1 usec MAP_TimerLoadSet(TIMERA0_BASE,TIMER_A,(80000000/1000000)*(1)); MAP_TimerEnable(TIMERA0_BASE,TIMER_A); contatore_tick_GPT++; } else{ GPIO_IF_Set(3, g_uport, g_upin, 1); MAP_TimerLoadSet(TIMERA0_BASE,TIMER_A,(80000000/1000000)*(1)); MAP_TimerEnable(TIMERA0_BASE,TIMER_A); set_input(); counter_tick_GPT=0; counter_phasis=2; } } else if(counter_phasis==1){ set_input(); //incremento il contatore_fasi counter_phases=2; counter_tick_GPT=0; MAP_TimerLoadSet(TIMERA0_BASE,TIMER_A,(80000000/1000000)*(1)); MAP_TimerEnable(TIMERA0_BASE,TIMER_A); } else if(counter_phasis==2){ v = GPIO_IF_Get(3, g_uport, g_upin); if(counter_tick_GPT<10){ MAP_TimerLoadSet(TIMERA0_BASE,TIMER_A,(80000000/1000000)*(1)); MAP_TimerEnable(TIMERA0_BASE,TIMER_A); counter_tick_GPT++; } else if((counter_tick_GPT>=10)&&(counter_tick_GPT<240)){ MAP_TimerLoadSet(TIMERA0_BASE,TIMER_A,(80000000/1000000)*(1)); MAP_TimerEnable(TIMERA0_BASE,TIMER_A); counter_tick_GPT++; } }
Semaphore_post(sem);
But after 15 usec from I set the output to high the sensor sets the bus to low only for 1 usec and not for 60 - 240 usecs.
Are the timer load sets wrong?
I've considered that MCU frequency is 80Mhz
then to count 1 usec the time to count is (80000000/1000000)*(usecs)
I have only one 1-wire device on the bus.
I'm using this function to read from bus when I ask to read scratchpad
unsigned char read_bit(void) { unsigned char v; // Get port / pin addys unsigned int addr; unsigned char pin; GPIO_IF_GetPortNPin(0, &addr, &pin); osi_EnterCritical(); // Mode Out output_mode(); // Pull Line low to start timeslot GPIO_IF_Set(0, addr, pin, 0); UtilsDelay((3*80)/3); // Pull Line high GPIO_IF_Set(0, addr, pin, 1); // Mode In input_mode(); // Delay 15usec //UtilsDelay((15*80)/3); UtilsDelay((10*80)/3); // read value v = GPIO_IF_Get(0, addr, pin); osi_ExitCritical(0); // end of timeslot UtilsDelay((53*80)/3); // return value of DQ line return(v); }
but I read only High value on the bus. It's a UtilsDelay time issue?
Thanks for help :D