One possible option is the Colegio Mayor Sant Raimon de Penyafort:

The contact details are available on the following website:

https://www.penyafort.ub.es/?mod=colegis&pag=contacte

There are rooms for visitors, although it is not particularly cheap (room and breakfast for €52.10). A discount is applied for stays of more than one week.

Another alternative sent in by a student from a previous course:

In Barcelona I stayed in Residencia Nikbor; it was better than the hostel in Madrid but worse than the university hall of residence. For students arriving in Barcelona by plane, there is a local train from the terminal which leaves you right on the street where the hostel is located after four or five stops. There is also a Metro stop next to hostel which takes you to the Faculty of Physics, so it has a good location. Breakfast is included in the price and you can also order dinner for an extra fee by arrangement although it is somewhat expensive and is nothing special. I recommend that you go to the restaurants around Plaza Cataluña for dinner.

http://www.nikbor.com/