dratthenez
Newbie level 3
Hi,
I am currently doing my bachelor thesis and would appreciate if you could advise or comment on my solutions... I tried to manipulate the pin simo, somi, sclk and cs of my microcontroller so that I could observe the results with some expected value. However, I encountered problem at pin somi since there is no input observed.
Here´s my code: (the code is working but pin somi is not giving a desire output)
What could I do with the somi pin? From my understanding, the data readback will be auto-generated once the register 0 of trf chip is enable, correct me if I was incorrect.
I am currently doing my bachelor thesis and would appreciate if you could advise or comment on my solutions... I tried to manipulate the pin simo, somi, sclk and cs of my microcontroller so that I could observe the results with some expected value. However, I encountered problem at pin somi since there is no input observed.
Here´s my code: (the code is working but pin somi is not giving a desire output)
void main(){
trf372017 dev;
pin mosi;
pin miso;
pin sclk;
pin cs;
pin_init ( &cs, /* port #*/ 9, /* pin # */ 6, /* output*/ 0 );
pin_init ( &mosi, /* port #*/ 4, /* pin # */ 3, /* output*/ 1 );
pin_init ( &miso, /* port #*/ 4, /* pin # */ 4, /* input*/ 0 );
pin_init ( &sclk, /* port #*/ 4, /* pin # */ 5, /* output*/ 1 );
pin_init ( &led0, /* port #*/ 4, /* pin # */ 0, /* output*/ 1 );
trf372017_init( &dev0, &sclk, &mosi, &miso, &cs );
trf372017_write_mosi_default ( &dev0, 0x41500029, 0x08A0100A, 0x0000000B, 0x4A01F00C, 0xAA2AA28D,0xA090100E, 0x5041100F, 0x00000008 );
trf372017_read_from_device ( &dev0, &readback, /* Read Only message send*/ 0x90000008 );
}
void trf372017_read_from_device( trf372017 *dev0, long *readback, long mesj )
{
dev0->reg0 = mesj;
write_mosi_loop ( dev0, dev0->reg0 ); //(looping of 32bit)
pin_set ( dev0->cs ); // cs low (enable low)
pin_set ( dev0->sclk ); // clock high
pin_clear ( dev0->sclk ); // clock low
pin_set ( dev0->cs ); // cs high (enable high)
readback_miso_loop ( dev0, readback );
}
void readback_miso_loop ( trf372017 *dev0, long *readback )
{
char loop = 0;
while (loop < 32)
{
pin_set ( dev0->sclk ); // clock high
pin_read ( dev0->miso );
pin_clear ( dev0->sclk ); // clock low
loop++;
}
}
void pin_read( pin *p ) {
*(p->in_reg) = *(p->in_reg); //???WONDERING IF THIS IS CORRECT
}
What could I do with the somi pin? From my understanding, the data readback will be auto-generated once the register 0 of trf chip is enable, correct me if I was incorrect.