Using IOBus for stm32f4

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
Faisal Mehmood
Posts: 25
Joined: Sat Jan 26, 2013 10:18 pm

Using IOBus for stm32f4

Post by Faisal Mehmood »

I'm trying to make an IOBus that is 8 bits wide. this is what i wrote:

Code: Select all

static IOBus bus_data = {
   GPIOA, //IOBus will contain pins of GPIOA
   8, // Bus width is to be 8 bits
   0, // No offset from the least significant bit.. meaning the lower 8 bits are to be used ??????????
};


then, in the main function, i used the following instruction to get an alternating bit pattern on GPIOA port:

Code: Select all

palWriteBus(&bus_data,0b10101010);


This code is not working.... I am not too sure about the IOBus configuration.. Can someone tell me what's wrong??
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Using IOBus for stm32f4

Post by Tectu »

What you did seems to be right.
How exactly can you tell it's not working? Dosen't happen anything? Do only some pins change the state?

However, it's very likely that your problem is that the PORTA pins on the header of the STM32F4 Discovery board are also used "internally" on the board. When you take a look at the board file, you can see that most of the pins are set as input or alternative.
Make sure the hardware connected to these pins makes no issues and that your pins are configured as digital output correctly.



~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Using IOBus for stm32f4

Post by Giovanni »

Hi,

The second field is the bus mask not the bus size so you have to write 0xFF there. Probably this is your problem, also make sure your pins are programmed as outputs.

Giovanni
Faisal Mehmood
Posts: 25
Joined: Sat Jan 26, 2013 10:18 pm

Re: Using IOBus for stm32f4

Post by Faisal Mehmood »

@Tectu: I used the PORTB pins as well but they were not following the assigned bit pattern either..... I checked the output pins on oscilloscope but all the pins remain high


@Giovanni: Will change the second field and then check again.. hopefully it will solve the problem

Thanx guys for helping me out!
Faisal Mehmood
Posts: 25
Joined: Sat Jan 26, 2013 10:18 pm

Re: Using IOBus for stm32f4

Post by Faisal Mehmood »

Hey i changed the bus mask field of IOBus configuration structure to 0xFF as you told. Now the PIN1 to PIN7 of GPIOB are working fine; doing what I tell them to do however, PIN0 remains at low logic level all the times.. I tried PORTA too but it's PIN0 also remained low
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Using IOBus for stm32f4

Post by Giovanni »

Are you sure those pins are not conflicting with something else?

Giovanni
Faisal Mehmood
Posts: 25
Joined: Sat Jan 26, 2013 10:18 pm

Re: Using IOBus for stm32f4

Post by Faisal Mehmood »

I think not... my program does nothing other than changing the data on these 8 pins from 0xFF to 0x00 every 1 second.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: Using IOBus for stm32f4

Post by Tectu »

What Giovanni meant is what I said before: On the board (F4 discovery as I guess) are other peripherals such as the accel, microphone, codec etc. it's very likely that a pin is connected to one of those peripherals and does therefore not work properly. You should check the F4 Discovery datasheet.


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Using IOBus for stm32f4

Post by Giovanni »

Exactly, probably those pins are used by other things that keep them low, if in doubt see if the GPIO ODR registers contains the correct data after each write.

Giovanni
Post Reply